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
stephenc/redmine-java-api
src/main/java/org/redmine/ta/internal/RedmineJSONParser.java
RedmineJSONParser.parseStatus
public static IssueStatus parseStatus(JSONObject object) throws JSONException { final int id = JsonInput.getInt(object, "id"); final String name = JsonInput.getStringNotNull(object, "name"); final IssueStatus result = new IssueStatus(id, name); if (object.has("is_default")) result.setDefaultStatus(JsonInput.getOptionalBool(object, "is_default")); if (object.has("is_closed")) result.setClosed(JsonInput.getOptionalBool(object, "is_closed")); return result; }
java
public static IssueStatus parseStatus(JSONObject object) throws JSONException { final int id = JsonInput.getInt(object, "id"); final String name = JsonInput.getStringNotNull(object, "name"); final IssueStatus result = new IssueStatus(id, name); if (object.has("is_default")) result.setDefaultStatus(JsonInput.getOptionalBool(object, "is_default")); if (object.has("is_closed")) result.setClosed(JsonInput.getOptionalBool(object, "is_closed")); return result; }
[ "public", "static", "IssueStatus", "parseStatus", "(", "JSONObject", "object", ")", "throws", "JSONException", "{", "final", "int", "id", "=", "JsonInput", ".", "getInt", "(", "object", ",", "\"id\"", ")", ";", "final", "String", "name", "=", "JsonInput", "....
Parses a status. @param object object to parse. @return parsed tracker. @throws RedmineFormatException if object is not a valid tracker.
[ "Parses", "a", "status", "." ]
7e5270c84aba32d74a506260ec47ff86ab6c9d84
https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/internal/RedmineJSONParser.java#L205-L216
train
stephenc/redmine-java-api
src/main/java/org/redmine/ta/internal/RedmineJSONParser.java
RedmineJSONParser.parseMinimalProject
public static Project parseMinimalProject(JSONObject content) throws JSONException { final Project result = new Project(); result.setId(JsonInput.getInt(content, "id")); result.setIdentifier(JsonInput.getStringOrNull(content, "identifier")); result.setName(JsonInput.getStringNotNull(content, "name")); return result; }
java
public static Project parseMinimalProject(JSONObject content) throws JSONException { final Project result = new Project(); result.setId(JsonInput.getInt(content, "id")); result.setIdentifier(JsonInput.getStringOrNull(content, "identifier")); result.setName(JsonInput.getStringNotNull(content, "name")); return result; }
[ "public", "static", "Project", "parseMinimalProject", "(", "JSONObject", "content", ")", "throws", "JSONException", "{", "final", "Project", "result", "=", "new", "Project", "(", ")", ";", "result", ".", "setId", "(", "JsonInput", ".", "getInt", "(", "content"...
Parses a "minimal" version of a project. @param content content to parse. @return parsed project.
[ "Parses", "a", "minimal", "version", "of", "a", "project", "." ]
7e5270c84aba32d74a506260ec47ff86ab6c9d84
https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/internal/RedmineJSONParser.java#L289-L296
train
stephenc/redmine-java-api
src/main/java/org/redmine/ta/internal/RedmineJSONParser.java
RedmineJSONParser.parseProject
public static Project parseProject(JSONObject content) throws JSONException { final Project result = new Project(); result.setId(JsonInput.getInt(content, "id")); result.setIdentifier(JsonInput.getStringOrNull(content, "identifier")); result.setName(JsonInput.getStringNotNull(content, "name")); result.setDescription(JsonInput .getStringOrEmpty(content, "description")); result.setHomepage(JsonInput.getStringOrEmpty(content, "homepage")); result.setCreatedOn(getDateOrNull(content, "created_on")); result.setUpdatedOn(getDateOrNull(content, "updated_on")); final JSONObject parentProject = JsonInput.getObjectOrNull(content, "parent"); if (parentProject != null) result.setParentId(JsonInput.getInt(parentProject, "id")); result.setTrackers(JsonInput.getListOrNull(content, "trackers", TRACKER_PARSER)); return result; }
java
public static Project parseProject(JSONObject content) throws JSONException { final Project result = new Project(); result.setId(JsonInput.getInt(content, "id")); result.setIdentifier(JsonInput.getStringOrNull(content, "identifier")); result.setName(JsonInput.getStringNotNull(content, "name")); result.setDescription(JsonInput .getStringOrEmpty(content, "description")); result.setHomepage(JsonInput.getStringOrEmpty(content, "homepage")); result.setCreatedOn(getDateOrNull(content, "created_on")); result.setUpdatedOn(getDateOrNull(content, "updated_on")); final JSONObject parentProject = JsonInput.getObjectOrNull(content, "parent"); if (parentProject != null) result.setParentId(JsonInput.getInt(parentProject, "id")); result.setTrackers(JsonInput.getListOrNull(content, "trackers", TRACKER_PARSER)); return result; }
[ "public", "static", "Project", "parseProject", "(", "JSONObject", "content", ")", "throws", "JSONException", "{", "final", "Project", "result", "=", "new", "Project", "(", ")", ";", "result", ".", "setId", "(", "JsonInput", ".", "getInt", "(", "content", ","...
Parses a project. @param content content to parse. @return parsed project.
[ "Parses", "a", "project", "." ]
7e5270c84aba32d74a506260ec47ff86ab6c9d84
https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/internal/RedmineJSONParser.java#L305-L322
train
threerings/nenya
core/src/main/java/com/threerings/cast/ComponentClass.java
ComponentClass.getRenderPriority
public int getRenderPriority (String action, String component, int orientation) { // because we expect there to be relatively few priority overrides, we simply search // linearly through the list for the closest match int ocount = (_overrides != null) ? _overrides.size() : 0; for (int ii = 0; ii < ocount; ii++) { PriorityOverride over = _overrides.get(ii); // based on the way the overrides are sorted, the first match // is the most specific and the one we want if (over.matches(action, component, orientation)) { return over.renderPriority; } } return renderPriority; }
java
public int getRenderPriority (String action, String component, int orientation) { // because we expect there to be relatively few priority overrides, we simply search // linearly through the list for the closest match int ocount = (_overrides != null) ? _overrides.size() : 0; for (int ii = 0; ii < ocount; ii++) { PriorityOverride over = _overrides.get(ii); // based on the way the overrides are sorted, the first match // is the most specific and the one we want if (over.matches(action, component, orientation)) { return over.renderPriority; } } return renderPriority; }
[ "public", "int", "getRenderPriority", "(", "String", "action", ",", "String", "component", ",", "int", "orientation", ")", "{", "// because we expect there to be relatively few priority overrides, we simply search", "// linearly through the list for the closest match", "int", "ocou...
Returns the render priority appropriate for the specified action, orientation and component.
[ "Returns", "the", "render", "priority", "appropriate", "for", "the", "specified", "action", "orientation", "and", "component", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/ComponentClass.java#L159-L174
train
threerings/nenya
core/src/main/java/com/threerings/cast/ComponentClass.java
ComponentClass.addPriorityOverride
public void addPriorityOverride (PriorityOverride override) { if (_overrides == null) { _overrides = new ComparableArrayList<PriorityOverride>(); } _overrides.insertSorted(override); }
java
public void addPriorityOverride (PriorityOverride override) { if (_overrides == null) { _overrides = new ComparableArrayList<PriorityOverride>(); } _overrides.insertSorted(override); }
[ "public", "void", "addPriorityOverride", "(", "PriorityOverride", "override", ")", "{", "if", "(", "_overrides", "==", "null", ")", "{", "_overrides", "=", "new", "ComparableArrayList", "<", "PriorityOverride", ">", "(", ")", ";", "}", "_overrides", ".", "inse...
Adds the supplied render priority override record to this component class.
[ "Adds", "the", "supplied", "render", "priority", "override", "record", "to", "this", "component", "class", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/ComponentClass.java#L179-L185
train
threerings/nenya
core/src/main/java/com/threerings/miso/tile/FringeConfiguration.java
FringeConfiguration.fringesOn
public int fringesOn (int first, int second) { FringeRecord f1 = _frecs.get(first); // we better have a fringe record for the first if (null != f1) { // it had better have some tilesets defined if (f1.tilesets.size() > 0) { FringeRecord f2 = _frecs.get(second); // and we only fringe if second doesn't exist or has a lower // priority if ((null == f2) || (f1.priority > f2.priority)) { return f1.priority; } } } return -1; }
java
public int fringesOn (int first, int second) { FringeRecord f1 = _frecs.get(first); // we better have a fringe record for the first if (null != f1) { // it had better have some tilesets defined if (f1.tilesets.size() > 0) { FringeRecord f2 = _frecs.get(second); // and we only fringe if second doesn't exist or has a lower // priority if ((null == f2) || (f1.priority > f2.priority)) { return f1.priority; } } } return -1; }
[ "public", "int", "fringesOn", "(", "int", "first", ",", "int", "second", ")", "{", "FringeRecord", "f1", "=", "_frecs", ".", "get", "(", "first", ")", ";", "// we better have a fringe record for the first", "if", "(", "null", "!=", "f1", ")", "{", "// it had...
If the first base tileset fringes upon the second, return the fringe priority of the first base tileset, otherwise return -1.
[ "If", "the", "first", "base", "tileset", "fringes", "upon", "the", "second", "return", "the", "fringe", "priority", "of", "the", "first", "base", "tileset", "otherwise", "return", "-", "1", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/tile/FringeConfiguration.java#L119-L140
train
threerings/nenya
core/src/main/java/com/threerings/miso/tile/FringeConfiguration.java
FringeConfiguration.getFringe
public FringeTileSetRecord getFringe (int baseset, int hashValue) { FringeRecord f = _frecs.get(baseset); return f.tilesets.get( hashValue % f.tilesets.size()); }
java
public FringeTileSetRecord getFringe (int baseset, int hashValue) { FringeRecord f = _frecs.get(baseset); return f.tilesets.get( hashValue % f.tilesets.size()); }
[ "public", "FringeTileSetRecord", "getFringe", "(", "int", "baseset", ",", "int", "hashValue", ")", "{", "FringeRecord", "f", "=", "_frecs", ".", "get", "(", "baseset", ")", ";", "return", "f", ".", "tilesets", ".", "get", "(", "hashValue", "%", "f", ".",...
Get a random FringeTileSetRecord from amongst the ones listed for the specified base tileset.
[ "Get", "a", "random", "FringeTileSetRecord", "from", "amongst", "the", "ones", "listed", "for", "the", "specified", "base", "tileset", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/tile/FringeConfiguration.java#L146-L151
train
threerings/nenya
core/src/main/java/com/threerings/media/ManagedJApplet.java
ManagedJApplet.getWindow
public Window getWindow () { Component parent = getParent(); while (!(parent instanceof Window) && parent != null) { parent = parent.getParent(); } return (Window)parent; }
java
public Window getWindow () { Component parent = getParent(); while (!(parent instanceof Window) && parent != null) { parent = parent.getParent(); } return (Window)parent; }
[ "public", "Window", "getWindow", "(", ")", "{", "Component", "parent", "=", "getParent", "(", ")", ";", "while", "(", "!", "(", "parent", "instanceof", "Window", ")", "&&", "parent", "!=", "null", ")", "{", "parent", "=", "parent", ".", "getParent", "(...
from interface FrameManager.ManagedRoot
[ "from", "interface", "FrameManager", ".", "ManagedRoot" ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/ManagedJApplet.java#L40-L47
train
jboss/jboss-jsp-api_spec
src/main/java/javax/servlet/jsp/tagext/TagData.java
TagData.getAttributeString
public String getAttributeString(String attName) { Object o = attributes.get(attName); if (o == null) { return null; } else { return (String) o; } }
java
public String getAttributeString(String attName) { Object o = attributes.get(attName); if (o == null) { return null; } else { return (String) o; } }
[ "public", "String", "getAttributeString", "(", "String", "attName", ")", "{", "Object", "o", "=", "attributes", ".", "get", "(", "attName", ")", ";", "if", "(", "o", "==", "null", ")", "{", "return", "null", ";", "}", "else", "{", "return", "(", "Str...
Get the value for a given attribute. @param attName the name of the attribute @return the attribute value string @throws ClassCastException if attribute value is not a String
[ "Get", "the", "value", "for", "a", "given", "attribute", "." ]
da53166619f33a5134dc3315a3264990cc1f541f
https://github.com/jboss/jboss-jsp-api_spec/blob/da53166619f33a5134dc3315a3264990cc1f541f/src/main/java/javax/servlet/jsp/tagext/TagData.java#L170-L177
train
jdillon/gshell
gshell-personality/src/main/java/com/planet57/gshell/Main.java
Main.maybeSetProperty
private void maybeSetProperty(final String name, final String value) { if (System.getProperty(name) == null) { System.setProperty(name, value); } }
java
private void maybeSetProperty(final String name, final String value) { if (System.getProperty(name) == null) { System.setProperty(name, value); } }
[ "private", "void", "maybeSetProperty", "(", "final", "String", "name", ",", "final", "String", "value", ")", "{", "if", "(", "System", ".", "getProperty", "(", "name", ")", "==", "null", ")", "{", "System", ".", "setProperty", "(", "name", ",", "value", ...
Helper to only set a property if not already set.
[ "Helper", "to", "only", "set", "a", "property", "if", "not", "already", "set", "." ]
b587c1a4672d2e4905871462fa3b38a1f7b94e90
https://github.com/jdillon/gshell/blob/b587c1a4672d2e4905871462fa3b38a1f7b94e90/gshell-personality/src/main/java/com/planet57/gshell/Main.java#L63-L67
train
threerings/nenya
core/src/main/java/com/threerings/chat/ChatGlyph.java
ChatGlyph.render
public void render (Graphics2D gfx) { Object oalias = SwingUtil.activateAntiAliasing(gfx); gfx.setColor(getBackground()); gfx.fill(_shape); gfx.setColor(_outline); gfx.draw(_shape); SwingUtil.restoreAntiAliasing(gfx, oalias); if (_icon != null) { _icon.paintIcon(_owner.getTarget(), gfx, _ipos.x, _ipos.y); } gfx.setColor(Color.BLACK); _label.render(gfx, _lpos.x, _lpos.y); }
java
public void render (Graphics2D gfx) { Object oalias = SwingUtil.activateAntiAliasing(gfx); gfx.setColor(getBackground()); gfx.fill(_shape); gfx.setColor(_outline); gfx.draw(_shape); SwingUtil.restoreAntiAliasing(gfx, oalias); if (_icon != null) { _icon.paintIcon(_owner.getTarget(), gfx, _ipos.x, _ipos.y); } gfx.setColor(Color.BLACK); _label.render(gfx, _lpos.x, _lpos.y); }
[ "public", "void", "render", "(", "Graphics2D", "gfx", ")", "{", "Object", "oalias", "=", "SwingUtil", ".", "activateAntiAliasing", "(", "gfx", ")", ";", "gfx", ".", "setColor", "(", "getBackground", "(", ")", ")", ";", "gfx", ".", "fill", "(", "_shape", ...
Render the chat glyph with no thought to dirty rectangles or restoring composites.
[ "Render", "the", "chat", "glyph", "with", "no", "thought", "to", "dirty", "rectangles", "or", "restoring", "composites", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/chat/ChatGlyph.java#L101-L117
train
threerings/nenya
core/src/main/java/com/threerings/chat/ChatGlyph.java
ChatGlyph.translate
public void translate (int dx, int dy) { setLocation(_bounds.x + dx, _bounds.y + dy); }
java
public void translate (int dx, int dy) { setLocation(_bounds.x + dx, _bounds.y + dy); }
[ "public", "void", "translate", "(", "int", "dx", ",", "int", "dy", ")", "{", "setLocation", "(", "_bounds", ".", "x", "+", "dx", ",", "_bounds", ".", "y", "+", "dy", ")", ";", "}" ]
Attempt to translate this glyph.
[ "Attempt", "to", "translate", "this", "glyph", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/chat/ChatGlyph.java#L176-L179
train
threerings/nenya
core/src/main/java/com/threerings/miso/MisoConfig.java
MisoConfig.getSceneMetrics
public static MisoSceneMetrics getSceneMetrics () { return new MisoSceneMetrics( config.getValue(TILE_WIDTH_KEY, DEF_TILE_WIDTH), config.getValue(TILE_HEIGHT_KEY, DEF_TILE_HEIGHT), config.getValue(FINE_GRAN_KEY, DEF_FINE_GRAN)); }
java
public static MisoSceneMetrics getSceneMetrics () { return new MisoSceneMetrics( config.getValue(TILE_WIDTH_KEY, DEF_TILE_WIDTH), config.getValue(TILE_HEIGHT_KEY, DEF_TILE_HEIGHT), config.getValue(FINE_GRAN_KEY, DEF_FINE_GRAN)); }
[ "public", "static", "MisoSceneMetrics", "getSceneMetrics", "(", ")", "{", "return", "new", "MisoSceneMetrics", "(", "config", ".", "getValue", "(", "TILE_WIDTH_KEY", ",", "DEF_TILE_WIDTH", ")", ",", "config", ".", "getValue", "(", "TILE_HEIGHT_KEY", ",", "DEF_TILE...
Creates scene metrics with information obtained from the deployed config file.
[ "Creates", "scene", "metrics", "with", "information", "obtained", "from", "the", "deployed", "config", "file", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/MisoConfig.java#L38-L44
train
tonilopezmr/Android-EasySQLite
easysqlite/src/main/java/com/tonilopezmr/easysqlite/SQLiteHelper.java
SQLiteHelper.onCreate
@Override public void onCreate(SQLiteDatabase db) { try { if(builder.tables == null){ throw new SQLiteHelperException("The array of String tables can't be null!!"); } executePragma(db); builder.onCreateCallback.onCreate(db); } catch (SQLiteHelperException e) { Log.e(this.getClass().toString(), Log.getStackTraceString(e), e); } }
java
@Override public void onCreate(SQLiteDatabase db) { try { if(builder.tables == null){ throw new SQLiteHelperException("The array of String tables can't be null!!"); } executePragma(db); builder.onCreateCallback.onCreate(db); } catch (SQLiteHelperException e) { Log.e(this.getClass().toString(), Log.getStackTraceString(e), e); } }
[ "@", "Override", "public", "void", "onCreate", "(", "SQLiteDatabase", "db", ")", "{", "try", "{", "if", "(", "builder", ".", "tables", "==", "null", ")", "{", "throw", "new", "SQLiteHelperException", "(", "\"The array of String tables can't be null!!\"", ")", ";...
Called when the database is created for the first time. This is where the creation of tables and the initial population of the tables should happen. @param db The database.
[ "Called", "when", "the", "database", "is", "created", "for", "the", "first", "time", ".", "This", "is", "where", "the", "creation", "of", "tables", "and", "the", "initial", "population", "of", "the", "tables", "should", "happen", "." ]
bb991a43c9fa11522e5367570ee2335b99bca7c0
https://github.com/tonilopezmr/Android-EasySQLite/blob/bb991a43c9fa11522e5367570ee2335b99bca7c0/easysqlite/src/main/java/com/tonilopezmr/easysqlite/SQLiteHelper.java#L66-L78
train
tonilopezmr/Android-EasySQLite
easysqlite/src/main/java/com/tonilopezmr/easysqlite/SQLiteHelper.java
SQLiteHelper.onUpgrade
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { try { if (builder.tableNames == null) { throw new SQLiteHelperException("The array of String tableNames can't be null!!"); } builder.onUpgradeCallback.onUpgrade(db, oldVersion, newVersion); } catch (SQLiteHelperException e) { Log.e(this.getClass().toString(), Log.getStackTraceString(e), e); } }
java
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { try { if (builder.tableNames == null) { throw new SQLiteHelperException("The array of String tableNames can't be null!!"); } builder.onUpgradeCallback.onUpgrade(db, oldVersion, newVersion); } catch (SQLiteHelperException e) { Log.e(this.getClass().toString(), Log.getStackTraceString(e), e); } }
[ "@", "Override", "public", "void", "onUpgrade", "(", "SQLiteDatabase", "db", ",", "int", "oldVersion", ",", "int", "newVersion", ")", "{", "try", "{", "if", "(", "builder", ".", "tableNames", "==", "null", ")", "{", "throw", "new", "SQLiteHelperException", ...
Called when the database needs to be upgraded. The implementation should use this method to drop tables, add tables, or do anything else it needs to upgrade to the new schema version. @param db The database. @param oldVersion The old database version. @param newVersion The new database version.
[ "Called", "when", "the", "database", "needs", "to", "be", "upgraded", ".", "The", "implementation", "should", "use", "this", "method", "to", "drop", "tables", "add", "tables", "or", "do", "anything", "else", "it", "needs", "to", "upgrade", "to", "the", "ne...
bb991a43c9fa11522e5367570ee2335b99bca7c0
https://github.com/tonilopezmr/Android-EasySQLite/blob/bb991a43c9fa11522e5367570ee2335b99bca7c0/easysqlite/src/main/java/com/tonilopezmr/easysqlite/SQLiteHelper.java#L101-L112
train
Systemdir/GML-Writer-for-yED
GMLWriter/src/com/github/systemdir/gml/model/Tools.java
Tools.getHex
static String getHex(Color color) { return String.format("#%02x%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); }
java
static String getHex(Color color) { return String.format("#%02x%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); }
[ "static", "String", "getHex", "(", "Color", "color", ")", "{", "return", "String", ".", "format", "(", "\"#%02x%02x%02x%02x\"", ",", "color", ".", "getRed", "(", ")", ",", "color", ".", "getGreen", "(", ")", ",", "color", ".", "getBlue", "(", ")", ",",...
create rgba hex from a java color
[ "create", "rgba", "hex", "from", "a", "java", "color" ]
353ecf132929889cb15968865283ee511f7c8d87
https://github.com/Systemdir/GML-Writer-for-yED/blob/353ecf132929889cb15968865283ee511f7c8d87/GMLWriter/src/com/github/systemdir/gml/model/Tools.java#L65-L67
train
kaazing/java.client
amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java
AmqpClient.getConnectionListeners
public List<ConnectionListener> getConnectionListeners() { if (changes == null) { return (List<ConnectionListener>)Collections.EMPTY_LIST; } List<EventListener> listeners = changes.getListenerList(AMQP); if ((listeners == null) || listeners.isEmpty()) { return (List<ConnectionListener>)Collections.EMPTY_LIST; } ArrayList<ConnectionListener> list = new ArrayList<ConnectionListener>(); for (EventListener listener : listeners) { list.add((ConnectionListener)listener); } return list; }
java
public List<ConnectionListener> getConnectionListeners() { if (changes == null) { return (List<ConnectionListener>)Collections.EMPTY_LIST; } List<EventListener> listeners = changes.getListenerList(AMQP); if ((listeners == null) || listeners.isEmpty()) { return (List<ConnectionListener>)Collections.EMPTY_LIST; } ArrayList<ConnectionListener> list = new ArrayList<ConnectionListener>(); for (EventListener listener : listeners) { list.add((ConnectionListener)listener); } return list; }
[ "public", "List", "<", "ConnectionListener", ">", "getConnectionListeners", "(", ")", "{", "if", "(", "changes", "==", "null", ")", "{", "return", "(", "List", "<", "ConnectionListener", ">", ")", "Collections", ".", "EMPTY_LIST", ";", "}", "List", "<", "E...
Returns the list of ConnectionListeners registered with this AmqpClient instance. @return List<ConnectionListener> list of ConnectionListeners
[ "Returns", "the", "list", "of", "ConnectionListeners", "registered", "with", "this", "AmqpClient", "instance", "." ]
25ad2ae5bb24aa9d6b79400fce649b518dcfbe26
https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java#L343-L359
train
kaazing/java.client
amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java
AmqpClient.connect
public void connect(String url, String virtualHost, String username, String password) { if (websocket != null) { throw new IllegalStateException("AmqpClient already connected"); } this.readyState = ReadyState.CONNECTING; this.url = url; this.userName = username; this.password = password; this.virtualHost = virtualHost; this.hasNegotiated = false; asyncClient.getStateMachine().enterState("handshaking", "", this.url); }
java
public void connect(String url, String virtualHost, String username, String password) { if (websocket != null) { throw new IllegalStateException("AmqpClient already connected"); } this.readyState = ReadyState.CONNECTING; this.url = url; this.userName = username; this.password = password; this.virtualHost = virtualHost; this.hasNegotiated = false; asyncClient.getStateMachine().enterState("handshaking", "", this.url); }
[ "public", "void", "connect", "(", "String", "url", ",", "String", "virtualHost", ",", "String", "username", ",", "String", "password", ")", "{", "if", "(", "websocket", "!=", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"AmqpClient already...
Connect to AMQP Broker via Kaazing Gateway @param url Location of AMQP Broker or Server @param virtualHost Name of the virtual host @param username Username to connect to the AMQP Server @param password Password to connect to the AMQP Server
[ "Connect", "to", "AMQP", "Broker", "via", "Kaazing", "Gateway" ]
25ad2ae5bb24aa9d6b79400fce649b518dcfbe26
https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java#L377-L389
train
kaazing/java.client
amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java
AmqpClient.disconnect
public void disconnect() { if (readyState == ReadyState.OPEN) { // readyState should be set to ReadyState.CLOSED ONLY AFTER the // the WebSocket has been successfully closed in // socketClosedHandler(). this.closeConnection(0, "", 0, 0, null, null); } else if (readyState == ReadyState.CONNECTING) { socketClosedHandler(); } }
java
public void disconnect() { if (readyState == ReadyState.OPEN) { // readyState should be set to ReadyState.CLOSED ONLY AFTER the // the WebSocket has been successfully closed in // socketClosedHandler(). this.closeConnection(0, "", 0, 0, null, null); } else if (readyState == ReadyState.CONNECTING) { socketClosedHandler(); } }
[ "public", "void", "disconnect", "(", ")", "{", "if", "(", "readyState", "==", "ReadyState", ".", "OPEN", ")", "{", "// readyState should be set to ReadyState.CLOSED ONLY AFTER the", "// the WebSocket has been successfully closed in", "// socketClosedHandler().", "this", ".", ...
Disconnects from Amqp Server.
[ "Disconnects", "from", "Amqp", "Server", "." ]
25ad2ae5bb24aa9d6b79400fce649b518dcfbe26
https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java#L394-L403
train
kaazing/java.client
amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java
AmqpClient.openChannel
public AmqpChannel openChannel() { int id = ++this.channelCount; AmqpChannel chan = new AmqpChannel(id, this); channels.put(id, chan); return chan; }
java
public AmqpChannel openChannel() { int id = ++this.channelCount; AmqpChannel chan = new AmqpChannel(id, this); channels.put(id, chan); return chan; }
[ "public", "AmqpChannel", "openChannel", "(", ")", "{", "int", "id", "=", "++", "this", ".", "channelCount", ";", "AmqpChannel", "chan", "=", "new", "AmqpChannel", "(", "id", ",", "this", ")", ";", "channels", ".", "put", "(", "id", ",", "chan", ")", ...
Opens a channel on server. @return AmqpChannel
[ "Opens", "a", "channel", "on", "server", "." ]
25ad2ae5bb24aa9d6b79400fce649b518dcfbe26
https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java#L410-L415
train
kaazing/java.client
amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java
AmqpClient.closedHandler
void closedHandler(Object context, String input, Object frame, String stateName) { if (getReadyState() == ReadyState.CLOSED) { return; } // TODO: Determine whether channels need to be cleaned up. if (this.channels.size() != 0) { for (int i = 1; i <= this.channels.size(); i++) { // 1-based AmqpChannel channel = this.channels.get(i); AmqpFrame f = new AmqpFrame(); // Close each channel which should result in CLOSE event // to be fired for each of the registered ChannelListener(s). f.setMethodName("closeChannel"); f.setChannelId((short) i); channel.channelClosedHandler(this, "", f, "closeChannel"); } } try { // Mark the readyState to be CLOSED. readyState = ReadyState.CLOSED; // Fire CLOSE event for the ConnectionListener(s) registered // on AmqpClient object. fireOnClosed(new ConnectionEvent(this, Kind.CLOSE)); // If the WebSocket(or ByteSocket) is still not closed, then // invoke the close() method. The callback in this case will be a // a no-op as we have completed the book-keeping here. if (websocket != null) { websocket.close(); } } catch (Exception e1) { throw new IllegalStateException(e1); } finally { websocket = null; } }
java
void closedHandler(Object context, String input, Object frame, String stateName) { if (getReadyState() == ReadyState.CLOSED) { return; } // TODO: Determine whether channels need to be cleaned up. if (this.channels.size() != 0) { for (int i = 1; i <= this.channels.size(); i++) { // 1-based AmqpChannel channel = this.channels.get(i); AmqpFrame f = new AmqpFrame(); // Close each channel which should result in CLOSE event // to be fired for each of the registered ChannelListener(s). f.setMethodName("closeChannel"); f.setChannelId((short) i); channel.channelClosedHandler(this, "", f, "closeChannel"); } } try { // Mark the readyState to be CLOSED. readyState = ReadyState.CLOSED; // Fire CLOSE event for the ConnectionListener(s) registered // on AmqpClient object. fireOnClosed(new ConnectionEvent(this, Kind.CLOSE)); // If the WebSocket(or ByteSocket) is still not closed, then // invoke the close() method. The callback in this case will be a // a no-op as we have completed the book-keeping here. if (websocket != null) { websocket.close(); } } catch (Exception e1) { throw new IllegalStateException(e1); } finally { websocket = null; } }
[ "void", "closedHandler", "(", "Object", "context", ",", "String", "input", ",", "Object", "frame", ",", "String", "stateName", ")", "{", "if", "(", "getReadyState", "(", ")", "==", "ReadyState", ".", "CLOSED", ")", "{", "return", ";", "}", "// TODO: Determ...
should be the order following in all our client implementations.
[ "should", "be", "the", "order", "following", "in", "all", "our", "client", "implementations", "." ]
25ad2ae5bb24aa9d6b79400fce649b518dcfbe26
https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java#L593-L634
train
kaazing/java.client
amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java
AmqpClient.socketClosedHandler
private void socketClosedHandler() { // If the book-keeping has already been completed earlier, then // we should just bail. if (getReadyState() == ReadyState.CLOSED) { return; } // TODO: Determine whether channels need to be cleaned up if (this.channels.size() != 0) { // Iterate over the channels and close them. for (int i = 1; i <= this.channels.size(); i++) { // 1-based AmqpChannel channel = this.channels.get(i); AmqpFrame f = new AmqpFrame(); // Close the channel and ensure that the CLOSE event is // fired on the registered ChannelListener objects. f.setMethodName("closeChannel"); f.setChannelId((short) i); channel.channelClosedHandler(this, "", f, "closeChannel"); } } // Mark the readyState as CLOSED. readyState = ReadyState.CLOSED; // Fire the CLOSE event on the ConnectionListener(s) registered on // the AmqpClient object. fireOnClosed(new ConnectionEvent(this, Kind.CLOSE)); }
java
private void socketClosedHandler() { // If the book-keeping has already been completed earlier, then // we should just bail. if (getReadyState() == ReadyState.CLOSED) { return; } // TODO: Determine whether channels need to be cleaned up if (this.channels.size() != 0) { // Iterate over the channels and close them. for (int i = 1; i <= this.channels.size(); i++) { // 1-based AmqpChannel channel = this.channels.get(i); AmqpFrame f = new AmqpFrame(); // Close the channel and ensure that the CLOSE event is // fired on the registered ChannelListener objects. f.setMethodName("closeChannel"); f.setChannelId((short) i); channel.channelClosedHandler(this, "", f, "closeChannel"); } } // Mark the readyState as CLOSED. readyState = ReadyState.CLOSED; // Fire the CLOSE event on the ConnectionListener(s) registered on // the AmqpClient object. fireOnClosed(new ConnectionEvent(this, Kind.CLOSE)); }
[ "private", "void", "socketClosedHandler", "(", ")", "{", "// If the book-keeping has already been completed earlier, then", "// we should just bail.", "if", "(", "getReadyState", "(", ")", "==", "ReadyState", ".", "CLOSED", ")", "{", "return", ";", "}", "// TODO: Determin...
closing the channels, raising events, and such.
[ "closing", "the", "channels", "raising", "events", "and", "such", "." ]
25ad2ae5bb24aa9d6b79400fce649b518dcfbe26
https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java#L653-L681
train
kaazing/java.client
amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java
AmqpClient.tuneOkConnection
AmqpClient tuneOkConnection(int channelMax, int frameMax, int heartbeat) { this.tuneOkConnection(channelMax, frameMax, heartbeat, null, null); return this; }
java
AmqpClient tuneOkConnection(int channelMax, int frameMax, int heartbeat) { this.tuneOkConnection(channelMax, frameMax, heartbeat, null, null); return this; }
[ "AmqpClient", "tuneOkConnection", "(", "int", "channelMax", ",", "int", "frameMax", ",", "int", "heartbeat", ")", "{", "this", ".", "tuneOkConnection", "(", "channelMax", ",", "frameMax", ",", "heartbeat", ",", "null", ",", "null", ")", ";", "return", "this"...
Sends a TuneOkConnection to server. @param channelMax @param frameMax @param heartbeat @return AmqpClient
[ "Sends", "a", "TuneOkConnection", "to", "server", "." ]
25ad2ae5bb24aa9d6b79400fce649b518dcfbe26
https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java#L814-L817
train
kaazing/java.client
amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java
AmqpClient.closeOkConnection
AmqpClient closeOkConnection(Continuation callback, ErrorHandler error) { Object[] args = {}; AmqpBuffer bodyArg = null; String methodName = "closeOkConnection"; String methodId = "10" + "50"; AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId); Object[] arguments = {this, amqpMethod, this.id, args, bodyArg}; asyncClient.enqueueAction(methodName, "write", arguments, callback, error); return this; }
java
AmqpClient closeOkConnection(Continuation callback, ErrorHandler error) { Object[] args = {}; AmqpBuffer bodyArg = null; String methodName = "closeOkConnection"; String methodId = "10" + "50"; AmqpMethod amqpMethod = MethodLookup.LookupMethod(methodId); Object[] arguments = {this, amqpMethod, this.id, args, bodyArg}; asyncClient.enqueueAction(methodName, "write", arguments, callback, error); return this; }
[ "AmqpClient", "closeOkConnection", "(", "Continuation", "callback", ",", "ErrorHandler", "error", ")", "{", "Object", "[", "]", "args", "=", "{", "}", ";", "AmqpBuffer", "bodyArg", "=", "null", ";", "String", "methodName", "=", "\"closeOkConnection\"", ";", "S...
Sends a CloseOkConnection to server. @param callback @param error @return AmqpClient
[ "Sends", "a", "CloseOkConnection", "to", "server", "." ]
25ad2ae5bb24aa9d6b79400fce649b518dcfbe26
https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java#L927-L937
train
kaazing/java.client
amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java
AmqpClient.fireOnClosed
private void fireOnClosed(ConnectionEvent e) { List<EventListener> listeners = changes.getListenerList(AMQP); for (EventListener listener : listeners) { ConnectionListener amqpListener = (ConnectionListener)listener; amqpListener.onConnectionClose(e); } }
java
private void fireOnClosed(ConnectionEvent e) { List<EventListener> listeners = changes.getListenerList(AMQP); for (EventListener listener : listeners) { ConnectionListener amqpListener = (ConnectionListener)listener; amqpListener.onConnectionClose(e); } }
[ "private", "void", "fireOnClosed", "(", "ConnectionEvent", "e", ")", "{", "List", "<", "EventListener", ">", "listeners", "=", "changes", ".", "getListenerList", "(", "AMQP", ")", ";", "for", "(", "EventListener", "listener", ":", "listeners", ")", "{", "Con...
Occurs when the connection to the AMQP server is closed @param e
[ "Occurs", "when", "the", "connection", "to", "the", "AMQP", "server", "is", "closed" ]
25ad2ae5bb24aa9d6b79400fce649b518dcfbe26
https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/amqp-0-9-1/amqp/src/main/java/org/kaazing/net/ws/amqp/AmqpClient.java#L965-L971
train
threerings/nenya
core/src/main/java/com/threerings/cast/CompositedMultiFrameImage.java
CompositedMultiFrameImage.createCompositedMirage
protected CompositedMirage createCompositedMirage (int index) { if (_sources.length == 1 && _sources[0].frames instanceof TileSetFrameImage) { TileSetFrameImage frames = (TileSetFrameImage)_sources[0].frames; Rectangle tbounds = new Rectangle(); frames.getTrimmedBounds(_orient, index, tbounds); int x = frames.getXOrigin(_orient, index) - tbounds.x; int y = frames.getYOrigin(_orient, index) - tbounds.y; return new SubmirageForwarder(frames.getTileMirage(_orient, index), x, y); } return new CompositedVolatileMirage(index); }
java
protected CompositedMirage createCompositedMirage (int index) { if (_sources.length == 1 && _sources[0].frames instanceof TileSetFrameImage) { TileSetFrameImage frames = (TileSetFrameImage)_sources[0].frames; Rectangle tbounds = new Rectangle(); frames.getTrimmedBounds(_orient, index, tbounds); int x = frames.getXOrigin(_orient, index) - tbounds.x; int y = frames.getYOrigin(_orient, index) - tbounds.y; return new SubmirageForwarder(frames.getTileMirage(_orient, index), x, y); } return new CompositedVolatileMirage(index); }
[ "protected", "CompositedMirage", "createCompositedMirage", "(", "int", "index", ")", "{", "if", "(", "_sources", ".", "length", "==", "1", "&&", "_sources", "[", "0", "]", ".", "frames", "instanceof", "TileSetFrameImage", ")", "{", "TileSetFrameImage", "frames",...
Creates a composited image for the specified frame.
[ "Creates", "a", "composited", "image", "for", "the", "specified", "frame", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/CompositedMultiFrameImage.java#L117-L128
train
threerings/nenya
core/src/main/java/com/threerings/cast/bundle/BundledComponentRepository.java
BundledComponentRepository.createComponent
protected void createComponent ( int componentId, String cclass, String cname, FrameProvider fprov) { // look up the component class information ComponentClass clazz = _classes.get(cclass); if (clazz == null) { log.warning("Non-existent component class", "class", cclass, "name", cname, "id", componentId); return; } // create the component CharacterComponent component = new CharacterComponent(componentId, cname, clazz, fprov); // stick it into the appropriate tables _components.put(componentId, component); // we have a hash of lists for mapping components by class/name ArrayList<CharacterComponent> comps = _classComps.get(cclass); if (comps == null) { comps = Lists.newArrayList(); _classComps.put(cclass, comps); } if (!comps.contains(component)) { comps.add(component); } else { log.info("Requested to register the same component twice?", "comp", component); } }
java
protected void createComponent ( int componentId, String cclass, String cname, FrameProvider fprov) { // look up the component class information ComponentClass clazz = _classes.get(cclass); if (clazz == null) { log.warning("Non-existent component class", "class", cclass, "name", cname, "id", componentId); return; } // create the component CharacterComponent component = new CharacterComponent(componentId, cname, clazz, fprov); // stick it into the appropriate tables _components.put(componentId, component); // we have a hash of lists for mapping components by class/name ArrayList<CharacterComponent> comps = _classComps.get(cclass); if (comps == null) { comps = Lists.newArrayList(); _classComps.put(cclass, comps); } if (!comps.contains(component)) { comps.add(component); } else { log.info("Requested to register the same component twice?", "comp", component); } }
[ "protected", "void", "createComponent", "(", "int", "componentId", ",", "String", "cclass", ",", "String", "cname", ",", "FrameProvider", "fprov", ")", "{", "// look up the component class information", "ComponentClass", "clazz", "=", "_classes", ".", "get", "(", "c...
Creates a component and inserts it into the component table.
[ "Creates", "a", "component", "and", "inserts", "it", "into", "the", "component", "table", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/bundle/BundledComponentRepository.java#L246-L274
train
threerings/nenya
core/src/main/java/com/threerings/media/sprite/ImageSprite.java
ImageSprite.setFrames
public void setFrames (MultiFrameImage frames) { if (frames == null) { // log.warning("Someone set up us the null frames!", "sprite", this); return; } // if these are the same frames we already had, no need to do a bunch of pointless business if (frames == _frames) { return; } // set and init our frames _frames = frames; _frameIdx = 0; layout(); }
java
public void setFrames (MultiFrameImage frames) { if (frames == null) { // log.warning("Someone set up us the null frames!", "sprite", this); return; } // if these are the same frames we already had, no need to do a bunch of pointless business if (frames == _frames) { return; } // set and init our frames _frames = frames; _frameIdx = 0; layout(); }
[ "public", "void", "setFrames", "(", "MultiFrameImage", "frames", ")", "{", "if", "(", "frames", "==", "null", ")", "{", "// log.warning(\"Someone set up us the null frames!\", \"sprite\", this);", "return", ";", "}", "// if these are the same frames we already had, no need to d...
Set the image array used to render the sprite. @param frames the sprite images.
[ "Set", "the", "image", "array", "used", "to", "render", "the", "sprite", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sprite/ImageSprite.java#L157-L173
train
threerings/nenya
core/src/main/java/com/threerings/media/sprite/ImageSprite.java
ImageSprite.setFrameIndex
protected void setFrameIndex (int frameIdx, boolean forceUpdate) { // make sure we're displaying a valid frame frameIdx = (frameIdx % _frames.getFrameCount()); // if this is the same frame we're already displaying and we're // not being forced to update, we can stop now if (frameIdx == _frameIdx && !forceUpdate) { return; } else { _frameIdx = frameIdx; } // start with our old bounds Rectangle dirty = new Rectangle(_bounds); // determine our drawing offsets and rendered rectangle size accomodateFrame(_frameIdx, _frames.getWidth(_frameIdx), _frames.getHeight(_frameIdx)); // add our new bounds dirty.add(_bounds); // give the dirty rectangle to the region manager if (_mgr != null) { _mgr.getRegionManager().addDirtyRegion(dirty); } }
java
protected void setFrameIndex (int frameIdx, boolean forceUpdate) { // make sure we're displaying a valid frame frameIdx = (frameIdx % _frames.getFrameCount()); // if this is the same frame we're already displaying and we're // not being forced to update, we can stop now if (frameIdx == _frameIdx && !forceUpdate) { return; } else { _frameIdx = frameIdx; } // start with our old bounds Rectangle dirty = new Rectangle(_bounds); // determine our drawing offsets and rendered rectangle size accomodateFrame(_frameIdx, _frames.getWidth(_frameIdx), _frames.getHeight(_frameIdx)); // add our new bounds dirty.add(_bounds); // give the dirty rectangle to the region manager if (_mgr != null) { _mgr.getRegionManager().addDirtyRegion(dirty); } }
[ "protected", "void", "setFrameIndex", "(", "int", "frameIdx", ",", "boolean", "forceUpdate", ")", "{", "// make sure we're displaying a valid frame", "frameIdx", "=", "(", "frameIdx", "%", "_frames", ".", "getFrameCount", "(", ")", ")", ";", "// if this is the same fr...
Instructs the sprite to display the specified frame index.
[ "Instructs", "the", "sprite", "to", "display", "the", "specified", "frame", "index", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sprite/ImageSprite.java#L188-L215
train
groupon/monsoon
collectors/collectd/src/main/java/com/groupon/lex/metrics/collector/collectd/CollectdPushCollector.java
CollectdPushCollector.up_down_host_
private MetricGroup up_down_host_(String host, boolean up) { final GroupName group = GroupName.valueOf( getBasePath(), Tags.valueOf(singletonMap("host", MetricValue.fromStrValue(host)))); return new SimpleMetricGroup(group, singleton(up ? UP_METRIC : DOWN_METRIC)); }
java
private MetricGroup up_down_host_(String host, boolean up) { final GroupName group = GroupName.valueOf( getBasePath(), Tags.valueOf(singletonMap("host", MetricValue.fromStrValue(host)))); return new SimpleMetricGroup(group, singleton(up ? UP_METRIC : DOWN_METRIC)); }
[ "private", "MetricGroup", "up_down_host_", "(", "String", "host", ",", "boolean", "up", ")", "{", "final", "GroupName", "group", "=", "GroupName", ".", "valueOf", "(", "getBasePath", "(", ")", ",", "Tags", ".", "valueOf", "(", "singletonMap", "(", "\"host\""...
Return a metric group indicating if the host is up or down.
[ "Return", "a", "metric", "group", "indicating", "if", "the", "host", "is", "up", "or", "down", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/collectors/collectd/src/main/java/com/groupon/lex/metrics/collector/collectd/CollectdPushCollector.java#L289-L294
train
jboss/jboss-jsp-api_spec
src/main/java/javax/servlet/jsp/JspFactory.java
JspFactory.getDefaultFactory
public static synchronized JspFactory getDefaultFactory() { if (deflt == null) { try { Class factory = Class.forName("org.apache.jasper.runtime.JspFactoryImpl"); if (factory != null) { deflt = (JspFactory) factory.newInstance(); } } catch (Exception ex) { } } return deflt; }
java
public static synchronized JspFactory getDefaultFactory() { if (deflt == null) { try { Class factory = Class.forName("org.apache.jasper.runtime.JspFactoryImpl"); if (factory != null) { deflt = (JspFactory) factory.newInstance(); } } catch (Exception ex) { } } return deflt; }
[ "public", "static", "synchronized", "JspFactory", "getDefaultFactory", "(", ")", "{", "if", "(", "deflt", "==", "null", ")", "{", "try", "{", "Class", "factory", "=", "Class", ".", "forName", "(", "\"org.apache.jasper.runtime.JspFactoryImpl\"", ")", ";", "if", ...
Returns the default factory for this implementation. @return the default factory for this implementation
[ "Returns", "the", "default", "factory", "for", "this", "implementation", "." ]
da53166619f33a5134dc3315a3264990cc1f541f
https://github.com/jboss/jboss-jsp-api_spec/blob/da53166619f33a5134dc3315a3264990cc1f541f/src/main/java/javax/servlet/jsp/JspFactory.java#L115-L126
train
jboss/jboss-jsp-api_spec
src/main/java/javax/servlet/jsp/tagext/TagInfo.java
TagInfo.getVariableInfo
public VariableInfo[] getVariableInfo(TagData data) { VariableInfo[] result = null; TagExtraInfo tei = getTagExtraInfo(); if (tei != null) { result = tei.getVariableInfo( data ); } return result; }
java
public VariableInfo[] getVariableInfo(TagData data) { VariableInfo[] result = null; TagExtraInfo tei = getTagExtraInfo(); if (tei != null) { result = tei.getVariableInfo( data ); } return result; }
[ "public", "VariableInfo", "[", "]", "getVariableInfo", "(", "TagData", "data", ")", "{", "VariableInfo", "[", "]", "result", "=", "null", ";", "TagExtraInfo", "tei", "=", "getTagExtraInfo", "(", ")", ";", "if", "(", "tei", "!=", "null", ")", "{", "result...
Information on the scripting objects created by this tag at runtime. This is a convenience method on the associated TagExtraInfo class. @param data TagData describing this action. @return if a TagExtraInfo object is associated with this TagInfo, the result of getTagExtraInfo().getVariableInfo( data ), otherwise null.
[ "Information", "on", "the", "scripting", "objects", "created", "by", "this", "tag", "at", "runtime", ".", "This", "is", "a", "convenience", "method", "on", "the", "associated", "TagExtraInfo", "class", "." ]
da53166619f33a5134dc3315a3264990cc1f541f
https://github.com/jboss/jboss-jsp-api_spec/blob/da53166619f33a5134dc3315a3264990cc1f541f/src/main/java/javax/servlet/jsp/tagext/TagInfo.java#L273-L280
train
jdillon/gshell
gshell-launcher/src/main/java/com/planet57/gshell/launcher/Configuration.java
Configuration.getProperty
@Nullable private String getProperty(final String name) { assert name != null; ensureConfigured(); return evaluate(System.getProperty(name, props.getProperty(name))); }
java
@Nullable private String getProperty(final String name) { assert name != null; ensureConfigured(); return evaluate(System.getProperty(name, props.getProperty(name))); }
[ "@", "Nullable", "private", "String", "getProperty", "(", "final", "String", "name", ")", "{", "assert", "name", "!=", "null", ";", "ensureConfigured", "(", ")", ";", "return", "evaluate", "(", "System", ".", "getProperty", "(", "name", ",", "props", ".", ...
Get the value of a property, checking system properties, then configuration properties and evaluating the result.
[ "Get", "the", "value", "of", "a", "property", "checking", "system", "properties", "then", "configuration", "properties", "and", "evaluating", "the", "result", "." ]
b587c1a4672d2e4905871462fa3b38a1f7b94e90
https://github.com/jdillon/gshell/blob/b587c1a4672d2e4905871462fa3b38a1f7b94e90/gshell-launcher/src/main/java/com/planet57/gshell/launcher/Configuration.java#L141-L146
train
calrissian/mango
mango-json/src/main/java/org/calrissian/mango/json/mappings/JsonAttributeMappings.java
JsonAttributeMappings.fromJson
public static Collection<Attribute> fromJson(ObjectNode object) throws IOException { Collection<Attribute> attributes = new HashSet<>(); convertJsonObject(attributes, object, "", 0, new HashMap<>()); return attributes; }
java
public static Collection<Attribute> fromJson(ObjectNode object) throws IOException { Collection<Attribute> attributes = new HashSet<>(); convertJsonObject(attributes, object, "", 0, new HashMap<>()); return attributes; }
[ "public", "static", "Collection", "<", "Attribute", ">", "fromJson", "(", "ObjectNode", "object", ")", "throws", "IOException", "{", "Collection", "<", "Attribute", ">", "attributes", "=", "new", "HashSet", "<>", "(", ")", ";", "convertJsonObject", "(", "attri...
Flattens a raw nested json string representation into a collection of attributes. @throws IOException
[ "Flattens", "a", "raw", "nested", "json", "string", "representation", "into", "a", "collection", "of", "attributes", "." ]
a95aa5e77af9aa0e629787228d80806560023452
https://github.com/calrissian/mango/blob/a95aa5e77af9aa0e629787228d80806560023452/mango-json/src/main/java/org/calrissian/mango/json/mappings/JsonAttributeMappings.java#L61-L66
train
calrissian/mango
mango-json/src/main/java/org/calrissian/mango/json/mappings/JsonAttributeMappings.java
JsonAttributeMappings.toJsonString
public static String toJsonString(Collection<Attribute> attributeCollection, ObjectMapper objectMapper) throws JsonProcessingException { return objectMapper.writeValueAsString(toObject(attributeCollection)); }
java
public static String toJsonString(Collection<Attribute> attributeCollection, ObjectMapper objectMapper) throws JsonProcessingException { return objectMapper.writeValueAsString(toObject(attributeCollection)); }
[ "public", "static", "String", "toJsonString", "(", "Collection", "<", "Attribute", ">", "attributeCollection", ",", "ObjectMapper", "objectMapper", ")", "throws", "JsonProcessingException", "{", "return", "objectMapper", ".", "writeValueAsString", "(", "toObject", "(", ...
Re-expands a flattened json representation from a collection of attributes back into a raw nested json string.
[ "Re", "-", "expands", "a", "flattened", "json", "representation", "from", "a", "collection", "of", "attributes", "back", "into", "a", "raw", "nested", "json", "string", "." ]
a95aa5e77af9aa0e629787228d80806560023452
https://github.com/calrissian/mango/blob/a95aa5e77af9aa0e629787228d80806560023452/mango-json/src/main/java/org/calrissian/mango/json/mappings/JsonAttributeMappings.java#L100-L102
train
threerings/nenya
core/src/main/java/com/threerings/miso/tile/AutoFringer.java
AutoFringer.getFringeTile
public BaseTile getFringeTile (MisoSceneModel scene, int col, int row, Map<FringeTile, WeakReference<FringeTile>> fringes, Map<Long, BufferedImage> masks) { // get the tileset id of the base tile we are considering int underset = adjustTileSetId(scene.getBaseTileId(col, row) >> 16); // start with a clean temporary fringer map _fringers.clear(); boolean passable = true; // walk through our influence tiles for (int y = row - 1, maxy = row + 2; y < maxy; y++) { for (int x = col - 1, maxx = col + 2; x < maxx; x++) { // we sensibly do not consider ourselves if ((x == col) && (y == row)) { continue; } // determine the tileset for this tile int btid = scene.getBaseTileId(x, y); int baseset = adjustTileSetId((btid <= 0) ? scene.getDefaultBaseTileSet() : (btid >> 16)); // determine if it fringes on our tile int pri = _fringeconf.fringesOn(baseset, underset); if (pri == -1) { continue; } FringerRec fringer = (FringerRec)_fringers.get(baseset); if (fringer == null) { fringer = new FringerRec(baseset, pri); _fringers.put(baseset, fringer); } // now turn on the appropriate fringebits fringer.bits |= FLAGMATRIX[y - row + 1][x - col + 1]; // See if a tile that fringes on us kills our passability, // but don't count the default base tile against us, as // we allow users to splash in the water. if (passable && (btid > 0)) { try { BaseTile bt = (BaseTile)_tmgr.getTile(btid); passable = bt.isPassable(); } catch (NoSuchTileSetException nstse) { log.warning("Autofringer couldn't find a base set while attempting to " + "figure passability", nstse); } } } } // if nothing fringed, we're done int numfringers = _fringers.size(); if (numfringers == 0) { return null; } // otherwise compose a FringeTile from the specified fringes FringerRec[] frecs = new FringerRec[numfringers]; for (int ii = 0, pp = 0; ii < 16; ii++) { FringerRec rec = (FringerRec)_fringers.getValue(ii); if (rec != null) { frecs[pp++] = rec; } } return composeFringeTile(frecs, fringes, TileUtil.getTileHash(col, row), passable, masks); }
java
public BaseTile getFringeTile (MisoSceneModel scene, int col, int row, Map<FringeTile, WeakReference<FringeTile>> fringes, Map<Long, BufferedImage> masks) { // get the tileset id of the base tile we are considering int underset = adjustTileSetId(scene.getBaseTileId(col, row) >> 16); // start with a clean temporary fringer map _fringers.clear(); boolean passable = true; // walk through our influence tiles for (int y = row - 1, maxy = row + 2; y < maxy; y++) { for (int x = col - 1, maxx = col + 2; x < maxx; x++) { // we sensibly do not consider ourselves if ((x == col) && (y == row)) { continue; } // determine the tileset for this tile int btid = scene.getBaseTileId(x, y); int baseset = adjustTileSetId((btid <= 0) ? scene.getDefaultBaseTileSet() : (btid >> 16)); // determine if it fringes on our tile int pri = _fringeconf.fringesOn(baseset, underset); if (pri == -1) { continue; } FringerRec fringer = (FringerRec)_fringers.get(baseset); if (fringer == null) { fringer = new FringerRec(baseset, pri); _fringers.put(baseset, fringer); } // now turn on the appropriate fringebits fringer.bits |= FLAGMATRIX[y - row + 1][x - col + 1]; // See if a tile that fringes on us kills our passability, // but don't count the default base tile against us, as // we allow users to splash in the water. if (passable && (btid > 0)) { try { BaseTile bt = (BaseTile)_tmgr.getTile(btid); passable = bt.isPassable(); } catch (NoSuchTileSetException nstse) { log.warning("Autofringer couldn't find a base set while attempting to " + "figure passability", nstse); } } } } // if nothing fringed, we're done int numfringers = _fringers.size(); if (numfringers == 0) { return null; } // otherwise compose a FringeTile from the specified fringes FringerRec[] frecs = new FringerRec[numfringers]; for (int ii = 0, pp = 0; ii < 16; ii++) { FringerRec rec = (FringerRec)_fringers.getValue(ii); if (rec != null) { frecs[pp++] = rec; } } return composeFringeTile(frecs, fringes, TileUtil.getTileHash(col, row), passable, masks); }
[ "public", "BaseTile", "getFringeTile", "(", "MisoSceneModel", "scene", ",", "int", "col", ",", "int", "row", ",", "Map", "<", "FringeTile", ",", "WeakReference", "<", "FringeTile", ">", ">", "fringes", ",", "Map", "<", "Long", ",", "BufferedImage", ">", "m...
Compute and return the fringe tile to be inserted at the specified location.
[ "Compute", "and", "return", "the", "fringe", "tile", "to", "be", "inserted", "at", "the", "specified", "location", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/tile/AutoFringer.java#L103-L172
train
threerings/nenya
core/src/main/java/com/threerings/miso/tile/AutoFringer.java
AutoFringer.composeFringeTile
protected FringeTile composeFringeTile (FringerRec[] fringers, Map<FringeTile, WeakReference<FringeTile>> fringes, int hashValue, boolean passable, Map<Long, BufferedImage> masks) { // sort the array so that higher priority fringers get drawn first QuickSort.sort(fringers); // Generate an identifier for the fringe tile being created as an array of the keys of its // component tiles in the order they'll be drawn in the fringe tile. List<Long> keys = Lists.newArrayList(); for (FringerRec fringer : fringers) { int[] indexes = getFringeIndexes(fringer.bits); FringeConfiguration.FringeTileSetRecord tsr = _fringeconf.getFringe( fringer.baseset, hashValue); int fringeset = tsr.fringe_tsid; for (int index : indexes) { // Add a key for this tile as a long containing its base tile, the fringe set it's // working with and the index used in that set. keys.add((((long)fringer.baseset) << 32) + (fringeset << 16) + index); } } long[] fringeId = new long[keys.size()]; for (int ii = 0; ii < fringeId.length; ii++) { fringeId[ii] = keys.get(ii); } FringeTile frTile = new FringeTile(fringeId, passable); // If the fringes map contains something with the same fringe identifier, this will pull // it out and we can use it instead. WeakReference<FringeTile> result = fringes.get(frTile); if (result != null) { FringeTile fringe = result.get(); if (fringe != null) { return fringe; } } // There's no fringe with he same identifier, so we need to create the tile. BufferedImage img = null; for (FringerRec fringer : fringers) { int[] indexes = getFringeIndexes(fringer.bits); FringeConfiguration.FringeTileSetRecord tsr = _fringeconf.getFringe( fringer.baseset, hashValue); for (int index : indexes) { try { img = getTileImage(img, tsr, fringer.baseset, index, hashValue, masks); } catch (NoSuchTileSetException nstse) { log.warning("Autofringer couldn't find a needed tileset", nstse); } } } frTile.setImage(new BufferedMirage(img)); fringes.put(frTile, new WeakReference<FringeTile>(frTile)); return frTile; }
java
protected FringeTile composeFringeTile (FringerRec[] fringers, Map<FringeTile, WeakReference<FringeTile>> fringes, int hashValue, boolean passable, Map<Long, BufferedImage> masks) { // sort the array so that higher priority fringers get drawn first QuickSort.sort(fringers); // Generate an identifier for the fringe tile being created as an array of the keys of its // component tiles in the order they'll be drawn in the fringe tile. List<Long> keys = Lists.newArrayList(); for (FringerRec fringer : fringers) { int[] indexes = getFringeIndexes(fringer.bits); FringeConfiguration.FringeTileSetRecord tsr = _fringeconf.getFringe( fringer.baseset, hashValue); int fringeset = tsr.fringe_tsid; for (int index : indexes) { // Add a key for this tile as a long containing its base tile, the fringe set it's // working with and the index used in that set. keys.add((((long)fringer.baseset) << 32) + (fringeset << 16) + index); } } long[] fringeId = new long[keys.size()]; for (int ii = 0; ii < fringeId.length; ii++) { fringeId[ii] = keys.get(ii); } FringeTile frTile = new FringeTile(fringeId, passable); // If the fringes map contains something with the same fringe identifier, this will pull // it out and we can use it instead. WeakReference<FringeTile> result = fringes.get(frTile); if (result != null) { FringeTile fringe = result.get(); if (fringe != null) { return fringe; } } // There's no fringe with he same identifier, so we need to create the tile. BufferedImage img = null; for (FringerRec fringer : fringers) { int[] indexes = getFringeIndexes(fringer.bits); FringeConfiguration.FringeTileSetRecord tsr = _fringeconf.getFringe( fringer.baseset, hashValue); for (int index : indexes) { try { img = getTileImage(img, tsr, fringer.baseset, index, hashValue, masks); } catch (NoSuchTileSetException nstse) { log.warning("Autofringer couldn't find a needed tileset", nstse); } } } frTile.setImage(new BufferedMirage(img)); fringes.put(frTile, new WeakReference<FringeTile>(frTile)); return frTile; }
[ "protected", "FringeTile", "composeFringeTile", "(", "FringerRec", "[", "]", "fringers", ",", "Map", "<", "FringeTile", ",", "WeakReference", "<", "FringeTile", ">", ">", "fringes", ",", "int", "hashValue", ",", "boolean", "passable", ",", "Map", "<", "Long", ...
Compose a FringeTile out of the various fringe images needed.
[ "Compose", "a", "FringeTile", "out", "of", "the", "various", "fringe", "images", "needed", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/tile/AutoFringer.java#L177-L231
train
threerings/nenya
core/src/main/java/com/threerings/miso/tile/AutoFringer.java
AutoFringer.getTileImage
protected BufferedImage getTileImage (BufferedImage img, FringeConfiguration.FringeTileSetRecord tsr, int baseset, int index, int hashValue, Map<Long, BufferedImage> masks) throws NoSuchTileSetException { int fringeset = tsr.fringe_tsid; TileSet fset = _tmgr.getTileSet(fringeset); if (!tsr.mask) { // oh good, this is easy Tile stamp = fset.getTile(index); return stampTileImage(stamp, img, stamp.getWidth(), stamp.getHeight()); } // otherwise, it's a mask.. Long maskkey = Long.valueOf((((long)baseset) << 32) + (fringeset << 16) + index); BufferedImage mask = masks.get(maskkey); if (mask == null) { BufferedImage fsrc = _tmgr.getTileSet(fringeset).getRawTileImage(index); BufferedImage bsrc = _tmgr.getTileSet(baseset).getRawTileImage(0); mask = ImageUtil.composeMaskedImage(_imgr, fsrc, bsrc); masks.put(maskkey, mask); } return stampTileImage(mask, img, mask.getWidth(null), mask.getHeight(null)); }
java
protected BufferedImage getTileImage (BufferedImage img, FringeConfiguration.FringeTileSetRecord tsr, int baseset, int index, int hashValue, Map<Long, BufferedImage> masks) throws NoSuchTileSetException { int fringeset = tsr.fringe_tsid; TileSet fset = _tmgr.getTileSet(fringeset); if (!tsr.mask) { // oh good, this is easy Tile stamp = fset.getTile(index); return stampTileImage(stamp, img, stamp.getWidth(), stamp.getHeight()); } // otherwise, it's a mask.. Long maskkey = Long.valueOf((((long)baseset) << 32) + (fringeset << 16) + index); BufferedImage mask = masks.get(maskkey); if (mask == null) { BufferedImage fsrc = _tmgr.getTileSet(fringeset).getRawTileImage(index); BufferedImage bsrc = _tmgr.getTileSet(baseset).getRawTileImage(0); mask = ImageUtil.composeMaskedImage(_imgr, fsrc, bsrc); masks.put(maskkey, mask); } return stampTileImage(mask, img, mask.getWidth(null), mask.getHeight(null)); }
[ "protected", "BufferedImage", "getTileImage", "(", "BufferedImage", "img", ",", "FringeConfiguration", ".", "FringeTileSetRecord", "tsr", ",", "int", "baseset", ",", "int", "index", ",", "int", "hashValue", ",", "Map", "<", "Long", ",", "BufferedImage", ">", "ma...
Retrieve or compose an image for the specified fringe.
[ "Retrieve", "or", "compose", "an", "image", "for", "the", "specified", "fringe", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/tile/AutoFringer.java#L236-L260
train
threerings/nenya
core/src/main/java/com/threerings/miso/tile/AutoFringer.java
AutoFringer.getFringeIndexes
protected int[] getFringeIndexes (int bits) { int index = BITS_TO_INDEX[bits]; if (index != -1) { int[] ret = new int[1]; ret[0] = index; return ret; } // otherwise, split the bits into contiguous components // look for a zero and start our first split int start = 0; while ((((1 << start) & bits) != 0) && (start < NUM_FRINGEBITS)) { start++; } if (start == NUM_FRINGEBITS) { // we never found an empty fringebit, and since index (above) // was already -1, we have no fringe tile for these bits.. sad. return new int[0]; } ArrayList<Integer> indexes = Lists.newArrayList(); int weebits = 0; for (int ii = (start + 1) % NUM_FRINGEBITS; ii != start; ii = (ii + 1) % NUM_FRINGEBITS) { if (((1 << ii) & bits) != 0) { weebits |= (1 << ii); } else if (weebits != 0) { index = BITS_TO_INDEX[weebits]; if (index != -1) { indexes.add(index); } weebits = 0; } } if (weebits != 0) { index = BITS_TO_INDEX[weebits]; if (index != -1) { indexes.add(index); } } int[] ret = new int[indexes.size()]; for (int ii = 0; ii < ret.length; ii++) { ret[ii] = indexes.get(ii); } return ret; }
java
protected int[] getFringeIndexes (int bits) { int index = BITS_TO_INDEX[bits]; if (index != -1) { int[] ret = new int[1]; ret[0] = index; return ret; } // otherwise, split the bits into contiguous components // look for a zero and start our first split int start = 0; while ((((1 << start) & bits) != 0) && (start < NUM_FRINGEBITS)) { start++; } if (start == NUM_FRINGEBITS) { // we never found an empty fringebit, and since index (above) // was already -1, we have no fringe tile for these bits.. sad. return new int[0]; } ArrayList<Integer> indexes = Lists.newArrayList(); int weebits = 0; for (int ii = (start + 1) % NUM_FRINGEBITS; ii != start; ii = (ii + 1) % NUM_FRINGEBITS) { if (((1 << ii) & bits) != 0) { weebits |= (1 << ii); } else if (weebits != 0) { index = BITS_TO_INDEX[weebits]; if (index != -1) { indexes.add(index); } weebits = 0; } } if (weebits != 0) { index = BITS_TO_INDEX[weebits]; if (index != -1) { indexes.add(index); } } int[] ret = new int[indexes.size()]; for (int ii = 0; ii < ret.length; ii++) { ret[ii] = indexes.get(ii); } return ret; }
[ "protected", "int", "[", "]", "getFringeIndexes", "(", "int", "bits", ")", "{", "int", "index", "=", "BITS_TO_INDEX", "[", "bits", "]", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "int", "[", "]", "ret", "=", "new", "int", "[", "1", "]", ...
Get the fringe index specified by the fringebits. If no index is available, try breaking down the bits into contiguous regions of bits and look for indexes for those.
[ "Get", "the", "fringe", "index", "specified", "by", "the", "fringebits", ".", "If", "no", "index", "is", "available", "try", "breaking", "down", "the", "bits", "into", "contiguous", "regions", "of", "bits", "and", "look", "for", "indexes", "for", "those", ...
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/tile/AutoFringer.java#L287-L336
train
threerings/nenya
core/src/main/java/com/threerings/openal/SoundGroup.java
SoundGroup.getSound
public Sound getSound (String path) { ClipBuffer buffer = null; if (_manager.isInitialized()) { buffer = _manager.getClip(_provider, path); } return (buffer == null) ? new BlankSound() : new Sound(this, buffer); }
java
public Sound getSound (String path) { ClipBuffer buffer = null; if (_manager.isInitialized()) { buffer = _manager.getClip(_provider, path); } return (buffer == null) ? new BlankSound() : new Sound(this, buffer); }
[ "public", "Sound", "getSound", "(", "String", "path", ")", "{", "ClipBuffer", "buffer", "=", "null", ";", "if", "(", "_manager", ".", "isInitialized", "(", ")", ")", "{", "buffer", "=", "_manager", ".", "getClip", "(", "_provider", ",", "path", ")", ";...
Obtains an "instance" of the specified sound which can be positioned, played, looped and otherwise used to make noise.
[ "Obtains", "an", "instance", "of", "the", "specified", "sound", "which", "can", "be", "positioned", "played", "looped", "and", "otherwise", "used", "to", "make", "noise", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/SoundGroup.java#L69-L76
train
threerings/nenya
core/src/main/java/com/threerings/openal/SoundGroup.java
SoundGroup.dispose
public void dispose () { reclaimAll(); for (PooledSource pooled : _sources) { pooled.source.delete(); } _sources.clear(); // remove from the manager _manager.removeGroup(this); }
java
public void dispose () { reclaimAll(); for (PooledSource pooled : _sources) { pooled.source.delete(); } _sources.clear(); // remove from the manager _manager.removeGroup(this); }
[ "public", "void", "dispose", "(", ")", "{", "reclaimAll", "(", ")", ";", "for", "(", "PooledSource", "pooled", ":", "_sources", ")", "{", "pooled", ".", "source", ".", "delete", "(", ")", ";", "}", "_sources", ".", "clear", "(", ")", ";", "// remove ...
Disposes this sound group, freeing up the OpenAL sources with which it is associated. All sounds obtained from this group will no longer be usable and should be discarded.
[ "Disposes", "this", "sound", "group", "freeing", "up", "the", "OpenAL", "sources", "with", "which", "it", "is", "associated", ".", "All", "sounds", "obtained", "from", "this", "group", "will", "no", "longer", "be", "usable", "and", "should", "be", "discarded...
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/SoundGroup.java#L82-L92
train
threerings/nenya
core/src/main/java/com/threerings/openal/SoundGroup.java
SoundGroup.reclaimAll
public void reclaimAll () { // make sure any bound sources are released for (PooledSource pooled : _sources) { if (pooled.holder != null) { pooled.holder.stop(); pooled.holder.reclaim(); pooled.holder = null; } } }
java
public void reclaimAll () { // make sure any bound sources are released for (PooledSource pooled : _sources) { if (pooled.holder != null) { pooled.holder.stop(); pooled.holder.reclaim(); pooled.holder = null; } } }
[ "public", "void", "reclaimAll", "(", ")", "{", "// make sure any bound sources are released", "for", "(", "PooledSource", "pooled", ":", "_sources", ")", "{", "if", "(", "pooled", ".", "holder", "!=", "null", ")", "{", "pooled", ".", "holder", ".", "stop", "...
Stops and reclaims all sounds from this sound group but does not free the sources.
[ "Stops", "and", "reclaims", "all", "sounds", "from", "this", "sound", "group", "but", "does", "not", "free", "the", "sources", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/SoundGroup.java#L97-L107
train
threerings/nenya
core/src/main/java/com/threerings/openal/SoundGroup.java
SoundGroup.baseGainChanged
protected void baseGainChanged () { // notify any sound currently holding a source for (int ii = 0, nn = _sources.size(); ii < nn; ii++) { Sound holder = _sources.get(ii).holder; if (holder != null) { holder.updateSourceGain(); } } }
java
protected void baseGainChanged () { // notify any sound currently holding a source for (int ii = 0, nn = _sources.size(); ii < nn; ii++) { Sound holder = _sources.get(ii).holder; if (holder != null) { holder.updateSourceGain(); } } }
[ "protected", "void", "baseGainChanged", "(", ")", "{", "// notify any sound currently holding a source", "for", "(", "int", "ii", "=", "0", ",", "nn", "=", "_sources", ".", "size", "(", ")", ";", "ii", "<", "nn", ";", "ii", "++", ")", "{", "Sound", "hold...
Called by the manager when the base gain has changed.
[ "Called", "by", "the", "manager", "when", "the", "base", "gain", "has", "changed", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/SoundGroup.java#L169-L178
train
threerings/nenya
core/src/main/java/com/threerings/media/animation/MultiFrameAnimation.java
MultiFrameAnimation.setFrameIndex
protected void setFrameIndex (int fidx) { _fidx = fidx; _bounds.width = _frames.getWidth(_fidx); _bounds.height = _frames.getHeight(_fidx); }
java
protected void setFrameIndex (int fidx) { _fidx = fidx; _bounds.width = _frames.getWidth(_fidx); _bounds.height = _frames.getHeight(_fidx); }
[ "protected", "void", "setFrameIndex", "(", "int", "fidx", ")", "{", "_fidx", "=", "fidx", ";", "_bounds", ".", "width", "=", "_frames", ".", "getWidth", "(", "_fidx", ")", ";", "_bounds", ".", "height", "=", "_frames", ".", "getHeight", "(", "_fidx", "...
Sets the frame index and updates our dimensions.
[ "Sets", "the", "frame", "index", "and", "updates", "our", "dimensions", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/animation/MultiFrameAnimation.java#L110-L115
train
tonilopezmr/Android-EasySQLite
easysqlite/src/main/java/com/tonilopezmr/easysqlite/SQLiteDelegate.java
SQLiteDelegate.read
@Override public synchronized T read(T dto) throws Exception { Cursor cursor = db.query(transformer.getTableName(), transformer.getFields(), transformer.getWhereClause(dto),null, null,null,null); T object = null; if (cursor.moveToFirst()){ object = transformer.transform(cursor); } return object; }
java
@Override public synchronized T read(T dto) throws Exception { Cursor cursor = db.query(transformer.getTableName(), transformer.getFields(), transformer.getWhereClause(dto),null, null,null,null); T object = null; if (cursor.moveToFirst()){ object = transformer.transform(cursor); } return object; }
[ "@", "Override", "public", "synchronized", "T", "read", "(", "T", "dto", ")", "throws", "Exception", "{", "Cursor", "cursor", "=", "db", ".", "query", "(", "transformer", ".", "getTableName", "(", ")", ",", "transformer", ".", "getFields", "(", ")", ",",...
Convenience method for reading rows in the database. @param dto row in database @return T object @throws Exception on error
[ "Convenience", "method", "for", "reading", "rows", "in", "the", "database", "." ]
bb991a43c9fa11522e5367570ee2335b99bca7c0
https://github.com/tonilopezmr/Android-EasySQLite/blob/bb991a43c9fa11522e5367570ee2335b99bca7c0/easysqlite/src/main/java/com/tonilopezmr/easysqlite/SQLiteDelegate.java#L112-L120
train
tonilopezmr/Android-EasySQLite
easysqlite/src/main/java/com/tonilopezmr/easysqlite/SQLiteDelegate.java
SQLiteDelegate.readAll
@Override public synchronized Collection<T> readAll() throws Exception { Cursor cursor = db.query(transformer.getTableName(), transformer.getFields(), null, null, null, null, null); Collection<T> list = getAllCursor(cursor); return list; }
java
@Override public synchronized Collection<T> readAll() throws Exception { Cursor cursor = db.query(transformer.getTableName(), transformer.getFields(), null, null, null, null, null); Collection<T> list = getAllCursor(cursor); return list; }
[ "@", "Override", "public", "synchronized", "Collection", "<", "T", ">", "readAll", "(", ")", "throws", "Exception", "{", "Cursor", "cursor", "=", "db", ".", "query", "(", "transformer", ".", "getTableName", "(", ")", ",", "transformer", ".", "getFields", "...
Convenience method for reading all rows in the table of database. @return Collection objects @throws Exception on error
[ "Convenience", "method", "for", "reading", "all", "rows", "in", "the", "table", "of", "database", "." ]
bb991a43c9fa11522e5367570ee2335b99bca7c0
https://github.com/tonilopezmr/Android-EasySQLite/blob/bb991a43c9fa11522e5367570ee2335b99bca7c0/easysqlite/src/main/java/com/tonilopezmr/easysqlite/SQLiteDelegate.java#L128-L133
train
threerings/nenya
core/src/main/java/com/threerings/geom/GeomUtil.java
GeomUtil.dot
public static int dot (Point v1s, Point v1e, Point v2s, Point v2e) { return ((v1e.x - v1s.x) * (v2e.x - v2s.x) + (v1e.y - v1s.y) * (v2e.y - v2s.y)); }
java
public static int dot (Point v1s, Point v1e, Point v2s, Point v2e) { return ((v1e.x - v1s.x) * (v2e.x - v2s.x) + (v1e.y - v1s.y) * (v2e.y - v2s.y)); }
[ "public", "static", "int", "dot", "(", "Point", "v1s", ",", "Point", "v1e", ",", "Point", "v2s", ",", "Point", "v2e", ")", "{", "return", "(", "(", "v1e", ".", "x", "-", "v1s", ".", "x", ")", "*", "(", "v2e", ".", "x", "-", "v2s", ".", "x", ...
Computes and returns the dot product of the two vectors. @param v1s the starting point of the first vector. @param v1e the ending point of the first vector. @param v2s the starting point of the second vector. @param v2e the ending point of the second vector.
[ "Computes", "and", "returns", "the", "dot", "product", "of", "the", "two", "vectors", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/geom/GeomUtil.java#L41-L44
train
threerings/nenya
core/src/main/java/com/threerings/geom/GeomUtil.java
GeomUtil.dot
public static int dot (Point vs, Point v1e, Point v2e) { return ((v1e.x - vs.x) * (v2e.x - vs.x) + (v1e.y - vs.y) * (v2e.y - vs.y)); }
java
public static int dot (Point vs, Point v1e, Point v2e) { return ((v1e.x - vs.x) * (v2e.x - vs.x) + (v1e.y - vs.y) * (v2e.y - vs.y)); }
[ "public", "static", "int", "dot", "(", "Point", "vs", ",", "Point", "v1e", ",", "Point", "v2e", ")", "{", "return", "(", "(", "v1e", ".", "x", "-", "vs", ".", "x", ")", "*", "(", "v2e", ".", "x", "-", "vs", ".", "x", ")", "+", "(", "v1e", ...
Computes and returns the dot product of the two vectors. The vectors are assumed to start with the same coordinate and end with different coordinates. @param vs the starting point of both vectors. @param v1e the ending point of the first vector. @param v2e the ending point of the second vector.
[ "Computes", "and", "returns", "the", "dot", "product", "of", "the", "two", "vectors", ".", "The", "vectors", "are", "assumed", "to", "start", "with", "the", "same", "coordinate", "and", "end", "with", "different", "coordinates", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/geom/GeomUtil.java#L64-L67
train
threerings/nenya
core/src/main/java/com/threerings/geom/GeomUtil.java
GeomUtil.lineIntersection
public static boolean lineIntersection (Point2D p1, Point2D p2, boolean seg1, Point2D p3, Point2D p4, boolean seg2, Point2D result) { // see http://astronomy.swin.edu.au/~pbourke/geometry/lineline2d/ double y43 = p4.getY() - p3.getY(); double x21 = p2.getX() - p1.getX(); double x43 = p4.getX() - p3.getX(); double y21 = p2.getY() - p1.getY(); double denom = y43 * x21 - x43 * y21; if (denom == 0) { return false; } double y13 = p1.getY() - p3.getY(); double x13 = p1.getX() - p3.getX(); double ua = (x43 * y13 - y43 * x13) / denom; if (seg1 && ((ua < 0) || (ua > 1))) { return false; } if (seg2) { double ub = (x21 * y13 - y21 * x13) / denom; if ((ub < 0) || (ub > 1)) { return false; } } double x = p1.getX() + ua * x21; double y = p1.getY() + ua * y21; result.setLocation(x, y); return true; }
java
public static boolean lineIntersection (Point2D p1, Point2D p2, boolean seg1, Point2D p3, Point2D p4, boolean seg2, Point2D result) { // see http://astronomy.swin.edu.au/~pbourke/geometry/lineline2d/ double y43 = p4.getY() - p3.getY(); double x21 = p2.getX() - p1.getX(); double x43 = p4.getX() - p3.getX(); double y21 = p2.getY() - p1.getY(); double denom = y43 * x21 - x43 * y21; if (denom == 0) { return false; } double y13 = p1.getY() - p3.getY(); double x13 = p1.getX() - p3.getX(); double ua = (x43 * y13 - y43 * x13) / denom; if (seg1 && ((ua < 0) || (ua > 1))) { return false; } if (seg2) { double ub = (x21 * y13 - y21 * x13) / denom; if ((ub < 0) || (ub > 1)) { return false; } } double x = p1.getX() + ua * x21; double y = p1.getY() + ua * y21; result.setLocation(x, y); return true; }
[ "public", "static", "boolean", "lineIntersection", "(", "Point2D", "p1", ",", "Point2D", "p2", ",", "boolean", "seg1", ",", "Point2D", "p3", ",", "Point2D", "p4", ",", "boolean", "seg2", ",", "Point2D", "result", ")", "{", "// see http://astronomy.swin.edu.au/~p...
Calculate the intersection of two lines. Either line may be considered as a line segment, and the intersecting point is only considered valid if it lies upon the segment. Note that Point extends Point2D. @param p1 and p2 the coordinates of the first line. @param seg1 if the first line should be considered a segment. @param p3 and p4 the coordinates of the second line. @param seg2 if the second line should be considered a segment. @param result the point that will be filled in with the intersecting point. @return true if result was filled in, or false if the lines are parallel or the point of intersection lies outside of a segment.
[ "Calculate", "the", "intersection", "of", "two", "lines", ".", "Either", "line", "may", "be", "considered", "as", "a", "line", "segment", "and", "the", "intersecting", "point", "is", "only", "considered", "valid", "if", "it", "lies", "upon", "the", "segment"...
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/geom/GeomUtil.java#L117-L148
train
threerings/nenya
core/src/main/java/com/threerings/geom/GeomUtil.java
GeomUtil.grow
public static Rectangle grow (Rectangle source, Rectangle target) { if (target == null) { log.warning("Can't grow with null rectangle [src=" + source + ", tgt=" + target + "].", new Exception()); } else if (source == null) { source = new Rectangle(target); } else { source.add(target); } return source; }
java
public static Rectangle grow (Rectangle source, Rectangle target) { if (target == null) { log.warning("Can't grow with null rectangle [src=" + source + ", tgt=" + target + "].", new Exception()); } else if (source == null) { source = new Rectangle(target); } else { source.add(target); } return source; }
[ "public", "static", "Rectangle", "grow", "(", "Rectangle", "source", ",", "Rectangle", "target", ")", "{", "if", "(", "target", "==", "null", ")", "{", "log", ".", "warning", "(", "\"Can't grow with null rectangle [src=\"", "+", "source", "+", "\", tgt=\"", "+...
Adds the target rectangle to the bounds of the source rectangle. If the source rectangle is null, a new rectangle is created that is the size of the target rectangle. @return the source rectangle.
[ "Adds", "the", "target", "rectangle", "to", "the", "bounds", "of", "the", "source", "rectangle", ".", "If", "the", "source", "rectangle", "is", "null", "a", "new", "rectangle", "is", "created", "that", "is", "the", "size", "of", "the", "target", "rectangle...
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/geom/GeomUtil.java#L200-L211
train
threerings/nenya
core/src/main/java/com/threerings/geom/GeomUtil.java
GeomUtil.getTile
public static Rectangle getTile ( int width, int height, int tileWidth, int tileHeight, int tileIndex) { Rectangle bounds = new Rectangle(); getTile(width, height, tileWidth, tileHeight, tileIndex, bounds); return bounds; }
java
public static Rectangle getTile ( int width, int height, int tileWidth, int tileHeight, int tileIndex) { Rectangle bounds = new Rectangle(); getTile(width, height, tileWidth, tileHeight, tileIndex, bounds); return bounds; }
[ "public", "static", "Rectangle", "getTile", "(", "int", "width", ",", "int", "height", ",", "int", "tileWidth", ",", "int", "tileHeight", ",", "int", "tileIndex", ")", "{", "Rectangle", "bounds", "=", "new", "Rectangle", "(", ")", ";", "getTile", "(", "w...
Returns the rectangle containing the specified tile in the supplied larger rectangle. Tiles go from left to right, top to bottom.
[ "Returns", "the", "rectangle", "containing", "the", "specified", "tile", "in", "the", "supplied", "larger", "rectangle", ".", "Tiles", "go", "from", "left", "to", "right", "top", "to", "bottom", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/geom/GeomUtil.java#L217-L223
train
threerings/nenya
core/src/main/java/com/threerings/geom/GeomUtil.java
GeomUtil.getTile
public static void getTile (int width, int height, int tileWidth, int tileHeight, int tileIndex, Rectangle bounds) { // figure out from whence to crop the tile int tilesPerRow = width / tileWidth; // if we got a bogus region, return bogus tile bounds if (tilesPerRow == 0) { bounds.setBounds(0, 0, width, height); } else { int row = tileIndex / tilesPerRow; int col = tileIndex % tilesPerRow; // crop the tile-sized image chunk from the full image bounds.setBounds(tileWidth*col, tileHeight*row, tileWidth, tileHeight); } }
java
public static void getTile (int width, int height, int tileWidth, int tileHeight, int tileIndex, Rectangle bounds) { // figure out from whence to crop the tile int tilesPerRow = width / tileWidth; // if we got a bogus region, return bogus tile bounds if (tilesPerRow == 0) { bounds.setBounds(0, 0, width, height); } else { int row = tileIndex / tilesPerRow; int col = tileIndex % tilesPerRow; // crop the tile-sized image chunk from the full image bounds.setBounds(tileWidth*col, tileHeight*row, tileWidth, tileHeight); } }
[ "public", "static", "void", "getTile", "(", "int", "width", ",", "int", "height", ",", "int", "tileWidth", ",", "int", "tileHeight", ",", "int", "tileIndex", ",", "Rectangle", "bounds", ")", "{", "// figure out from whence to crop the tile", "int", "tilesPerRow", ...
Fills in the bounds of the specified tile in the supplied larger rectangle. Tiles go from left to right, top to bottom.
[ "Fills", "in", "the", "bounds", "of", "the", "specified", "tile", "in", "the", "supplied", "larger", "rectangle", ".", "Tiles", "go", "from", "left", "to", "right", "top", "to", "bottom", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/geom/GeomUtil.java#L229-L245
train
kaazing/java.client
ws/ws/src/main/java/org/kaazing/net/ws/impl/WebSocketImpl.java
WebSocketImpl.setNegotiatedExtensions
private void setNegotiatedExtensions(String extensionsHeader) { if ((extensionsHeader == null) || (extensionsHeader.trim().length() == 0)) { _negotiatedExtensions = null; return; } String[] extns = extensionsHeader.split(","); List<String> extnNames = new ArrayList<String>(); for (String extn : extns) { String[] properties = extn.split(";"); String extnName = properties[0].trim(); if (!getEnabledExtensions().contains(extnName)) { String s = String.format("Extension '%s' is not an enabled " + "extension so it should not have been negotiated", extnName); setException(new WebSocketException(s)); return; } WebSocketExtension extension = WebSocketExtension.getWebSocketExtension(extnName); WsExtensionParameterValuesSpiImpl paramValues = _negotiatedParameters.get(extnName); Collection<Parameter<?>> anonymousParams = extension.getParameters(Metadata.ANONYMOUS); // Start from the second(0-based) property to parse the name-value // pairs as the first(or 0th) is the extension name. for (int i = 1; i < properties.length; i++) { String property = properties[i].trim(); String[] pair = property.split("="); Parameter<?> parameter = null; String paramValue = null; if (pair.length == 1) { // We are dealing with an anonymous parameter. Since the // Collection is actually an ArrayList, we are guaranteed to // iterate the parameters in the definition/creation order. // As there is no parameter name, we will just get the next // anonymous Parameter instance and use it for setting the // value. The onus is on the extension implementor to either // use only named parameters or ensure that the anonymous // parameters are defined in the order in which the server // will send them back during negotiation. parameter = anonymousParams.iterator().next(); paramValue = pair[0].trim(); } else { parameter = extension.getParameter(pair[0].trim()); paramValue = pair[1].trim(); } if (parameter.type() != String.class) { String paramName = parameter.name(); String s = String.format("Negotiated Extension '%s': " + "Type of parameter '%s' should be String", extnName, paramName); setException(new WebSocketException(s)); return; } if (paramValues == null) { paramValues = new WsExtensionParameterValuesSpiImpl(); _negotiatedParameters.put(extnName, paramValues); } paramValues.setParameterValue(parameter, paramValue); } extnNames.add(extnName); } HashSet<String> extnsSet = new HashSet<String>(extnNames); _negotiatedExtensions = unmodifiableCollection(extnsSet); }
java
private void setNegotiatedExtensions(String extensionsHeader) { if ((extensionsHeader == null) || (extensionsHeader.trim().length() == 0)) { _negotiatedExtensions = null; return; } String[] extns = extensionsHeader.split(","); List<String> extnNames = new ArrayList<String>(); for (String extn : extns) { String[] properties = extn.split(";"); String extnName = properties[0].trim(); if (!getEnabledExtensions().contains(extnName)) { String s = String.format("Extension '%s' is not an enabled " + "extension so it should not have been negotiated", extnName); setException(new WebSocketException(s)); return; } WebSocketExtension extension = WebSocketExtension.getWebSocketExtension(extnName); WsExtensionParameterValuesSpiImpl paramValues = _negotiatedParameters.get(extnName); Collection<Parameter<?>> anonymousParams = extension.getParameters(Metadata.ANONYMOUS); // Start from the second(0-based) property to parse the name-value // pairs as the first(or 0th) is the extension name. for (int i = 1; i < properties.length; i++) { String property = properties[i].trim(); String[] pair = property.split("="); Parameter<?> parameter = null; String paramValue = null; if (pair.length == 1) { // We are dealing with an anonymous parameter. Since the // Collection is actually an ArrayList, we are guaranteed to // iterate the parameters in the definition/creation order. // As there is no parameter name, we will just get the next // anonymous Parameter instance and use it for setting the // value. The onus is on the extension implementor to either // use only named parameters or ensure that the anonymous // parameters are defined in the order in which the server // will send them back during negotiation. parameter = anonymousParams.iterator().next(); paramValue = pair[0].trim(); } else { parameter = extension.getParameter(pair[0].trim()); paramValue = pair[1].trim(); } if (parameter.type() != String.class) { String paramName = parameter.name(); String s = String.format("Negotiated Extension '%s': " + "Type of parameter '%s' should be String", extnName, paramName); setException(new WebSocketException(s)); return; } if (paramValues == null) { paramValues = new WsExtensionParameterValuesSpiImpl(); _negotiatedParameters.put(extnName, paramValues); } paramValues.setParameterValue(parameter, paramValue); } extnNames.add(extnName); } HashSet<String> extnsSet = new HashSet<String>(extnNames); _negotiatedExtensions = unmodifiableCollection(extnsSet); }
[ "private", "void", "setNegotiatedExtensions", "(", "String", "extensionsHeader", ")", "{", "if", "(", "(", "extensionsHeader", "==", "null", ")", "||", "(", "extensionsHeader", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", ")", "{", "_n...
RFC 3864 format.
[ "RFC", "3864", "format", "." ]
25ad2ae5bb24aa9d6b79400fce649b518dcfbe26
https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/ws/ws/src/main/java/org/kaazing/net/ws/impl/WebSocketImpl.java#L972-L1048
train
groupon/robo-remote
RoboRemoteClient/src/main/com/groupon/roboremote/roboremoteclient/components/ListView.java
ListView.scrollToIndex
public static int scrollToIndex(String listRef, int itemIndex) throws Exception { int listViewIndex = getListViewIndex(listRef); if (itemIndex >= numItemsInList(listRef)) throw new Exception("Item index is greater than number of items in the list"); // scroll to the top of this view if we already passed the index being looked for QueryBuilder builder = new QueryBuilder(); int firstVisiblePosition = builder.map("solo", "getCurrentViews", "android.widget.ListView").call("get", listViewIndex).call("getFirstVisiblePosition").execute().getInt(0); if (firstVisiblePosition > itemIndex) scrollToTop(); boolean scrollDown = true; // need to get the wanted item onto the screen while (true) { builder = new QueryBuilder(); firstVisiblePosition = builder.map("solo", "getCurrentViews", "android.widget.ListView").call("get", listViewIndex).call("getFirstVisiblePosition").execute().getInt(0); builder = new QueryBuilder(); int headersViewsCount = builder.map("solo", "getCurrentViews", "android.widget.ListView").call("get", listViewIndex).call("getHeaderViewsCount").execute().getInt(0); firstVisiblePosition = firstVisiblePosition - headersViewsCount; builder = new QueryBuilder(); int visibleChildCount = builder.map("solo", "getCurrentViews", "android.widget.ListView").call("get", listViewIndex).call("getChildCount").execute().getInt(0); int wantedPosition = itemIndex - firstVisiblePosition; if (wantedPosition >= visibleChildCount) { // check to see if we can even scroll anymore if (! scrollDown) { break; } scrollDown = Solo.scrollDownList(listViewIndex); } else { // return the position return wantedPosition; } } throw new Exception("Could not find item"); }
java
public static int scrollToIndex(String listRef, int itemIndex) throws Exception { int listViewIndex = getListViewIndex(listRef); if (itemIndex >= numItemsInList(listRef)) throw new Exception("Item index is greater than number of items in the list"); // scroll to the top of this view if we already passed the index being looked for QueryBuilder builder = new QueryBuilder(); int firstVisiblePosition = builder.map("solo", "getCurrentViews", "android.widget.ListView").call("get", listViewIndex).call("getFirstVisiblePosition").execute().getInt(0); if (firstVisiblePosition > itemIndex) scrollToTop(); boolean scrollDown = true; // need to get the wanted item onto the screen while (true) { builder = new QueryBuilder(); firstVisiblePosition = builder.map("solo", "getCurrentViews", "android.widget.ListView").call("get", listViewIndex).call("getFirstVisiblePosition").execute().getInt(0); builder = new QueryBuilder(); int headersViewsCount = builder.map("solo", "getCurrentViews", "android.widget.ListView").call("get", listViewIndex).call("getHeaderViewsCount").execute().getInt(0); firstVisiblePosition = firstVisiblePosition - headersViewsCount; builder = new QueryBuilder(); int visibleChildCount = builder.map("solo", "getCurrentViews", "android.widget.ListView").call("get", listViewIndex).call("getChildCount").execute().getInt(0); int wantedPosition = itemIndex - firstVisiblePosition; if (wantedPosition >= visibleChildCount) { // check to see if we can even scroll anymore if (! scrollDown) { break; } scrollDown = Solo.scrollDownList(listViewIndex); } else { // return the position return wantedPosition; } } throw new Exception("Could not find item"); }
[ "public", "static", "int", "scrollToIndex", "(", "String", "listRef", ",", "int", "itemIndex", ")", "throws", "Exception", "{", "int", "listViewIndex", "=", "getListViewIndex", "(", "listRef", ")", ";", "if", "(", "itemIndex", ">=", "numItemsInList", "(", "lis...
Scrolls the specified item index onto the screen and returns the offset based on the current visible list @param listRef @param itemIndex @return @throws Exception
[ "Scrolls", "the", "specified", "item", "index", "onto", "the", "screen", "and", "returns", "the", "offset", "based", "on", "the", "current", "visible", "list" ]
12d242faad50bf90f98657ca9a0c0c3ae1993f07
https://github.com/groupon/robo-remote/blob/12d242faad50bf90f98657ca9a0c0c3ae1993f07/RoboRemoteClient/src/main/com/groupon/roboremote/roboremoteclient/components/ListView.java#L93-L135
train
threerings/nenya
core/src/main/java/com/threerings/media/util/TrailingAverage.java
TrailingAverage.value
public int value () { int end = Math.min(_history.length, _index); int value = 0; for (int ii = 0; ii < end; ii++) { value += _history[ii]; } return (end > 0) ? (value/end) : 0; }
java
public int value () { int end = Math.min(_history.length, _index); int value = 0; for (int ii = 0; ii < end; ii++) { value += _history[ii]; } return (end > 0) ? (value/end) : 0; }
[ "public", "int", "value", "(", ")", "{", "int", "end", "=", "Math", ".", "min", "(", "_history", ".", "length", ",", "_index", ")", ";", "int", "value", "=", "0", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "end", ";", "ii", "++",...
Returns the current averaged value.
[ "Returns", "the", "current", "averaged", "value", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/util/TrailingAverage.java#L56-L64
train
threerings/nenya
core/src/main/java/com/threerings/media/sound/JavaSoundPlayer.java
JavaSoundPlayer.loop
protected Frob loop (String pkgPath, String key, float pan, byte cmd) { SoundKey skey = new SoundKey(cmd, pkgPath, key, 0, _clipVol, pan); addToPlayQueue(skey); return skey; // it is a frob }
java
protected Frob loop (String pkgPath, String key, float pan, byte cmd) { SoundKey skey = new SoundKey(cmd, pkgPath, key, 0, _clipVol, pan); addToPlayQueue(skey); return skey; // it is a frob }
[ "protected", "Frob", "loop", "(", "String", "pkgPath", ",", "String", "key", ",", "float", "pan", ",", "byte", "cmd", ")", "{", "SoundKey", "skey", "=", "new", "SoundKey", "(", "cmd", ",", "pkgPath", ",", "key", ",", "0", ",", "_clipVol", ",", "pan",...
Loop the specified sound.
[ "Loop", "the", "specified", "sound", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sound/JavaSoundPlayer.java#L176-L181
train
threerings/nenya
core/src/main/java/com/threerings/media/sound/JavaSoundPlayer.java
JavaSoundPlayer.addToPlayQueue
protected void addToPlayQueue (SoundKey skey) { boolean queued = enqueue(skey, true); if (queued) { if (_verbose.getValue()) { log.info("Sound request [key=" + skey.key + "]."); } } else /* if (_verbose.getValue()) */ { log.warning("SoundManager not playing sound because too many sounds in queue " + "[key=" + skey + "]."); } }
java
protected void addToPlayQueue (SoundKey skey) { boolean queued = enqueue(skey, true); if (queued) { if (_verbose.getValue()) { log.info("Sound request [key=" + skey.key + "]."); } } else /* if (_verbose.getValue()) */ { log.warning("SoundManager not playing sound because too many sounds in queue " + "[key=" + skey + "]."); } }
[ "protected", "void", "addToPlayQueue", "(", "SoundKey", "skey", ")", "{", "boolean", "queued", "=", "enqueue", "(", "skey", ",", "true", ")", ";", "if", "(", "queued", ")", "{", "if", "(", "_verbose", ".", "getValue", "(", ")", ")", "{", "log", ".", ...
Add the sound clip key to the queue to be played.
[ "Add", "the", "sound", "clip", "key", "to", "the", "queue", "to", "be", "played", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sound/JavaSoundPlayer.java#L186-L198
train
threerings/nenya
core/src/main/java/com/threerings/media/sound/JavaSoundPlayer.java
JavaSoundPlayer.enqueue
protected boolean enqueue (SoundKey key, boolean okToStartNew) { boolean add; boolean queued; synchronized (_queue) { if (key.cmd == PLAY && _queue.size() > MAX_QUEUE_SIZE) { queued = add = false; } else { _queue.appendLoud(key); queued = true; add = okToStartNew && (_freeSpoolers == 0) && (_spoolerCount < MAX_SPOOLERS); if (add) { _spoolerCount++; } } } // and if we need a new thread, add it if (add) { Thread spooler = new Thread("narya SoundManager line spooler") { @Override public void run () { spoolerRun(); } }; spooler.setDaemon(true); spooler.start(); } return queued; }
java
protected boolean enqueue (SoundKey key, boolean okToStartNew) { boolean add; boolean queued; synchronized (_queue) { if (key.cmd == PLAY && _queue.size() > MAX_QUEUE_SIZE) { queued = add = false; } else { _queue.appendLoud(key); queued = true; add = okToStartNew && (_freeSpoolers == 0) && (_spoolerCount < MAX_SPOOLERS); if (add) { _spoolerCount++; } } } // and if we need a new thread, add it if (add) { Thread spooler = new Thread("narya SoundManager line spooler") { @Override public void run () { spoolerRun(); } }; spooler.setDaemon(true); spooler.start(); } return queued; }
[ "protected", "boolean", "enqueue", "(", "SoundKey", "key", ",", "boolean", "okToStartNew", ")", "{", "boolean", "add", ";", "boolean", "queued", ";", "synchronized", "(", "_queue", ")", "{", "if", "(", "key", ".", "cmd", "==", "PLAY", "&&", "_queue", "."...
Enqueue a new SoundKey.
[ "Enqueue", "a", "new", "SoundKey", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sound/JavaSoundPlayer.java#L203-L233
train
threerings/nenya
core/src/main/java/com/threerings/media/sound/JavaSoundPlayer.java
JavaSoundPlayer.spoolerRun
protected void spoolerRun () { while (true) { try { SoundKey key; synchronized (_queue) { _freeSpoolers++; key = _queue.get(MAX_WAIT_TIME); _freeSpoolers--; if (key == null || key.cmd == DIE) { _spoolerCount--; // if dying and there are others to kill, do so if (key != null && _spoolerCount > 0) { _queue.appendLoud(key); } return; } } // process the command processKey(key); } catch (Exception e) { log.warning(e); } } }
java
protected void spoolerRun () { while (true) { try { SoundKey key; synchronized (_queue) { _freeSpoolers++; key = _queue.get(MAX_WAIT_TIME); _freeSpoolers--; if (key == null || key.cmd == DIE) { _spoolerCount--; // if dying and there are others to kill, do so if (key != null && _spoolerCount > 0) { _queue.appendLoud(key); } return; } } // process the command processKey(key); } catch (Exception e) { log.warning(e); } } }
[ "protected", "void", "spoolerRun", "(", ")", "{", "while", "(", "true", ")", "{", "try", "{", "SoundKey", "key", ";", "synchronized", "(", "_queue", ")", "{", "_freeSpoolers", "++", ";", "key", "=", "_queue", ".", "get", "(", "MAX_WAIT_TIME", ")", ";",...
This is the primary run method of the sound-playing threads.
[ "This", "is", "the", "primary", "run", "method", "of", "the", "sound", "-", "playing", "threads", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sound/JavaSoundPlayer.java#L238-L265
train
threerings/nenya
core/src/main/java/com/threerings/media/sound/JavaSoundPlayer.java
JavaSoundPlayer.processKey
protected void processKey (SoundKey key) throws Exception { switch (key.cmd) { case PLAY: case LOOP: playSound(key); break; case LOCK: if (!isTesting()) { synchronized (_clipCache) { try { getClipData(key); // preload // copy cached to lock map _lockedClips.put(key, _clipCache.get(key)); } catch (Exception e) { // don't whine about LOCK failures unless we are verbosely logging if (_verbose.getValue()) { throw e; } } } } break; case UNLOCK: synchronized (_clipCache) { _lockedClips.remove(key); } break; } }
java
protected void processKey (SoundKey key) throws Exception { switch (key.cmd) { case PLAY: case LOOP: playSound(key); break; case LOCK: if (!isTesting()) { synchronized (_clipCache) { try { getClipData(key); // preload // copy cached to lock map _lockedClips.put(key, _clipCache.get(key)); } catch (Exception e) { // don't whine about LOCK failures unless we are verbosely logging if (_verbose.getValue()) { throw e; } } } } break; case UNLOCK: synchronized (_clipCache) { _lockedClips.remove(key); } break; } }
[ "protected", "void", "processKey", "(", "SoundKey", "key", ")", "throws", "Exception", "{", "switch", "(", "key", ".", "cmd", ")", "{", "case", "PLAY", ":", "case", "LOOP", ":", "playSound", "(", "key", ")", ";", "break", ";", "case", "LOCK", ":", "i...
Process the requested command in the specified SoundKey.
[ "Process", "the", "requested", "command", "in", "the", "specified", "SoundKey", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sound/JavaSoundPlayer.java#L270-L302
train
threerings/nenya
core/src/main/java/com/threerings/media/sound/JavaSoundPlayer.java
JavaSoundPlayer.getClipData
protected byte[] getClipData (SoundKey key) throws IOException, UnsupportedAudioFileException { byte[][] data; synchronized (_clipCache) { // if we're testing, clear all non-locked sounds every time if (isTesting()) { _clipCache.clear(); } data = _clipCache.get(key); // see if it's in the locked cache (we first look in the regular // clip cache so that locked clips that are still cached continue // to be moved to the head of the LRU queue) if (data == null) { data = _lockedClips.get(key); } if (data == null) { // if there is a test sound, JUST use the test sound. InputStream stream = getTestClip(key); if (stream != null) { data = new byte[1][]; data[0] = StreamUtil.toByteArray(stream); } else { data = _loader.load(key.pkgPath, key.key); } _clipCache.put(key, data); } } return (data.length > 0) ? data[RandomUtil.getInt(data.length)] : null; }
java
protected byte[] getClipData (SoundKey key) throws IOException, UnsupportedAudioFileException { byte[][] data; synchronized (_clipCache) { // if we're testing, clear all non-locked sounds every time if (isTesting()) { _clipCache.clear(); } data = _clipCache.get(key); // see if it's in the locked cache (we first look in the regular // clip cache so that locked clips that are still cached continue // to be moved to the head of the LRU queue) if (data == null) { data = _lockedClips.get(key); } if (data == null) { // if there is a test sound, JUST use the test sound. InputStream stream = getTestClip(key); if (stream != null) { data = new byte[1][]; data[0] = StreamUtil.toByteArray(stream); } else { data = _loader.load(key.pkgPath, key.key); } _clipCache.put(key, data); } } return (data.length > 0) ? data[RandomUtil.getInt(data.length)] : null; }
[ "protected", "byte", "[", "]", "getClipData", "(", "SoundKey", "key", ")", "throws", "IOException", ",", "UnsupportedAudioFileException", "{", "byte", "[", "]", "[", "]", "data", ";", "synchronized", "(", "_clipCache", ")", "{", "// if we're testing, clear all non...
Called by spooling threads, loads clip data from the resource manager or the cache.
[ "Called", "by", "spooling", "threads", "loads", "clip", "data", "from", "the", "resource", "manager", "or", "the", "cache", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sound/JavaSoundPlayer.java#L484-L519
train
threerings/nenya
core/src/main/java/com/threerings/media/sound/JavaSoundPlayer.java
JavaSoundPlayer.adjustVolume
protected static void adjustVolume (Line line, float vol) { FloatControl control = (FloatControl) line.getControl(FloatControl.Type.MASTER_GAIN); // the only problem is that gain is specified in decibals, which is a logarithmic scale. // Since we want max volume to leave the sample unchanged, our // maximum volume translates into a 0db gain. float gain; if (vol == 0f) { gain = control.getMinimum(); } else { gain = (float) ((Math.log(vol) / Math.log(10.0)) * 20.0); } control.setValue(gain); //Log.info("Set gain: " + gain); }
java
protected static void adjustVolume (Line line, float vol) { FloatControl control = (FloatControl) line.getControl(FloatControl.Type.MASTER_GAIN); // the only problem is that gain is specified in decibals, which is a logarithmic scale. // Since we want max volume to leave the sample unchanged, our // maximum volume translates into a 0db gain. float gain; if (vol == 0f) { gain = control.getMinimum(); } else { gain = (float) ((Math.log(vol) / Math.log(10.0)) * 20.0); } control.setValue(gain); //Log.info("Set gain: " + gain); }
[ "protected", "static", "void", "adjustVolume", "(", "Line", "line", ",", "float", "vol", ")", "{", "FloatControl", "control", "=", "(", "FloatControl", ")", "line", ".", "getControl", "(", "FloatControl", ".", "Type", ".", "MASTER_GAIN", ")", ";", "// the on...
Use the gain control to implement volume.
[ "Use", "the", "gain", "control", "to", "implement", "volume", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sound/JavaSoundPlayer.java#L577-L593
train
threerings/nenya
core/src/main/java/com/threerings/media/sound/JavaSoundPlayer.java
JavaSoundPlayer.adjustPan
protected static void adjustPan (Line line, float pan) { try { FloatControl control = (FloatControl) line.getControl(FloatControl.Type.PAN); control.setValue(pan); } catch (Exception e) { log.debug("Cannot set pan on line: " + e); } }
java
protected static void adjustPan (Line line, float pan) { try { FloatControl control = (FloatControl) line.getControl(FloatControl.Type.PAN); control.setValue(pan); } catch (Exception e) { log.debug("Cannot set pan on line: " + e); } }
[ "protected", "static", "void", "adjustPan", "(", "Line", "line", ",", "float", "pan", ")", "{", "try", "{", "FloatControl", "control", "=", "(", "FloatControl", ")", "line", ".", "getControl", "(", "FloatControl", ".", "Type", ".", "PAN", ")", ";", "cont...
Set the pan value for the specified line.
[ "Set", "the", "pan", "value", "for", "the", "specified", "line", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sound/JavaSoundPlayer.java#L598-L606
train
threerings/nenya
core/src/main/java/com/threerings/media/FrameInterval.java
FrameInterval.tick
public void tick (long tickStamp) { if (_nextTime == -1) { // First time through _nextTime = tickStamp + _initDelay; } else if (tickStamp >= _nextTime) { // If we're repeating, set the next time to run, otherwise, reset if (_repeatDelay != 0L) { _nextTime += _repeatDelay; } else { _nextTime = -1; cancel(); } expired(); } }
java
public void tick (long tickStamp) { if (_nextTime == -1) { // First time through _nextTime = tickStamp + _initDelay; } else if (tickStamp >= _nextTime) { // If we're repeating, set the next time to run, otherwise, reset if (_repeatDelay != 0L) { _nextTime += _repeatDelay; } else { _nextTime = -1; cancel(); } expired(); } }
[ "public", "void", "tick", "(", "long", "tickStamp", ")", "{", "if", "(", "_nextTime", "==", "-", "1", ")", "{", "// First time through", "_nextTime", "=", "tickStamp", "+", "_initDelay", ";", "}", "else", "if", "(", "tickStamp", ">=", "_nextTime", ")", "...
documentation inherited from FrameParticipant
[ "documentation", "inherited", "from", "FrameParticipant" ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/FrameInterval.java#L48-L64
train
threerings/nenya
core/src/main/java/com/threerings/media/sprite/OrientableImageSprite.java
OrientableImageSprite.getRotationTransform
private AffineTransform getRotationTransform () { double theta; switch (_orient) { case NORTH: default: theta = 0.0; break; case SOUTH: theta = Math.PI; break; case EAST: theta = Math.PI*0.5; break; case WEST: theta = -Math.PI*0.5; break; case NORTHEAST: theta = Math.PI*0.25; break; case NORTHWEST: theta = -Math.PI*0.25; break; case SOUTHEAST: theta = Math.PI*0.75; break; case SOUTHWEST: theta = -Math.PI*0.75; break; case NORTHNORTHEAST: theta = -Math.PI*0.125; break; case NORTHNORTHWEST: theta = Math.PI*0.125; break; case SOUTHSOUTHEAST: theta = -Math.PI*0.875; break; case SOUTHSOUTHWEST: theta = Math.PI*0.875; break; case EASTNORTHEAST: theta = -Math.PI*0.375; break; case EASTSOUTHEAST: theta = -Math.PI*0.625; break; case WESTNORTHWEST: theta = Math.PI*0.375; break; case WESTSOUTHWEST: theta = Math.PI*0.625; break; } return AffineTransform.getRotateInstance( theta, (_ox - _oxoff) + _frames.getWidth(_frameIdx)/2, (_oy - _oyoff) + _frames.getHeight(_frameIdx)/2 ); }
java
private AffineTransform getRotationTransform () { double theta; switch (_orient) { case NORTH: default: theta = 0.0; break; case SOUTH: theta = Math.PI; break; case EAST: theta = Math.PI*0.5; break; case WEST: theta = -Math.PI*0.5; break; case NORTHEAST: theta = Math.PI*0.25; break; case NORTHWEST: theta = -Math.PI*0.25; break; case SOUTHEAST: theta = Math.PI*0.75; break; case SOUTHWEST: theta = -Math.PI*0.75; break; case NORTHNORTHEAST: theta = -Math.PI*0.125; break; case NORTHNORTHWEST: theta = Math.PI*0.125; break; case SOUTHSOUTHEAST: theta = -Math.PI*0.875; break; case SOUTHSOUTHWEST: theta = Math.PI*0.875; break; case EASTNORTHEAST: theta = -Math.PI*0.375; break; case EASTSOUTHEAST: theta = -Math.PI*0.625; break; case WESTNORTHWEST: theta = Math.PI*0.375; break; case WESTSOUTHWEST: theta = Math.PI*0.625; break; } return AffineTransform.getRotateInstance( theta, (_ox - _oxoff) + _frames.getWidth(_frameIdx)/2, (_oy - _oyoff) + _frames.getHeight(_frameIdx)/2 ); }
[ "private", "AffineTransform", "getRotationTransform", "(", ")", "{", "double", "theta", ";", "switch", "(", "_orient", ")", "{", "case", "NORTH", ":", "default", ":", "theta", "=", "0.0", ";", "break", ";", "case", "SOUTH", ":", "theta", "=", "Math", "."...
Computes and returns the rotation transform for this sprite. @return the newly computed rotation transform
[ "Computes", "and", "returns", "the", "rotation", "transform", "for", "this", "sprite", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/sprite/OrientableImageSprite.java#L68-L144
train
groupon/monsoon
expr/src/main/java/com/groupon/lex/metrics/MetricMatcher.java
MetricMatcher.filter
public Stream<Entry<MatchedName, MetricValue>> filter(Context t) { return t.getTSData().getCurrentCollection().get(this::match, x -> true).stream() .flatMap(this::filterMetricsInTsv); }
java
public Stream<Entry<MatchedName, MetricValue>> filter(Context t) { return t.getTSData().getCurrentCollection().get(this::match, x -> true).stream() .flatMap(this::filterMetricsInTsv); }
[ "public", "Stream", "<", "Entry", "<", "MatchedName", ",", "MetricValue", ">", ">", "filter", "(", "Context", "t", ")", "{", "return", "t", ".", "getTSData", "(", ")", ".", "getCurrentCollection", "(", ")", ".", "get", "(", "this", "::", "match", ",", ...
Create a stream of TimeSeriesMetricDeltas with values.
[ "Create", "a", "stream", "of", "TimeSeriesMetricDeltas", "with", "values", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/expr/src/main/java/com/groupon/lex/metrics/MetricMatcher.java#L85-L88
train
threerings/nenya
core/src/main/java/com/threerings/media/image/ColorUtil.java
ColorUtil.blend
public static final Color blend (Color c1, Color c2) { return new Color((c1.getRed() + c2.getRed()) >> 1, (c1.getGreen() + c2.getGreen()) >> 1, (c1.getBlue() + c2.getBlue()) >> 1); }
java
public static final Color blend (Color c1, Color c2) { return new Color((c1.getRed() + c2.getRed()) >> 1, (c1.getGreen() + c2.getGreen()) >> 1, (c1.getBlue() + c2.getBlue()) >> 1); }
[ "public", "static", "final", "Color", "blend", "(", "Color", "c1", ",", "Color", "c2", ")", "{", "return", "new", "Color", "(", "(", "c1", ".", "getRed", "(", ")", "+", "c2", ".", "getRed", "(", ")", ")", ">>", "1", ",", "(", "c1", ".", "getGre...
Blends the two supplied colors. @return a color halfway between the two colors.
[ "Blends", "the", "two", "supplied", "colors", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ColorUtil.java#L34-L39
train
threerings/nenya
core/src/main/java/com/threerings/media/image/ColorUtil.java
ColorUtil.blend
public static final Color blend (Color c1, Color c2, float firstperc) { float p2 = 1.0f - firstperc; return new Color((int) (c1.getRed() * firstperc + c2.getRed() * p2), (int) (c1.getGreen() * firstperc + c2.getGreen() * p2), (int) (c1.getBlue() * firstperc + c2.getBlue() * p2)); }
java
public static final Color blend (Color c1, Color c2, float firstperc) { float p2 = 1.0f - firstperc; return new Color((int) (c1.getRed() * firstperc + c2.getRed() * p2), (int) (c1.getGreen() * firstperc + c2.getGreen() * p2), (int) (c1.getBlue() * firstperc + c2.getBlue() * p2)); }
[ "public", "static", "final", "Color", "blend", "(", "Color", "c1", ",", "Color", "c2", ",", "float", "firstperc", ")", "{", "float", "p2", "=", "1.0f", "-", "firstperc", ";", "return", "new", "Color", "(", "(", "int", ")", "(", "c1", ".", "getRed", ...
Blends the two supplied colors, using the supplied percentage as the amount of the first color to use. @param firstperc The percentage of the first color to use, from 0.0f to 1.0f inclusive.
[ "Blends", "the", "two", "supplied", "colors", "using", "the", "supplied", "percentage", "as", "the", "amount", "of", "the", "first", "color", "to", "use", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ColorUtil.java#L48-L54
train
jdillon/gshell
gshell-core/src/main/java/com/planet57/gshell/MainSupport.java
MainSupport.setupLogging
protected void setupLogging(@Nullable final Level level) { // install JUL adapter SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); // conifgure gossip bootstrap loggers with target factory Log.configure(LoggerFactory.getILoggerFactory()); log.debug("Logging setup; level: {}", level); }
java
protected void setupLogging(@Nullable final Level level) { // install JUL adapter SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); // conifgure gossip bootstrap loggers with target factory Log.configure(LoggerFactory.getILoggerFactory()); log.debug("Logging setup; level: {}", level); }
[ "protected", "void", "setupLogging", "(", "@", "Nullable", "final", "Level", "level", ")", "{", "// install JUL adapter", "SLF4JBridgeHandler", ".", "removeHandlersForRootLogger", "(", ")", ";", "SLF4JBridgeHandler", ".", "install", "(", ")", ";", "// conifgure gossip...
Setup logging environment.
[ "Setup", "logging", "environment", "." ]
b587c1a4672d2e4905871462fa3b38a1f7b94e90
https://github.com/jdillon/gshell/blob/b587c1a4672d2e4905871462fa3b38a1f7b94e90/gshell-core/src/main/java/com/planet57/gshell/MainSupport.java#L258-L266
train
threerings/nenya
core/src/main/java/com/threerings/media/animation/AnimationWaiter.java
AnimationWaiter.addAnimations
public void addAnimations (Animation[] anims) { int acount = anims.length; for (int ii = 0; ii < acount; ii++) { addAnimation(anims[ii]); } }
java
public void addAnimations (Animation[] anims) { int acount = anims.length; for (int ii = 0; ii < acount; ii++) { addAnimation(anims[ii]); } }
[ "public", "void", "addAnimations", "(", "Animation", "[", "]", "anims", ")", "{", "int", "acount", "=", "anims", ".", "length", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "acount", ";", "ii", "++", ")", "{", "addAnimation", "(", "anims...
Adds the supplied animations to the animation waiter for observation.
[ "Adds", "the", "supplied", "animations", "to", "the", "animation", "waiter", "for", "observation", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/animation/AnimationWaiter.java#L45-L51
train
threerings/nenya
core/src/main/java/com/threerings/openal/SoundManager.java
SoundManager.createSoundManager
public static SoundManager createSoundManager (RunQueue rqueue) { if (_soundmgr != null) { throw new IllegalStateException("A sound manager has already been created."); } _soundmgr = new SoundManager(rqueue); return _soundmgr; }
java
public static SoundManager createSoundManager (RunQueue rqueue) { if (_soundmgr != null) { throw new IllegalStateException("A sound manager has already been created."); } _soundmgr = new SoundManager(rqueue); return _soundmgr; }
[ "public", "static", "SoundManager", "createSoundManager", "(", "RunQueue", "rqueue", ")", "{", "if", "(", "_soundmgr", "!=", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"A sound manager has already been created.\"", ")", ";", "}", "_soundmgr", ...
Creates, initializes and returns the singleton sound manager instance. @param rqueue a queue that the sound manager can use to post short runnables that must be executed on the same thread from which all other sound methods will be called.
[ "Creates", "initializes", "and", "returns", "the", "singleton", "sound", "manager", "instance", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/SoundManager.java#L66-L73
train
threerings/nenya
core/src/main/java/com/threerings/openal/SoundManager.java
SoundManager.updateStreams
public void updateStreams (float time) { // iterate backwards through the list so that streams can dispose of themselves during // their update for (int ii = _streams.size() - 1; ii >= 0; ii--) { _streams.get(ii).update(time); } // delete any finalized objects deleteFinalizedObjects(); }
java
public void updateStreams (float time) { // iterate backwards through the list so that streams can dispose of themselves during // their update for (int ii = _streams.size() - 1; ii >= 0; ii--) { _streams.get(ii).update(time); } // delete any finalized objects deleteFinalizedObjects(); }
[ "public", "void", "updateStreams", "(", "float", "time", ")", "{", "// iterate backwards through the list so that streams can dispose of themselves during", "// their update", "for", "(", "int", "ii", "=", "_streams", ".", "size", "(", ")", "-", "1", ";", "ii", ">=", ...
Updates all of the streams controlled by the manager. This should be called once per frame by the application. @param time the number of seconds elapsed since the last update
[ "Updates", "all", "of", "the", "streams", "controlled", "by", "the", "manager", ".", "This", "should", "be", "called", "once", "per", "frame", "by", "the", "application", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/SoundManager.java#L166-L176
train
threerings/nenya
core/src/main/java/com/threerings/openal/SoundManager.java
SoundManager.loadClip
public void loadClip (ClipProvider provider, String path, Observer observer) { getClip(provider, path, observer); }
java
public void loadClip (ClipProvider provider, String path, Observer observer) { getClip(provider, path, observer); }
[ "public", "void", "loadClip", "(", "ClipProvider", "provider", ",", "String", "path", ",", "Observer", "observer", ")", "{", "getClip", "(", "provider", ",", "path", ",", "observer", ")", ";", "}" ]
Loads a clip buffer for the sound clip loaded via the specified provider with the specified path. The loaded clip is placed in the cache.
[ "Loads", "a", "clip", "buffer", "for", "the", "sound", "clip", "loaded", "via", "the", "specified", "provider", "with", "the", "specified", "path", ".", "The", "loaded", "clip", "is", "placed", "in", "the", "cache", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/SoundManager.java#L191-L194
train
threerings/nenya
core/src/main/java/com/threerings/openal/SoundManager.java
SoundManager.deleteFinalizedObjects
protected synchronized void deleteFinalizedObjects () { if (_finalizedSources != null) { IntBuffer idbuf = BufferUtils.createIntBuffer(_finalizedSources.length); idbuf.put(_finalizedSources).rewind(); AL10.alDeleteSources(idbuf); _finalizedSources = null; } if (_finalizedBuffers != null) { IntBuffer idbuf = BufferUtils.createIntBuffer(_finalizedBuffers.length); idbuf.put(_finalizedBuffers).rewind(); AL10.alDeleteBuffers(idbuf); _finalizedBuffers = null; } }
java
protected synchronized void deleteFinalizedObjects () { if (_finalizedSources != null) { IntBuffer idbuf = BufferUtils.createIntBuffer(_finalizedSources.length); idbuf.put(_finalizedSources).rewind(); AL10.alDeleteSources(idbuf); _finalizedSources = null; } if (_finalizedBuffers != null) { IntBuffer idbuf = BufferUtils.createIntBuffer(_finalizedBuffers.length); idbuf.put(_finalizedBuffers).rewind(); AL10.alDeleteBuffers(idbuf); _finalizedBuffers = null; } }
[ "protected", "synchronized", "void", "deleteFinalizedObjects", "(", ")", "{", "if", "(", "_finalizedSources", "!=", "null", ")", "{", "IntBuffer", "idbuf", "=", "BufferUtils", ".", "createIntBuffer", "(", "_finalizedSources", ".", "length", ")", ";", "idbuf", "....
Deletes all finalized objects.
[ "Deletes", "all", "finalized", "objects", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/SoundManager.java#L369-L383
train
threerings/nenya
core/src/main/java/com/threerings/media/animation/FloatingTextAnimation.java
FloatingTextAnimation.paintLabels
protected void paintLabels (Graphics2D gfx, int x, int y) { _label.render(gfx, x, y); }
java
protected void paintLabels (Graphics2D gfx, int x, int y) { _label.render(gfx, x, y); }
[ "protected", "void", "paintLabels", "(", "Graphics2D", "gfx", ",", "int", "x", ",", "int", "y", ")", "{", "_label", ".", "render", "(", "gfx", ",", "x", ",", "y", ")", ";", "}" ]
Derived classes may wish to extend score animation and render more than just the standard single label. @param x the upper left coordinate of the animation. @param y the upper left coordinate of the animation.
[ "Derived", "classes", "may", "wish", "to", "extend", "score", "animation", "and", "render", "more", "than", "just", "the", "standard", "single", "label", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/animation/FloatingTextAnimation.java#L195-L198
train
ckpoint/CheckPoint
src/main/java/hsim/checkpoint/core/store/ValidationDataGroup.java
ValidationDataGroup.addRule
public void addRule(ValidationData vd) { this.rules.addAll(vd.getValidationRules().stream().filter(vr -> vr.isUse()).collect(Collectors.toList())); }
java
public void addRule(ValidationData vd) { this.rules.addAll(vd.getValidationRules().stream().filter(vr -> vr.isUse()).collect(Collectors.toList())); }
[ "public", "void", "addRule", "(", "ValidationData", "vd", ")", "{", "this", ".", "rules", ".", "addAll", "(", "vd", ".", "getValidationRules", "(", ")", ".", "stream", "(", ")", ".", "filter", "(", "vr", "->", "vr", ".", "isUse", "(", ")", ")", "."...
Add rule. @param vd the vd
[ "Add", "rule", "." ]
2c2b1a87a88485d49ea6afa34acdf16ef4134f19
https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/store/ValidationDataGroup.java#L36-L38
train
ckpoint/CheckPoint
src/main/java/hsim/checkpoint/core/store/ValidationDataGroup.java
ValidationDataGroup.initDataGroup
public void initDataGroup(ParamType paramType, List<ValidationData> lists) { this.paramType = paramType; lists.forEach(vd -> { this.addRule(vd); }); }
java
public void initDataGroup(ParamType paramType, List<ValidationData> lists) { this.paramType = paramType; lists.forEach(vd -> { this.addRule(vd); }); }
[ "public", "void", "initDataGroup", "(", "ParamType", "paramType", ",", "List", "<", "ValidationData", ">", "lists", ")", "{", "this", ".", "paramType", "=", "paramType", ";", "lists", ".", "forEach", "(", "vd", "->", "{", "this", ".", "addRule", "(", "vd...
Init data group. @param paramType the param type @param lists the lists
[ "Init", "data", "group", "." ]
2c2b1a87a88485d49ea6afa34acdf16ef4134f19
https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/store/ValidationDataGroup.java#L46-L53
train
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor
MapCore/src/main/java/org/wwarn/mapcore/client/components/customwidgets/map/GoogleV3MapWidget.java
GoogleV3MapWidget.addMapZoomEndHandler
@Override public HandlerRegistration addMapZoomEndHandler(final Runnable zoomHandler){ return mapWidget.addZoomChangeHandler(zoomChangeMapEvent -> zoomHandler.run()); }
java
@Override public HandlerRegistration addMapZoomEndHandler(final Runnable zoomHandler){ return mapWidget.addZoomChangeHandler(zoomChangeMapEvent -> zoomHandler.run()); }
[ "@", "Override", "public", "HandlerRegistration", "addMapZoomEndHandler", "(", "final", "Runnable", "zoomHandler", ")", "{", "return", "mapWidget", ".", "addZoomChangeHandler", "(", "zoomChangeMapEvent", "->", "zoomHandler", ".", "run", "(", ")", ")", ";", "}" ]
Add zoom handler, event is not exposed at present @param zoomHandler runnable zoom handler
[ "Add", "zoom", "handler", "event", "is", "not", "exposed", "at", "present" ]
224280bcd6e8045bda6b673584caf0aea5e4c841
https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/MapCore/src/main/java/org/wwarn/mapcore/client/components/customwidgets/map/GoogleV3MapWidget.java#L215-L218
train
OpenCompare/OpenCompare
org.opencompare/pcmdata-importers/src/main/java/JSONformating/model/JProduct.java
JProduct.sameProduct
public boolean sameProduct(JProduct p, Map<String, String> featLinks, boolean exactContent) { List<JCell> tempCells = new ArrayList<>(this.cells); if(p.getCells().size() != this.cells.size()){ return false; } for(JCell pC : p.getCells()){ for(JCell thisC: this.cells){ if(tempCells.contains(thisC)){ if(thisC.sameCell(pC, featLinks, exactContent)){ tempCells.remove(thisC); } } } } // if(tempCells.isEmpty()){ // System.out.println(id); // } return tempCells.isEmpty(); }
java
public boolean sameProduct(JProduct p, Map<String, String> featLinks, boolean exactContent) { List<JCell> tempCells = new ArrayList<>(this.cells); if(p.getCells().size() != this.cells.size()){ return false; } for(JCell pC : p.getCells()){ for(JCell thisC: this.cells){ if(tempCells.contains(thisC)){ if(thisC.sameCell(pC, featLinks, exactContent)){ tempCells.remove(thisC); } } } } // if(tempCells.isEmpty()){ // System.out.println(id); // } return tempCells.isEmpty(); }
[ "public", "boolean", "sameProduct", "(", "JProduct", "p", ",", "Map", "<", "String", ",", "String", ">", "featLinks", ",", "boolean", "exactContent", ")", "{", "List", "<", "JCell", ">", "tempCells", "=", "new", "ArrayList", "<>", "(", "this", ".", "cell...
Compares cells of both products omitting ids @param p the product to compare @param featLinks the links between the features of the 2 JSONFormat objects @param exactContent @return true if cells of both products are the same, omits ids
[ "Compares", "cells", "of", "both", "products", "omitting", "ids" ]
6cd776466b375cb8ecca08fcd94e573d65e20b14
https://github.com/OpenCompare/OpenCompare/blob/6cd776466b375cb8ecca08fcd94e573d65e20b14/org.opencompare/pcmdata-importers/src/main/java/JSONformating/model/JProduct.java#L34-L52
train
ckpoint/CheckPoint
src/main/java/hsim/checkpoint/util/AnnotationUtil.java
AnnotationUtil.getAnnotation
public static Annotation getAnnotation(Annotation[] annotations, Class<?> annotationClass) { return Arrays.stream(annotations).filter(annotation -> annotation.annotationType().equals(annotationClass)).findFirst().orElse(null); }
java
public static Annotation getAnnotation(Annotation[] annotations, Class<?> annotationClass) { return Arrays.stream(annotations).filter(annotation -> annotation.annotationType().equals(annotationClass)).findFirst().orElse(null); }
[ "public", "static", "Annotation", "getAnnotation", "(", "Annotation", "[", "]", "annotations", ",", "Class", "<", "?", ">", "annotationClass", ")", "{", "return", "Arrays", ".", "stream", "(", "annotations", ")", ".", "filter", "(", "annotation", "->", "anno...
Gets annotation. @param annotations the annotations @param annotationClass the annotation class @return the annotation
[ "Gets", "annotation", "." ]
2c2b1a87a88485d49ea6afa34acdf16ef4134f19
https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/AnnotationUtil.java#L18-L20
train
ckpoint/CheckPoint
src/main/java/hsim/checkpoint/core/store/ValidationStore.java
ValidationStore.getValidationDatas
public List<ValidationData> getValidationDatas(ParamType paramType, String key) { if (this.urlMap == null || this.validationDataRuleListMap == null) { log.info("url map is empty :: " + key ); return null; } if (key == null || paramType == null) { throw new ValidationLibException("any parameter is null", HttpStatus.INTERNAL_SERVER_ERROR); } ReqUrl reqUrl = urlMap.get(key); if (reqUrl == null) { log.info("reqUrl is null :" + key); return null; } return validationDataRuleListMap.get(paramType.getUniqueKey(reqUrl.getUniqueKey())); }
java
public List<ValidationData> getValidationDatas(ParamType paramType, String key) { if (this.urlMap == null || this.validationDataRuleListMap == null) { log.info("url map is empty :: " + key ); return null; } if (key == null || paramType == null) { throw new ValidationLibException("any parameter is null", HttpStatus.INTERNAL_SERVER_ERROR); } ReqUrl reqUrl = urlMap.get(key); if (reqUrl == null) { log.info("reqUrl is null :" + key); return null; } return validationDataRuleListMap.get(paramType.getUniqueKey(reqUrl.getUniqueKey())); }
[ "public", "List", "<", "ValidationData", ">", "getValidationDatas", "(", "ParamType", "paramType", ",", "String", "key", ")", "{", "if", "(", "this", ".", "urlMap", "==", "null", "||", "this", ".", "validationDataRuleListMap", "==", "null", ")", "{", "log", ...
Gets validation datas. @param paramType the param type @param key the key @return the validation datas
[ "Gets", "validation", "datas", "." ]
2c2b1a87a88485d49ea6afa34acdf16ef4134f19
https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/store/ValidationStore.java#L83-L100
train
ckpoint/CheckPoint
src/main/java/hsim/checkpoint/core/component/validationRule/rule/AssistType.java
AssistType.all
public static AssistType all() { AssistType assistType = new AssistType(); assistType.nullable = true; assistType.string = true; assistType.number = true; assistType.enumType = true; assistType.list = true; assistType.obj = true; return assistType; }
java
public static AssistType all() { AssistType assistType = new AssistType(); assistType.nullable = true; assistType.string = true; assistType.number = true; assistType.enumType = true; assistType.list = true; assistType.obj = true; return assistType; }
[ "public", "static", "AssistType", "all", "(", ")", "{", "AssistType", "assistType", "=", "new", "AssistType", "(", ")", ";", "assistType", ".", "nullable", "=", "true", ";", "assistType", ".", "string", "=", "true", ";", "assistType", ".", "number", "=", ...
All assist type. @return the assist type
[ "All", "assist", "type", "." ]
2c2b1a87a88485d49ea6afa34acdf16ef4134f19
https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/component/validationRule/rule/AssistType.java#L24-L33
train
ckpoint/CheckPoint
src/main/java/hsim/checkpoint/core/component/DetailParam.java
DetailParam.getReqUrls
public List<ReqUrl> getReqUrls() { String url = this.getClassMappingUrl(this.getParentClass()); RequestAnnotation requestAnnotation = new RequestAnnotation(this.getParentMethod()); url += this.getRequestMappingUrl(requestAnnotation.getValue()); List<ReqUrl> list = new ArrayList<>(); for (RequestMethod requestMethod : requestAnnotation.getMethod()) { list.add(new ReqUrl(requestMethod.name(), url)); } return list; }
java
public List<ReqUrl> getReqUrls() { String url = this.getClassMappingUrl(this.getParentClass()); RequestAnnotation requestAnnotation = new RequestAnnotation(this.getParentMethod()); url += this.getRequestMappingUrl(requestAnnotation.getValue()); List<ReqUrl> list = new ArrayList<>(); for (RequestMethod requestMethod : requestAnnotation.getMethod()) { list.add(new ReqUrl(requestMethod.name(), url)); } return list; }
[ "public", "List", "<", "ReqUrl", ">", "getReqUrls", "(", ")", "{", "String", "url", "=", "this", ".", "getClassMappingUrl", "(", "this", ".", "getParentClass", "(", ")", ")", ";", "RequestAnnotation", "requestAnnotation", "=", "new", "RequestAnnotation", "(", ...
Gets req urls. @return the req urls
[ "Gets", "req", "urls", "." ]
2c2b1a87a88485d49ea6afa34acdf16ef4134f19
https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/component/DetailParam.java#L78-L91
train
OpenCompare/OpenCompare
org.opencompare/pcmdata-importers/src/main/java/JSONformating/model/JSONFormat.java
JSONFormat.sameJSONFormat
public boolean sameJSONFormat(JSONFormat jf){ Map<String,String> featLinks = new HashMap<>(); if(!this.name.equals(jf.name) || !this.creator.equals(jf.creator) || !this.license.equals(jf.license) || !this.source.equals(jf.source)){ return false; }else if(!this.sameFeatures(jf, featLinks)){ System.out.println("\nDifferences in features"); return false; }else if(!this.sameProducts(jf, featLinks, false)){ System.out.println("\nDifferences in products"); return false; } return true; }
java
public boolean sameJSONFormat(JSONFormat jf){ Map<String,String> featLinks = new HashMap<>(); if(!this.name.equals(jf.name) || !this.creator.equals(jf.creator) || !this.license.equals(jf.license) || !this.source.equals(jf.source)){ return false; }else if(!this.sameFeatures(jf, featLinks)){ System.out.println("\nDifferences in features"); return false; }else if(!this.sameProducts(jf, featLinks, false)){ System.out.println("\nDifferences in products"); return false; } return true; }
[ "public", "boolean", "sameJSONFormat", "(", "JSONFormat", "jf", ")", "{", "Map", "<", "String", ",", "String", ">", "featLinks", "=", "new", "HashMap", "<>", "(", ")", ";", "if", "(", "!", "this", ".", "name", ".", "equals", "(", "jf", ".", "name", ...
Checks if the JSONFormat in parameter is the same as this, omitting ids and jcell.jvalue.value content @param jf the format to compare @return true if this and jf are the same, omits ids
[ "Checks", "if", "the", "JSONFormat", "in", "parameter", "is", "the", "same", "as", "this", "omitting", "ids", "and", "jcell", ".", "jvalue", ".", "value", "content" ]
6cd776466b375cb8ecca08fcd94e573d65e20b14
https://github.com/OpenCompare/OpenCompare/blob/6cd776466b375cb8ecca08fcd94e573d65e20b14/org.opencompare/pcmdata-importers/src/main/java/JSONformating/model/JSONFormat.java#L395-L407
train
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor
SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/DefaultLocalJSONDataProvider.java
DefaultLocalJSONDataProvider.validateFacetFields
private void validateFacetFields(String[] facetFieldList) { if(facetFieldList == null || facetFieldList.length == 0){ return; } for (String facetfield : facetFieldList){ if(schema.getColumnIndex(facetfield) < 0){ throw new IllegalArgumentException("Facet field:"+facetfield+", not found in schema"); } } }
java
private void validateFacetFields(String[] facetFieldList) { if(facetFieldList == null || facetFieldList.length == 0){ return; } for (String facetfield : facetFieldList){ if(schema.getColumnIndex(facetfield) < 0){ throw new IllegalArgumentException("Facet field:"+facetfield+", not found in schema"); } } }
[ "private", "void", "validateFacetFields", "(", "String", "[", "]", "facetFieldList", ")", "{", "if", "(", "facetFieldList", "==", "null", "||", "facetFieldList", ".", "length", "==", "0", ")", "{", "return", ";", "}", "for", "(", "String", "facetfield", ":...
Check each facet field is present in schema. @param facetFieldList an array of facet fields
[ "Check", "each", "facet", "field", "is", "present", "in", "schema", "." ]
224280bcd6e8045bda6b673584caf0aea5e4c841
https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/DefaultLocalJSONDataProvider.java#L136-L146
train
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor
SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/DefaultLocalJSONDataProvider.java
DefaultLocalJSONDataProvider.calculateFacetList
private FacetList calculateFacetList(AbstractDataTable table, String[] facetFields) { if(facetFields == null || facetFields.length == 0){ throw new NullPointerException("Facet field list empty"); } FacetList facetList = new FacetList(); for (String facetField : facetFields) { Set<String> distinctColumnValues = dataTableExtensions.getDistinctColumnValues(table, schema.getColumnIndex(facetField)); facetList.addFacetField(facetField, distinctColumnValues); } return facetList; }
java
private FacetList calculateFacetList(AbstractDataTable table, String[] facetFields) { if(facetFields == null || facetFields.length == 0){ throw new NullPointerException("Facet field list empty"); } FacetList facetList = new FacetList(); for (String facetField : facetFields) { Set<String> distinctColumnValues = dataTableExtensions.getDistinctColumnValues(table, schema.getColumnIndex(facetField)); facetList.addFacetField(facetField, distinctColumnValues); } return facetList; }
[ "private", "FacetList", "calculateFacetList", "(", "AbstractDataTable", "table", ",", "String", "[", "]", "facetFields", ")", "{", "if", "(", "facetFields", "==", "null", "||", "facetFields", ".", "length", "==", "0", ")", "{", "throw", "new", "NullPointerExce...
facet field -> list of facet field values @param table gwt datatable as internal table data source @param facetFields list of field to calculate facet values for
[ "facet", "field", "-", ">", "list", "of", "facet", "field", "values" ]
224280bcd6e8045bda6b673584caf0aea5e4c841
https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/DefaultLocalJSONDataProvider.java#L304-L314
train
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor
SurveyorCore/src/main/java/org/wwarn/surveyor/client/mvp/SimpleClientFactory.java
SimpleClientFactory.getDataProvider
public DataProvider getDataProvider(){ if(this.dataProvider == null){ // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getDataProvider", "begin"); // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getSchema", "begin"); DataSchema schema = getSchema(); // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getSchema", "end"); // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getFacetFieldList", "begin"); String[] facetFieldList = getFacetFieldList(); // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getFacetFieldList", "end"); // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "DefaultLocalJSONDataProvider", "begin"); final ApplicationContext applicationContext1 = getApplicationContext(); final DatasourceConfig config = applicationContext1.getConfig(DatasourceConfig.class); GenericDataSource dataSource = new GenericDataSource(config.getFilename(), null, GenericDataSource.DataSourceType.ServletRelativeDataSource); switch (config.getDataSourceProvider()){ case ClientSideSearchDataProvider: dataSource.setDataSourceProvider(DataSourceProvider.ClientSideSearchDataProvider); this.dataProvider = new ClientSideSearchDataProvider(dataSource, schema, facetFieldList); break; case ServerSideLuceneDataProvider: dataSource.setDataSourceProvider(DataSourceProvider.ServerSideLuceneDataProvider); this.dataProvider = new ServerSideSearchDataProvider(dataSource, schema, facetFieldList); break; case GoogleAppEngineLuceneDataSource: dataSource.setDataSourceProvider(DataSourceProvider.GoogleAppEngineLuceneDataSource); this.dataProvider = new ServerSideSearchDataProvider(dataSource, schema, facetFieldList); break; case LocalClientSideDataProvider: default: dataSource.setDataSourceProvider(DataSourceProvider.LocalClientSideDataProvider); this.dataProvider = new DefaultLocalJSONDataProvider(dataSource, schema, facetFieldList); break; } // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "DefaultLocalJSONDataProvider", "end"); // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getDataProvider", "end"); } return this.dataProvider; }
java
public DataProvider getDataProvider(){ if(this.dataProvider == null){ // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getDataProvider", "begin"); // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getSchema", "begin"); DataSchema schema = getSchema(); // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getSchema", "end"); // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getFacetFieldList", "begin"); String[] facetFieldList = getFacetFieldList(); // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getFacetFieldList", "end"); // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "DefaultLocalJSONDataProvider", "begin"); final ApplicationContext applicationContext1 = getApplicationContext(); final DatasourceConfig config = applicationContext1.getConfig(DatasourceConfig.class); GenericDataSource dataSource = new GenericDataSource(config.getFilename(), null, GenericDataSource.DataSourceType.ServletRelativeDataSource); switch (config.getDataSourceProvider()){ case ClientSideSearchDataProvider: dataSource.setDataSourceProvider(DataSourceProvider.ClientSideSearchDataProvider); this.dataProvider = new ClientSideSearchDataProvider(dataSource, schema, facetFieldList); break; case ServerSideLuceneDataProvider: dataSource.setDataSourceProvider(DataSourceProvider.ServerSideLuceneDataProvider); this.dataProvider = new ServerSideSearchDataProvider(dataSource, schema, facetFieldList); break; case GoogleAppEngineLuceneDataSource: dataSource.setDataSourceProvider(DataSourceProvider.GoogleAppEngineLuceneDataSource); this.dataProvider = new ServerSideSearchDataProvider(dataSource, schema, facetFieldList); break; case LocalClientSideDataProvider: default: dataSource.setDataSourceProvider(DataSourceProvider.LocalClientSideDataProvider); this.dataProvider = new DefaultLocalJSONDataProvider(dataSource, schema, facetFieldList); break; } // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "DefaultLocalJSONDataProvider", "end"); // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getDataProvider", "end"); } return this.dataProvider; }
[ "public", "DataProvider", "getDataProvider", "(", ")", "{", "if", "(", "this", ".", "dataProvider", "==", "null", ")", "{", "// EventLogger.logEvent(\"org.wwarn.surveyor.client.mvp.SimpleClientFactory\", \"getDataProvider\", \"begin\");", "// EventLogger.logEven...
Lazy initialise Dataprovider @return DataProvider
[ "Lazy", "initialise", "Dataprovider" ]
224280bcd6e8045bda6b673584caf0aea5e4c841
https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/SurveyorCore/src/main/java/org/wwarn/surveyor/client/mvp/SimpleClientFactory.java#L99-L139
train
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor
SurveyorCore/src/main/java/org/wwarn/surveyor/client/mvp/SimpleClientFactory.java
SimpleClientFactory.setConfigDynamically
@Override public void setConfigDynamically(Config viewConfig) { if(viewConfig instanceof MapViewConfig) { MapViewConfig newMapViewConfig = (MapViewConfig) viewConfig; updateMapViewConfig(newMapViewConfig); } }
java
@Override public void setConfigDynamically(Config viewConfig) { if(viewConfig instanceof MapViewConfig) { MapViewConfig newMapViewConfig = (MapViewConfig) viewConfig; updateMapViewConfig(newMapViewConfig); } }
[ "@", "Override", "public", "void", "setConfigDynamically", "(", "Config", "viewConfig", ")", "{", "if", "(", "viewConfig", "instanceof", "MapViewConfig", ")", "{", "MapViewConfig", "newMapViewConfig", "=", "(", "MapViewConfig", ")", "viewConfig", ";", "updateMapView...
This method configures dynamically any config in the xml. Right now, only overrides the coordinates of the map but it could be use to override any configuration @param viewConfig
[ "This", "method", "configures", "dynamically", "any", "config", "in", "the", "xml", ".", "Right", "now", "only", "overrides", "the", "coordinates", "of", "the", "map", "but", "it", "could", "be", "use", "to", "override", "any", "configuration" ]
224280bcd6e8045bda6b673584caf0aea5e4c841
https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/SurveyorCore/src/main/java/org/wwarn/surveyor/client/mvp/SimpleClientFactory.java#L208-L215
train
ckpoint/CheckPoint
src/main/java/hsim/checkpoint/setting/session/ValidationSessionComponent.java
ValidationSessionComponent.sessionCheck
public void sessionCheck(HttpServletRequest req) { String authHeader = req.getHeader("Authorization"); if (authHeader != null && this.validationSessionCheck(authHeader)) { return; } if (req.getCookies() != null) { Cookie cookie = Arrays.stream(req.getCookies()).filter(ck -> ck.getName().equals("AuthToken")).findFirst().orElse(null); if (cookie != null && this.validationSessionCheck(cookie.getValue())) { return; } } if ( req.getParameter("token") != null){ String token = req.getParameter("token"); if(this.validationSessionCheck(token)){ return; } } throw new ValidationLibException("UnAuthorization", HttpStatus.UNAUTHORIZED); }
java
public void sessionCheck(HttpServletRequest req) { String authHeader = req.getHeader("Authorization"); if (authHeader != null && this.validationSessionCheck(authHeader)) { return; } if (req.getCookies() != null) { Cookie cookie = Arrays.stream(req.getCookies()).filter(ck -> ck.getName().equals("AuthToken")).findFirst().orElse(null); if (cookie != null && this.validationSessionCheck(cookie.getValue())) { return; } } if ( req.getParameter("token") != null){ String token = req.getParameter("token"); if(this.validationSessionCheck(token)){ return; } } throw new ValidationLibException("UnAuthorization", HttpStatus.UNAUTHORIZED); }
[ "public", "void", "sessionCheck", "(", "HttpServletRequest", "req", ")", "{", "String", "authHeader", "=", "req", ".", "getHeader", "(", "\"Authorization\"", ")", ";", "if", "(", "authHeader", "!=", "null", "&&", "this", ".", "validationSessionCheck", "(", "au...
Session check. @param req the req
[ "Session", "check", "." ]
2c2b1a87a88485d49ea6afa34acdf16ef4134f19
https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/setting/session/ValidationSessionComponent.java#L53-L74
train
ckpoint/CheckPoint
src/main/java/hsim/checkpoint/setting/session/ValidationSessionComponent.java
ValidationSessionComponent.checkAuth
public ValidationSessionInfo checkAuth(ValidationLoginInfo info, HttpServletRequest req, HttpServletResponse res) { if (info.getToken() == null || info.getToken().isEmpty()) { throw new ValidationLibException("UnAuthorization", HttpStatus.UNAUTHORIZED); } if (this.validationConfig.getAuthToken() == null) { throw new ValidationLibException("Sever authkey is not helper ", HttpStatus.INTERNAL_SERVER_ERROR); } if (validaitonSessionCheckAndRemake(info.getToken())) { return this.createSession(req, res); } if (!this.validationConfig.getAuthToken().equals(info.getToken())) { throw new ValidationLibException("UnAuthorization", HttpStatus.UNAUTHORIZED); } req.getSession(); return this.createSession(req, res); }
java
public ValidationSessionInfo checkAuth(ValidationLoginInfo info, HttpServletRequest req, HttpServletResponse res) { if (info.getToken() == null || info.getToken().isEmpty()) { throw new ValidationLibException("UnAuthorization", HttpStatus.UNAUTHORIZED); } if (this.validationConfig.getAuthToken() == null) { throw new ValidationLibException("Sever authkey is not helper ", HttpStatus.INTERNAL_SERVER_ERROR); } if (validaitonSessionCheckAndRemake(info.getToken())) { return this.createSession(req, res); } if (!this.validationConfig.getAuthToken().equals(info.getToken())) { throw new ValidationLibException("UnAuthorization", HttpStatus.UNAUTHORIZED); } req.getSession(); return this.createSession(req, res); }
[ "public", "ValidationSessionInfo", "checkAuth", "(", "ValidationLoginInfo", "info", ",", "HttpServletRequest", "req", ",", "HttpServletResponse", "res", ")", "{", "if", "(", "info", ".", "getToken", "(", ")", "==", "null", "||", "info", ".", "getToken", "(", "...
Check auth validation session info. @param info the info @param req the req @param res the res @return the validation session info
[ "Check", "auth", "validation", "session", "info", "." ]
2c2b1a87a88485d49ea6afa34acdf16ef4134f19
https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/setting/session/ValidationSessionComponent.java#L84-L103
train
ckpoint/CheckPoint
src/main/java/hsim/checkpoint/setting/session/ValidationSessionComponent.java
ValidationSessionComponent.createSession
public ValidationSessionInfo createSession(HttpServletRequest req, HttpServletResponse res) { String key = this.getSessionKey(); ValidationSessionInfo sessionInfo = new ValidationSessionInfo(req, key); this.sessionMap.put(key, sessionInfo); res.addCookie(new Cookie("AuthToken", key)); return sessionInfo; }
java
public ValidationSessionInfo createSession(HttpServletRequest req, HttpServletResponse res) { String key = this.getSessionKey(); ValidationSessionInfo sessionInfo = new ValidationSessionInfo(req, key); this.sessionMap.put(key, sessionInfo); res.addCookie(new Cookie("AuthToken", key)); return sessionInfo; }
[ "public", "ValidationSessionInfo", "createSession", "(", "HttpServletRequest", "req", ",", "HttpServletResponse", "res", ")", "{", "String", "key", "=", "this", ".", "getSessionKey", "(", ")", ";", "ValidationSessionInfo", "sessionInfo", "=", "new", "ValidationSession...
Create session validation session info. @param req the req @param res the res @return the validation session info
[ "Create", "session", "validation", "session", "info", "." ]
2c2b1a87a88485d49ea6afa34acdf16ef4134f19
https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/setting/session/ValidationSessionComponent.java#L122-L128
train
ckpoint/CheckPoint
src/main/java/hsim/checkpoint/setting/session/ValidationSessionComponent.java
ValidationSessionComponent.getSession
public Object getSession(HttpServletRequest req) { if (req.getCookies() == null) { return null; } Cookie cookie = Arrays.stream(req.getCookies()).filter(c -> c.getName().equalsIgnoreCase("ValidationSession")).findFirst().orElse(null); if (cookie == null) { return null; } return this.sessionMap.get(cookie.getValue()); }
java
public Object getSession(HttpServletRequest req) { if (req.getCookies() == null) { return null; } Cookie cookie = Arrays.stream(req.getCookies()).filter(c -> c.getName().equalsIgnoreCase("ValidationSession")).findFirst().orElse(null); if (cookie == null) { return null; } return this.sessionMap.get(cookie.getValue()); }
[ "public", "Object", "getSession", "(", "HttpServletRequest", "req", ")", "{", "if", "(", "req", ".", "getCookies", "(", ")", "==", "null", ")", "{", "return", "null", ";", "}", "Cookie", "cookie", "=", "Arrays", ".", "stream", "(", "req", ".", "getCook...
Gets session. @param req the req @return the session
[ "Gets", "session", "." ]
2c2b1a87a88485d49ea6afa34acdf16ef4134f19
https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/setting/session/ValidationSessionComponent.java#L136-L147
train
lightblue-platform/lightblue-client
http/src/main/java/com/redhat/lightblue/client/http/transport/JavaNetHttpTransport.java
JavaNetHttpTransport.response
private String response(HttpURLConnection connection) throws LightblueHttpClientException { try (InputStream responseStream = connection.getInputStream()) { return readResponseStream(responseStream, connection); } catch (IOException e) { return readErrorStream(connection,e); } }
java
private String response(HttpURLConnection connection) throws LightblueHttpClientException { try (InputStream responseStream = connection.getInputStream()) { return readResponseStream(responseStream, connection); } catch (IOException e) { return readErrorStream(connection,e); } }
[ "private", "String", "response", "(", "HttpURLConnection", "connection", ")", "throws", "LightblueHttpClientException", "{", "try", "(", "InputStream", "responseStream", "=", "connection", ".", "getInputStream", "(", ")", ")", "{", "return", "readResponseStream", "(",...
Parses response, whether or not the request was successful, if possible. Reads entire input stream and closes it so the socket knows it is finished and may be put back into a pool for reuse.
[ "Parses", "response", "whether", "or", "not", "the", "request", "was", "successful", "if", "possible", ".", "Reads", "entire", "input", "stream", "and", "closes", "it", "so", "the", "socket", "knows", "it", "is", "finished", "and", "may", "be", "put", "bac...
03790aff34e90d3889f60fd6c603c21a21dc1a40
https://github.com/lightblue-platform/lightblue-client/blob/03790aff34e90d3889f60fd6c603c21a21dc1a40/http/src/main/java/com/redhat/lightblue/client/http/transport/JavaNetHttpTransport.java#L207-L213
train
lightblue-platform/lightblue-client
http/src/main/java/com/redhat/lightblue/client/http/transport/JavaNetHttpTransport.java
JavaNetHttpTransport.readResponseStream
private String readResponseStream(InputStream responseStream, HttpURLConnection connection) throws IOException { LOGGER.debug("Reading response stream"); InputStream decodedStream = responseStream; if (compression == Compression.LZF && "lzf".equals(connection.getHeaderField("Content-Encoding"))) { LOGGER.debug("Decoding lzf"); decodedStream = new LZFInputStream(responseStream); } int contentLength = connection.getContentLength(); if (contentLength == 0) { return ""; } else { return new String(ByteStreams.toByteArray(decodedStream), UTF_8); } }
java
private String readResponseStream(InputStream responseStream, HttpURLConnection connection) throws IOException { LOGGER.debug("Reading response stream"); InputStream decodedStream = responseStream; if (compression == Compression.LZF && "lzf".equals(connection.getHeaderField("Content-Encoding"))) { LOGGER.debug("Decoding lzf"); decodedStream = new LZFInputStream(responseStream); } int contentLength = connection.getContentLength(); if (contentLength == 0) { return ""; } else { return new String(ByteStreams.toByteArray(decodedStream), UTF_8); } }
[ "private", "String", "readResponseStream", "(", "InputStream", "responseStream", ",", "HttpURLConnection", "connection", ")", "throws", "IOException", "{", "LOGGER", ".", "debug", "(", "\"Reading response stream\"", ")", ";", "InputStream", "decodedStream", "=", "respon...
Tries to efficiently allocate the response string if the "Content-Length" header is set.
[ "Tries", "to", "efficiently", "allocate", "the", "response", "string", "if", "the", "Content", "-", "Length", "header", "is", "set", "." ]
03790aff34e90d3889f60fd6c603c21a21dc1a40
https://github.com/lightblue-platform/lightblue-client/blob/03790aff34e90d3889f60fd6c603c21a21dc1a40/http/src/main/java/com/redhat/lightblue/client/http/transport/JavaNetHttpTransport.java#L239-L255
train
needle4j/needle4j
src/main/java/org/needle4j/db/operation/AbstractDBOperation.java
AbstractDBOperation.openConnection
protected void openConnection() throws SQLException { if (connection == null) { try { Class.forName(configuration.getJdbcDriver()); } catch (NullPointerException npe) { throw new RuntimeException("error while lookup jdbc driver class. jdbc driver is not configured.", npe); } catch (ClassNotFoundException e) { throw new RuntimeException("jdbc driver not found", e); } connection = DriverManager.getConnection(configuration.getJdbcUrl(), configuration.getJdbcUser(), configuration.getJdbcPassword()); connection.setAutoCommit(false); } }
java
protected void openConnection() throws SQLException { if (connection == null) { try { Class.forName(configuration.getJdbcDriver()); } catch (NullPointerException npe) { throw new RuntimeException("error while lookup jdbc driver class. jdbc driver is not configured.", npe); } catch (ClassNotFoundException e) { throw new RuntimeException("jdbc driver not found", e); } connection = DriverManager.getConnection(configuration.getJdbcUrl(), configuration.getJdbcUser(), configuration.getJdbcPassword()); connection.setAutoCommit(false); } }
[ "protected", "void", "openConnection", "(", ")", "throws", "SQLException", "{", "if", "(", "connection", "==", "null", ")", "{", "try", "{", "Class", ".", "forName", "(", "configuration", ".", "getJdbcDriver", "(", ")", ")", ";", "}", "catch", "(", "Null...
Establish a connection to the given database. @throws SQLException if a database access error occurs
[ "Establish", "a", "connection", "to", "the", "given", "database", "." ]
55fbcdeed72be5cf26e4404b0fe40282792b51f2
https://github.com/needle4j/needle4j/blob/55fbcdeed72be5cf26e4404b0fe40282792b51f2/src/main/java/org/needle4j/db/operation/AbstractDBOperation.java#L43-L57
train
needle4j/needle4j
src/main/java/org/needle4j/db/operation/AbstractDBOperation.java
AbstractDBOperation.closeConnection
protected void closeConnection() throws SQLException { if (connection != null && !connection.isClosed()) { connection.close(); connection = null; } }
java
protected void closeConnection() throws SQLException { if (connection != null && !connection.isClosed()) { connection.close(); connection = null; } }
[ "protected", "void", "closeConnection", "(", ")", "throws", "SQLException", "{", "if", "(", "connection", "!=", "null", "&&", "!", "connection", ".", "isClosed", "(", ")", ")", "{", "connection", ".", "close", "(", ")", ";", "connection", "=", "null", ";...
Close the connection to the database. @throws SQLException if a database access error occurs
[ "Close", "the", "connection", "to", "the", "database", "." ]
55fbcdeed72be5cf26e4404b0fe40282792b51f2
https://github.com/needle4j/needle4j/blob/55fbcdeed72be5cf26e4404b0fe40282792b51f2/src/main/java/org/needle4j/db/operation/AbstractDBOperation.java#L65-L71
train
needle4j/needle4j
src/main/java/org/needle4j/db/operation/AbstractDBOperation.java
AbstractDBOperation.executeScript
protected void executeScript(final String filename, final Statement statement) throws SQLException { LOG.info("Executing sql script: " + filename); InputStream fileInputStream; try { fileInputStream = ConfigurationLoader.loadResource(filename); } catch (FileNotFoundException e) { LOG.error("could not execute script", e); return; } final BufferedReader reader = new BufferedReader(new InputStreamReader(fileInputStream)); executeScript(reader, statement); }
java
protected void executeScript(final String filename, final Statement statement) throws SQLException { LOG.info("Executing sql script: " + filename); InputStream fileInputStream; try { fileInputStream = ConfigurationLoader.loadResource(filename); } catch (FileNotFoundException e) { LOG.error("could not execute script", e); return; } final BufferedReader reader = new BufferedReader(new InputStreamReader(fileInputStream)); executeScript(reader, statement); }
[ "protected", "void", "executeScript", "(", "final", "String", "filename", ",", "final", "Statement", "statement", ")", "throws", "SQLException", "{", "LOG", ".", "info", "(", "\"Executing sql script: \"", "+", "filename", ")", ";", "InputStream", "fileInputStream", ...
Execute the given sql script. @param filename the filename of the sql script @param statement the {@link Statement} to be used for executing a SQL statement. @throws SQLException if a database access error occurs
[ "Execute", "the", "given", "sql", "script", "." ]
55fbcdeed72be5cf26e4404b0fe40282792b51f2
https://github.com/needle4j/needle4j/blob/55fbcdeed72be5cf26e4404b0fe40282792b51f2/src/main/java/org/needle4j/db/operation/AbstractDBOperation.java#L183-L196
train
reinert/requestor
requestor/core/requestor-api/src/main/java/io/reinert/requestor/SerdesManagerImpl.java
SerdesManagerImpl.register
@SuppressWarnings("unchecked") public <T> HandlerRegistration register(Deserializer<T> deserializer) { final HandlerRegistration reg = bindDeserializerToType(deserializer, deserializer.handledType()); if (deserializer instanceof HasImpl) { Class[] impls = ((HasImpl) deserializer).implTypes(); final HandlerRegistration[] regs = new HandlerRegistration[impls.length + 1]; regs[0] = reg; for (int i = 0; i < impls.length; i++) { Class impl = impls[i]; regs[i + 1] = bindDeserializerToType(deserializer, impl); } return new HandlerRegistration() { public void removeHandler() { for (HandlerRegistration reg : regs) { reg.removeHandler(); } } }; } return reg; }
java
@SuppressWarnings("unchecked") public <T> HandlerRegistration register(Deserializer<T> deserializer) { final HandlerRegistration reg = bindDeserializerToType(deserializer, deserializer.handledType()); if (deserializer instanceof HasImpl) { Class[] impls = ((HasImpl) deserializer).implTypes(); final HandlerRegistration[] regs = new HandlerRegistration[impls.length + 1]; regs[0] = reg; for (int i = 0; i < impls.length; i++) { Class impl = impls[i]; regs[i + 1] = bindDeserializerToType(deserializer, impl); } return new HandlerRegistration() { public void removeHandler() { for (HandlerRegistration reg : regs) { reg.removeHandler(); } } }; } return reg; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "HandlerRegistration", "register", "(", "Deserializer", "<", "T", ">", "deserializer", ")", "{", "final", "HandlerRegistration", "reg", "=", "bindDeserializerToType", "(", "deserializer", ...
Register a deserializer of the given type. @param deserializer The deserializer of T. @param <T> The type of the object to be deserialized. @return The {@link com.google.web.bindery.event.shared.HandlerRegistration} object, capable of cancelling this HandlerRegistration to the {@link SerdesManagerImpl}.
[ "Register", "a", "deserializer", "of", "the", "given", "type", "." ]
40163a75cd17815d5089935d0dd97b8d652ad6d4
https://github.com/reinert/requestor/blob/40163a75cd17815d5089935d0dd97b8d652ad6d4/requestor/core/requestor-api/src/main/java/io/reinert/requestor/SerdesManagerImpl.java#L57-L82
train
reinert/requestor
requestor/core/requestor-api/src/main/java/io/reinert/requestor/SerdesManagerImpl.java
SerdesManagerImpl.register
@SuppressWarnings("unchecked") public <T> HandlerRegistration register(Serializer<T> serializer) { final HandlerRegistration reg = bindSerializerToType(serializer, serializer.handledType()); if (serializer instanceof HasImpl) { Class[] impls = ((HasImpl) serializer).implTypes(); final HandlerRegistration[] regs = new HandlerRegistration[impls.length + 1]; regs[0] = reg; for (int i = 0; i < impls.length; i++) { Class impl = impls[i]; regs[i + 1] = bindSerializerToType(serializer, impl); } return new HandlerRegistration() { public void removeHandler() { for (HandlerRegistration reg : regs) { reg.removeHandler(); } } }; } return reg; }
java
@SuppressWarnings("unchecked") public <T> HandlerRegistration register(Serializer<T> serializer) { final HandlerRegistration reg = bindSerializerToType(serializer, serializer.handledType()); if (serializer instanceof HasImpl) { Class[] impls = ((HasImpl) serializer).implTypes(); final HandlerRegistration[] regs = new HandlerRegistration[impls.length + 1]; regs[0] = reg; for (int i = 0; i < impls.length; i++) { Class impl = impls[i]; regs[i + 1] = bindSerializerToType(serializer, impl); } return new HandlerRegistration() { public void removeHandler() { for (HandlerRegistration reg : regs) { reg.removeHandler(); } } }; } return reg; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "HandlerRegistration", "register", "(", "Serializer", "<", "T", ">", "serializer", ")", "{", "final", "HandlerRegistration", "reg", "=", "bindSerializerToType", "(", "serializer", ",", ...
Register a serializer of the given type. @param serializer The serializer of T. @param <T> The type of the object to be serialized. @return The {@link HandlerRegistration} object, capable of cancelling this HandlerRegistration to the {@link SerdesManagerImpl}.
[ "Register", "a", "serializer", "of", "the", "given", "type", "." ]
40163a75cd17815d5089935d0dd97b8d652ad6d4
https://github.com/reinert/requestor/blob/40163a75cd17815d5089935d0dd97b8d652ad6d4/requestor/core/requestor-api/src/main/java/io/reinert/requestor/SerdesManagerImpl.java#L93-L118
train
reinert/requestor
requestor/core/requestor-api/src/main/java/io/reinert/requestor/SerdesManagerImpl.java
SerdesManagerImpl.getDeserializer
@SuppressWarnings("unchecked") public <T> Deserializer<T> getDeserializer(Class<T> type, String mediaType) throws SerializationException { checkNotNull(type, "Type (Class<T>) cannot be null."); checkNotNull(mediaType, "Media-Type cannot be null."); final String typeName = getClassName(type); final Key key = new Key(typeName, mediaType); logger.log(Level.FINE, "Querying for Deserializer of type '" + typeName + "' and " + "media-type '" + mediaType + "'."); ArrayList<DeserializerHolder> holders = deserializers.get(typeName); if (holders != null) { for (DeserializerHolder holder : holders) { if (holder.key.matches(key)) { logger.log(Level.FINE, "Deserializer for type '" + holder.deserializer.handledType() + "' and " + "media-type '" + Arrays.toString(holder.deserializer.mediaType()) + "' matched: " + holder.deserializer.getClass().getName()); return (Deserializer<T>) holder.deserializer; } } } logger.log(Level.WARNING, "There is no Deserializer registered for " + type.getName() + " and media-type " + mediaType + ". If you're relying on auto-generated deserializers," + " please make sure you imported the correct GWT Module."); return null; }
java
@SuppressWarnings("unchecked") public <T> Deserializer<T> getDeserializer(Class<T> type, String mediaType) throws SerializationException { checkNotNull(type, "Type (Class<T>) cannot be null."); checkNotNull(mediaType, "Media-Type cannot be null."); final String typeName = getClassName(type); final Key key = new Key(typeName, mediaType); logger.log(Level.FINE, "Querying for Deserializer of type '" + typeName + "' and " + "media-type '" + mediaType + "'."); ArrayList<DeserializerHolder> holders = deserializers.get(typeName); if (holders != null) { for (DeserializerHolder holder : holders) { if (holder.key.matches(key)) { logger.log(Level.FINE, "Deserializer for type '" + holder.deserializer.handledType() + "' and " + "media-type '" + Arrays.toString(holder.deserializer.mediaType()) + "' matched: " + holder.deserializer.getClass().getName()); return (Deserializer<T>) holder.deserializer; } } } logger.log(Level.WARNING, "There is no Deserializer registered for " + type.getName() + " and media-type " + mediaType + ". If you're relying on auto-generated deserializers," + " please make sure you imported the correct GWT Module."); return null; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "Deserializer", "<", "T", ">", "getDeserializer", "(", "Class", "<", "T", ">", "type", ",", "String", "mediaType", ")", "throws", "SerializationException", "{", "checkNotNull", "(", ...
Retrieve Deserializer from manager. @param type The type class of the deserializer. @param <T> The type of the deserializer. @return The deserializer of the specified type. @throws SerializationException if no deserializer was registered for the class.
[ "Retrieve", "Deserializer", "from", "manager", "." ]
40163a75cd17815d5089935d0dd97b8d652ad6d4
https://github.com/reinert/requestor/blob/40163a75cd17815d5089935d0dd97b8d652ad6d4/requestor/core/requestor-api/src/main/java/io/reinert/requestor/SerdesManagerImpl.java#L151-L179
train