id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
154,000
OwlPlatform/java-owl-worldmodel
src/main/java/com/owlplatform/worldmodel/solver/SolverWorldConnection.java
SolverWorldConnection.expire
public boolean expire(final String identifier, final long timestamp, final String... attributes) { if (attributes == null || attributes.length == 0) { return this.wmi.expireId(identifier, timestamp); } boolean retVal = true; for (String attribute : attributes) { retVal = retVal && this.wmi.expireAttribute(identifier, attribute, timestamp); } return retVal; }
java
public boolean expire(final String identifier, final long timestamp, final String... attributes) { if (attributes == null || attributes.length == 0) { return this.wmi.expireId(identifier, timestamp); } boolean retVal = true; for (String attribute : attributes) { retVal = retVal && this.wmi.expireAttribute(identifier, attribute, timestamp); } return retVal; }
[ "public", "boolean", "expire", "(", "final", "String", "identifier", ",", "final", "long", "timestamp", ",", "final", "String", "...", "attributes", ")", "{", "if", "(", "attributes", "==", "null", "||", "attributes", ".", "length", "==", "0", ")", "{", "return", "this", ".", "wmi", ".", "expireId", "(", "identifier", ",", "timestamp", ")", ";", "}", "boolean", "retVal", "=", "true", ";", "for", "(", "String", "attribute", ":", "attributes", ")", "{", "retVal", "=", "retVal", "&&", "this", ".", "wmi", ".", "expireAttribute", "(", "identifier", ",", "attribute", ",", "timestamp", ")", ";", "}", "return", "retVal", ";", "}" ]
Expires an Identifier, or one or more attributes of that Identifier. If Attributes are specified, then they will be expired instead of the Identifier. @param identifier the Identifier to expire, or the Identifier of the attributes to expire. @param timestamp the time at which the values are expired, in milliseconds since the UNIX epoch. @param attributes one or more attribute names to expire. If none are specified, then the Identifier itself is expired. @return {@code true} if all expirations are successful, else {@code false} .
[ "Expires", "an", "Identifier", "or", "one", "or", "more", "attributes", "of", "that", "Identifier", ".", "If", "Attributes", "are", "specified", "then", "they", "will", "be", "expired", "instead", "of", "the", "Identifier", "." ]
a850e8b930c6e9787c7cad30c0de887858ca563d
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/solver/SolverWorldConnection.java#L344-L356
154,001
OwlPlatform/java-owl-worldmodel
src/main/java/com/owlplatform/worldmodel/solver/SolverWorldConnection.java
SolverWorldConnection.expire
public boolean expire(final String identifier, final String... attributes){ return this.expire(identifier, System.currentTimeMillis(),attributes); }
java
public boolean expire(final String identifier, final String... attributes){ return this.expire(identifier, System.currentTimeMillis(),attributes); }
[ "public", "boolean", "expire", "(", "final", "String", "identifier", ",", "final", "String", "...", "attributes", ")", "{", "return", "this", ".", "expire", "(", "identifier", ",", "System", ".", "currentTimeMillis", "(", ")", ",", "attributes", ")", ";", "}" ]
Expires an Identifier, or one or more attributes of that Identifier. If Attributes are specified, then they will be expired instead of the Identifier. The expiration time will be the current local time. @param identifier the Identifier to expire, or the Identifier of the attributes to expire. @param attributes one or more attribute names to expire. If none are specified, then the Identifier itself is expired. @return {@code true} if all expirations are successful, else {@code false}
[ "Expires", "an", "Identifier", "or", "one", "or", "more", "attributes", "of", "that", "Identifier", ".", "If", "Attributes", "are", "specified", "then", "they", "will", "be", "expired", "instead", "of", "the", "Identifier", ".", "The", "expiration", "time", "will", "be", "the", "current", "local", "time", "." ]
a850e8b930c6e9787c7cad30c0de887858ca563d
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/solver/SolverWorldConnection.java#L370-L372
154,002
OwlPlatform/java-owl-worldmodel
src/main/java/com/owlplatform/worldmodel/solver/SolverWorldConnection.java
SolverWorldConnection.sendBufferedValues
private void sendBufferedValues() { ArrayList<Attribute> attributesToSend = new ArrayList<Attribute>(); int num = 0; while (!this.attributeBuffer.isEmpty()) { num += this.attributeBuffer.drainTo(attributesToSend); } if (num > 0) { this.wmi.updateAttributes(attributesToSend); log.info("Sent {} buffered attribute updates.", Integer.valueOf(num)); } }
java
private void sendBufferedValues() { ArrayList<Attribute> attributesToSend = new ArrayList<Attribute>(); int num = 0; while (!this.attributeBuffer.isEmpty()) { num += this.attributeBuffer.drainTo(attributesToSend); } if (num > 0) { this.wmi.updateAttributes(attributesToSend); log.info("Sent {} buffered attribute updates.", Integer.valueOf(num)); } }
[ "private", "void", "sendBufferedValues", "(", ")", "{", "ArrayList", "<", "Attribute", ">", "attributesToSend", "=", "new", "ArrayList", "<", "Attribute", ">", "(", ")", ";", "int", "num", "=", "0", ";", "while", "(", "!", "this", ".", "attributeBuffer", ".", "isEmpty", "(", ")", ")", "{", "num", "+=", "this", ".", "attributeBuffer", ".", "drainTo", "(", "attributesToSend", ")", ";", "}", "if", "(", "num", ">", "0", ")", "{", "this", ".", "wmi", ".", "updateAttributes", "(", "attributesToSend", ")", ";", "log", ".", "info", "(", "\"Sent {} buffered attribute updates.\"", ",", "Integer", ".", "valueOf", "(", "num", ")", ")", ";", "}", "}" ]
Sends any buffered Attribute values to the world model.
[ "Sends", "any", "buffered", "Attribute", "values", "to", "the", "world", "model", "." ]
a850e8b930c6e9787c7cad30c0de887858ca563d
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/solver/SolverWorldConnection.java#L401-L411
154,003
FrodeRanders/java-vopn
src/main/java/org/gautelis/vopn/db/utils/Manager.java
Manager.execute
public void execute(String name, Reader sqlCode, PrintWriter out) throws Exception { runScript(name, sqlCode, out); }
java
public void execute(String name, Reader sqlCode, PrintWriter out) throws Exception { runScript(name, sqlCode, out); }
[ "public", "void", "execute", "(", "String", "name", ",", "Reader", "sqlCode", ",", "PrintWriter", "out", ")", "throws", "Exception", "{", "runScript", "(", "name", ",", "sqlCode", ",", "out", ")", ";", "}" ]
Executes any SQL script file
[ "Executes", "any", "SQL", "script", "file" ]
4c7b2f90201327af4eaa3cd46b3fee68f864e5cc
https://github.com/FrodeRanders/java-vopn/blob/4c7b2f90201327af4eaa3cd46b3fee68f864e5cc/src/main/java/org/gautelis/vopn/db/utils/Manager.java#L128-L130
154,004
FrodeRanders/java-vopn
src/main/java/org/gautelis/vopn/db/utils/Manager.java
Manager.execute
protected void execute(String sqlStatement, PrintWriter out, boolean acceptFailure) throws Exception { try (Connection conn = dataSource.getConnection()) { try (Statement stmt = conn.createStatement()) { boolean success = execute(stmt, sqlStatement, out, acceptFailure); // Loop over all kinds of results. while (success) { /* 'success' is not modified below this line */ int rowCount = stmt.getUpdateCount(); if (rowCount > 0) { // -------------------------------------------------- // Result of successful INSERT or UPDATE or the like // -------------------------------------------------- if (options.debug) { out.println("Rows affected: " + rowCount); out.flush(); } if (stmt.getMoreResults()) { continue; } } else if (rowCount == 0) { // -------------------------------------------------- // Either a DDL command or 0 updates // -------------------------------------------------- if (options.debug) { out.println("No rows affected or statement was DDL command"); out.flush(); } boolean moreResults; try { moreResults = stmt.getMoreResults(); } catch (SQLException sqle) { // State: 24000 - Invalid cursor state // [Teradata: Continue request submitted but no response to return] if (sqle.getSQLState().startsWith("24")) { break; } else { throw sqle; } } if (moreResults) { continue; } } else { // rowCount < 0 // -------------------------------------------------- // Either we have a result set or no more results... // -------------------------------------------------- ResultSet rs = stmt.getResultSet(); if (null != rs) { // Ignore resultset rs.close(); if (stmt.getMoreResults()) { continue; } } } // No more results break; } } } catch (SQLException sqle) { out.println("Failed to execute statement: \n" + sqlStatement); out.println("\n\nDescription of failure: \n" + Database.squeeze(sqle)); out.flush(); throw sqle; } catch (Exception e) { out.println("Failed to execute statement: \n" + sqlStatement); out.println("\n\nDescription of failure: \n" + e.getMessage()); out.flush(); throw e; } }
java
protected void execute(String sqlStatement, PrintWriter out, boolean acceptFailure) throws Exception { try (Connection conn = dataSource.getConnection()) { try (Statement stmt = conn.createStatement()) { boolean success = execute(stmt, sqlStatement, out, acceptFailure); // Loop over all kinds of results. while (success) { /* 'success' is not modified below this line */ int rowCount = stmt.getUpdateCount(); if (rowCount > 0) { // -------------------------------------------------- // Result of successful INSERT or UPDATE or the like // -------------------------------------------------- if (options.debug) { out.println("Rows affected: " + rowCount); out.flush(); } if (stmt.getMoreResults()) { continue; } } else if (rowCount == 0) { // -------------------------------------------------- // Either a DDL command or 0 updates // -------------------------------------------------- if (options.debug) { out.println("No rows affected or statement was DDL command"); out.flush(); } boolean moreResults; try { moreResults = stmt.getMoreResults(); } catch (SQLException sqle) { // State: 24000 - Invalid cursor state // [Teradata: Continue request submitted but no response to return] if (sqle.getSQLState().startsWith("24")) { break; } else { throw sqle; } } if (moreResults) { continue; } } else { // rowCount < 0 // -------------------------------------------------- // Either we have a result set or no more results... // -------------------------------------------------- ResultSet rs = stmt.getResultSet(); if (null != rs) { // Ignore resultset rs.close(); if (stmt.getMoreResults()) { continue; } } } // No more results break; } } } catch (SQLException sqle) { out.println("Failed to execute statement: \n" + sqlStatement); out.println("\n\nDescription of failure: \n" + Database.squeeze(sqle)); out.flush(); throw sqle; } catch (Exception e) { out.println("Failed to execute statement: \n" + sqlStatement); out.println("\n\nDescription of failure: \n" + e.getMessage()); out.flush(); throw e; } }
[ "protected", "void", "execute", "(", "String", "sqlStatement", ",", "PrintWriter", "out", ",", "boolean", "acceptFailure", ")", "throws", "Exception", "{", "try", "(", "Connection", "conn", "=", "dataSource", ".", "getConnection", "(", ")", ")", "{", "try", "(", "Statement", "stmt", "=", "conn", ".", "createStatement", "(", ")", ")", "{", "boolean", "success", "=", "execute", "(", "stmt", ",", "sqlStatement", ",", "out", ",", "acceptFailure", ")", ";", "// Loop over all kinds of results.", "while", "(", "success", ")", "{", "/* 'success' is not modified below this line */", "int", "rowCount", "=", "stmt", ".", "getUpdateCount", "(", ")", ";", "if", "(", "rowCount", ">", "0", ")", "{", "// --------------------------------------------------", "// Result of successful INSERT or UPDATE or the like", "// --------------------------------------------------", "if", "(", "options", ".", "debug", ")", "{", "out", ".", "println", "(", "\"Rows affected: \"", "+", "rowCount", ")", ";", "out", ".", "flush", "(", ")", ";", "}", "if", "(", "stmt", ".", "getMoreResults", "(", ")", ")", "{", "continue", ";", "}", "}", "else", "if", "(", "rowCount", "==", "0", ")", "{", "// --------------------------------------------------", "// Either a DDL command or 0 updates", "// --------------------------------------------------", "if", "(", "options", ".", "debug", ")", "{", "out", ".", "println", "(", "\"No rows affected or statement was DDL command\"", ")", ";", "out", ".", "flush", "(", ")", ";", "}", "boolean", "moreResults", ";", "try", "{", "moreResults", "=", "stmt", ".", "getMoreResults", "(", ")", ";", "}", "catch", "(", "SQLException", "sqle", ")", "{", "// State: 24000 - Invalid cursor state", "// [Teradata: Continue request submitted but no response to return]", "if", "(", "sqle", ".", "getSQLState", "(", ")", ".", "startsWith", "(", "\"24\"", ")", ")", "{", "break", ";", "}", "else", "{", "throw", "sqle", ";", "}", "}", "if", "(", "moreResults", ")", "{", "continue", ";", "}", "}", "else", "{", "// rowCount < 0", "// --------------------------------------------------", "// Either we have a result set or no more results...", "// --------------------------------------------------", "ResultSet", "rs", "=", "stmt", ".", "getResultSet", "(", ")", ";", "if", "(", "null", "!=", "rs", ")", "{", "// Ignore resultset", "rs", ".", "close", "(", ")", ";", "if", "(", "stmt", ".", "getMoreResults", "(", ")", ")", "{", "continue", ";", "}", "}", "}", "// No more results", "break", ";", "}", "}", "}", "catch", "(", "SQLException", "sqle", ")", "{", "out", ".", "println", "(", "\"Failed to execute statement: \\n\"", "+", "sqlStatement", ")", ";", "out", ".", "println", "(", "\"\\n\\nDescription of failure: \\n\"", "+", "Database", ".", "squeeze", "(", "sqle", ")", ")", ";", "out", ".", "flush", "(", ")", ";", "throw", "sqle", ";", "}", "catch", "(", "Exception", "e", ")", "{", "out", ".", "println", "(", "\"Failed to execute statement: \\n\"", "+", "sqlStatement", ")", ";", "out", ".", "println", "(", "\"\\n\\nDescription of failure: \\n\"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "out", ".", "flush", "(", ")", ";", "throw", "e", ";", "}", "}" ]
Executes an SQL statement. @param sqlStatement @throws Exception
[ "Executes", "an", "SQL", "statement", "." ]
4c7b2f90201327af4eaa3cd46b3fee68f864e5cc
https://github.com/FrodeRanders/java-vopn/blob/4c7b2f90201327af4eaa3cd46b3fee68f864e5cc/src/main/java/org/gautelis/vopn/db/utils/Manager.java#L175-L257
154,005
microfocus-idol/java-logging
src/main/java/com/hp/autonomy/frontend/logging/LogbackMarkerFilter.java
LogbackMarkerFilter.decide
@Override public FilterReply decide(final ILoggingEvent event) { final Marker marker = event.getMarker(); if (marker == this.marker) { return FilterReply.NEUTRAL; } else { return FilterReply.DENY; } }
java
@Override public FilterReply decide(final ILoggingEvent event) { final Marker marker = event.getMarker(); if (marker == this.marker) { return FilterReply.NEUTRAL; } else { return FilterReply.DENY; } }
[ "@", "Override", "public", "FilterReply", "decide", "(", "final", "ILoggingEvent", "event", ")", "{", "final", "Marker", "marker", "=", "event", ".", "getMarker", "(", ")", ";", "if", "(", "marker", "==", "this", ".", "marker", ")", "{", "return", "FilterReply", ".", "NEUTRAL", ";", "}", "else", "{", "return", "FilterReply", ".", "DENY", ";", "}", "}" ]
Filter the logging event according to the provided marker @param event The logging event @return FilterReply.NEUTRAL if the event's marker is the same as the provided marker; FilterReply.DENY otherwise
[ "Filter", "the", "logging", "event", "according", "to", "the", "provided", "marker" ]
f06f8547928897d07d41e046f53abcbbc3725271
https://github.com/microfocus-idol/java-logging/blob/f06f8547928897d07d41e046f53abcbbc3725271/src/main/java/com/hp/autonomy/frontend/logging/LogbackMarkerFilter.java#L28-L37
154,006
OwlPlatform/java-owl-worldmodel
src/main/java/com/owlplatform/worldmodel/client/ClientWorldConnection.java
ClientWorldConnection.connect
public boolean connect(long timeout) { if (this.wmi.connect(timeout)) { this.wmi.setStayConnected(true); // this.isReady = true; return true; } return false; }
java
public boolean connect(long timeout) { if (this.wmi.connect(timeout)) { this.wmi.setStayConnected(true); // this.isReady = true; return true; } return false; }
[ "public", "boolean", "connect", "(", "long", "timeout", ")", "{", "if", "(", "this", ".", "wmi", ".", "connect", "(", "timeout", ")", ")", "{", "this", ".", "wmi", ".", "setStayConnected", "(", "true", ")", ";", "// this.isReady = true;", "return", "true", ";", "}", "return", "false", ";", "}" ]
Connects to the world model at the configured host and port. @param timeout the maximum time to attempt the connection or 0 for the configured timeout @return {@code true} if the connection succeeds, else {@code false}.
[ "Connects", "to", "the", "world", "model", "at", "the", "configured", "host", "and", "port", "." ]
a850e8b930c6e9787c7cad30c0de887858ca563d
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/client/ClientWorldConnection.java#L226-L233
154,007
OwlPlatform/java-owl-worldmodel
src/main/java/com/owlplatform/worldmodel/client/ClientWorldConnection.java
ClientWorldConnection.getSnapshot
public synchronized Response getSnapshot(final String idRegex, final long start, final long end, String... attributes) { SnapshotRequestMessage req = new SnapshotRequestMessage(); req.setIdRegex(idRegex); req.setBeginTimestamp(start); req.setEndTimestamp(end); if (attributes != null) { req.setAttributeRegexes(attributes); } Response resp = new Response(this, 0); try { while (!this.isReady) { log.debug("Trying to wait until connection is ready."); synchronized (this) { try { this.wait(); } catch (InterruptedException ie) { // Ignored } } } long reqId = this.wmi.sendMessage(req); resp.setTicketNumber(reqId); this.outstandingSnapshots.put(Long.valueOf(reqId), resp); WorldState ws = new WorldState(); this.outstandingStates.put(Long.valueOf(reqId), ws); log.info("Binding Tix #{} to {}", Long.valueOf(reqId), resp); return resp; } catch (Exception e) { log.error("Unable to send " + req + ".", e); resp.setError(e); return resp; } }
java
public synchronized Response getSnapshot(final String idRegex, final long start, final long end, String... attributes) { SnapshotRequestMessage req = new SnapshotRequestMessage(); req.setIdRegex(idRegex); req.setBeginTimestamp(start); req.setEndTimestamp(end); if (attributes != null) { req.setAttributeRegexes(attributes); } Response resp = new Response(this, 0); try { while (!this.isReady) { log.debug("Trying to wait until connection is ready."); synchronized (this) { try { this.wait(); } catch (InterruptedException ie) { // Ignored } } } long reqId = this.wmi.sendMessage(req); resp.setTicketNumber(reqId); this.outstandingSnapshots.put(Long.valueOf(reqId), resp); WorldState ws = new WorldState(); this.outstandingStates.put(Long.valueOf(reqId), ws); log.info("Binding Tix #{} to {}", Long.valueOf(reqId), resp); return resp; } catch (Exception e) { log.error("Unable to send " + req + ".", e); resp.setError(e); return resp; } }
[ "public", "synchronized", "Response", "getSnapshot", "(", "final", "String", "idRegex", ",", "final", "long", "start", ",", "final", "long", "end", ",", "String", "...", "attributes", ")", "{", "SnapshotRequestMessage", "req", "=", "new", "SnapshotRequestMessage", "(", ")", ";", "req", ".", "setIdRegex", "(", "idRegex", ")", ";", "req", ".", "setBeginTimestamp", "(", "start", ")", ";", "req", ".", "setEndTimestamp", "(", "end", ")", ";", "if", "(", "attributes", "!=", "null", ")", "{", "req", ".", "setAttributeRegexes", "(", "attributes", ")", ";", "}", "Response", "resp", "=", "new", "Response", "(", "this", ",", "0", ")", ";", "try", "{", "while", "(", "!", "this", ".", "isReady", ")", "{", "log", ".", "debug", "(", "\"Trying to wait until connection is ready.\"", ")", ";", "synchronized", "(", "this", ")", "{", "try", "{", "this", ".", "wait", "(", ")", ";", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "// Ignored", "}", "}", "}", "long", "reqId", "=", "this", ".", "wmi", ".", "sendMessage", "(", "req", ")", ";", "resp", ".", "setTicketNumber", "(", "reqId", ")", ";", "this", ".", "outstandingSnapshots", ".", "put", "(", "Long", ".", "valueOf", "(", "reqId", ")", ",", "resp", ")", ";", "WorldState", "ws", "=", "new", "WorldState", "(", ")", ";", "this", ".", "outstandingStates", ".", "put", "(", "Long", ".", "valueOf", "(", "reqId", ")", ",", "ws", ")", ";", "log", ".", "info", "(", "\"Binding Tix #{} to {}\"", ",", "Long", ".", "valueOf", "(", "reqId", ")", ",", "resp", ")", ";", "return", "resp", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"Unable to send \"", "+", "req", "+", "\".\"", ",", "e", ")", ";", "resp", ".", "setError", "(", "e", ")", ";", "return", "resp", ";", "}", "}" ]
Sends a snapshot request to the world model for the specified Identifier regular expression and Attribute regular expressions, between the start and end timestamps. @param idRegex regular expression for matching the identifier. @param start the begin time for the snapshot. @param end the ending time for the snapshot. @param attributes the attribute regular expressions to request @return a {@code Response} for the request.
[ "Sends", "a", "snapshot", "request", "to", "the", "world", "model", "for", "the", "specified", "Identifier", "regular", "expression", "and", "Attribute", "regular", "expressions", "between", "the", "start", "and", "end", "timestamps", "." ]
a850e8b930c6e9787c7cad30c0de887858ca563d
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/client/ClientWorldConnection.java#L282-L316
154,008
OwlPlatform/java-owl-worldmodel
src/main/java/com/owlplatform/worldmodel/client/ClientWorldConnection.java
ClientWorldConnection.getRangeRequest
public synchronized StepResponse getRangeRequest(final String idRegex, final long start, final long end, String... attributes) { RangeRequestMessage req = new RangeRequestMessage(); req.setIdRegex(idRegex); req.setBeginTimestamp(start); req.setEndTimestamp(end); if (attributes != null) { req.setAttributeRegexes(attributes); } StepResponse resp = new StepResponse(this, 0); try { while (!this.isReady) { log.debug("Trying to wait until connection is ready."); synchronized (this) { try { this.wait(); } catch (InterruptedException ie) { // Ignored } } } long reqId = this.wmi.sendMessage(req); resp.setTicketNumber(reqId); this.outstandingSteps.put(Long.valueOf(reqId), resp); log.info("Binding Tix #{} to {}", Long.valueOf(reqId), resp); return resp; } catch (Exception e) { resp.setError(e); return resp; } }
java
public synchronized StepResponse getRangeRequest(final String idRegex, final long start, final long end, String... attributes) { RangeRequestMessage req = new RangeRequestMessage(); req.setIdRegex(idRegex); req.setBeginTimestamp(start); req.setEndTimestamp(end); if (attributes != null) { req.setAttributeRegexes(attributes); } StepResponse resp = new StepResponse(this, 0); try { while (!this.isReady) { log.debug("Trying to wait until connection is ready."); synchronized (this) { try { this.wait(); } catch (InterruptedException ie) { // Ignored } } } long reqId = this.wmi.sendMessage(req); resp.setTicketNumber(reqId); this.outstandingSteps.put(Long.valueOf(reqId), resp); log.info("Binding Tix #{} to {}", Long.valueOf(reqId), resp); return resp; } catch (Exception e) { resp.setError(e); return resp; } }
[ "public", "synchronized", "StepResponse", "getRangeRequest", "(", "final", "String", "idRegex", ",", "final", "long", "start", ",", "final", "long", "end", ",", "String", "...", "attributes", ")", "{", "RangeRequestMessage", "req", "=", "new", "RangeRequestMessage", "(", ")", ";", "req", ".", "setIdRegex", "(", "idRegex", ")", ";", "req", ".", "setBeginTimestamp", "(", "start", ")", ";", "req", ".", "setEndTimestamp", "(", "end", ")", ";", "if", "(", "attributes", "!=", "null", ")", "{", "req", ".", "setAttributeRegexes", "(", "attributes", ")", ";", "}", "StepResponse", "resp", "=", "new", "StepResponse", "(", "this", ",", "0", ")", ";", "try", "{", "while", "(", "!", "this", ".", "isReady", ")", "{", "log", ".", "debug", "(", "\"Trying to wait until connection is ready.\"", ")", ";", "synchronized", "(", "this", ")", "{", "try", "{", "this", ".", "wait", "(", ")", ";", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "// Ignored", "}", "}", "}", "long", "reqId", "=", "this", ".", "wmi", ".", "sendMessage", "(", "req", ")", ";", "resp", ".", "setTicketNumber", "(", "reqId", ")", ";", "this", ".", "outstandingSteps", ".", "put", "(", "Long", ".", "valueOf", "(", "reqId", ")", ",", "resp", ")", ";", "log", ".", "info", "(", "\"Binding Tix #{} to {}\"", ",", "Long", ".", "valueOf", "(", "reqId", ")", ",", "resp", ")", ";", "return", "resp", ";", "}", "catch", "(", "Exception", "e", ")", "{", "resp", ".", "setError", "(", "e", ")", ";", "return", "resp", ";", "}", "}" ]
Sends a range request to the world model for the specified Identifier regular expression, Attribute regular expressions, between the start and end times. @param idRegex regular expression for matching the identifier. @param start the beginning of the range.. @param end the end of the range. @param attributes the attribute regular expressions to request @return a {@code StepResponse} for the request.
[ "Sends", "a", "range", "request", "to", "the", "world", "model", "for", "the", "specified", "Identifier", "regular", "expression", "Attribute", "regular", "expressions", "between", "the", "start", "and", "end", "times", "." ]
a850e8b930c6e9787c7cad30c0de887858ca563d
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/client/ClientWorldConnection.java#L348-L379
154,009
OwlPlatform/java-owl-worldmodel
src/main/java/com/owlplatform/worldmodel/client/ClientWorldConnection.java
ClientWorldConnection.searchId
public String[] searchId(final String idRegex) { synchronized (this.idSearchResponses) { if (!this.wmi.searchIdRegex(idRegex)) { log.warn("Attempted to search for a null Identifier regex. Not sending."); return new String[] {}; } do { log.debug("Waiting for response."); try { return this.idSearchResponses.take(); } catch (InterruptedException ie) { // Ignored } } while (this.idSearchResponses.isEmpty()); log.error("Unable to retrieve matching Identifier values for {}.", idRegex); return new String[] {}; } }
java
public String[] searchId(final String idRegex) { synchronized (this.idSearchResponses) { if (!this.wmi.searchIdRegex(idRegex)) { log.warn("Attempted to search for a null Identifier regex. Not sending."); return new String[] {}; } do { log.debug("Waiting for response."); try { return this.idSearchResponses.take(); } catch (InterruptedException ie) { // Ignored } } while (this.idSearchResponses.isEmpty()); log.error("Unable to retrieve matching Identifier values for {}.", idRegex); return new String[] {}; } }
[ "public", "String", "[", "]", "searchId", "(", "final", "String", "idRegex", ")", "{", "synchronized", "(", "this", ".", "idSearchResponses", ")", "{", "if", "(", "!", "this", ".", "wmi", ".", "searchIdRegex", "(", "idRegex", ")", ")", "{", "log", ".", "warn", "(", "\"Attempted to search for a null Identifier regex. Not sending.\"", ")", ";", "return", "new", "String", "[", "]", "{", "}", ";", "}", "do", "{", "log", ".", "debug", "(", "\"Waiting for response.\"", ")", ";", "try", "{", "return", "this", ".", "idSearchResponses", ".", "take", "(", ")", ";", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "// Ignored", "}", "}", "while", "(", "this", ".", "idSearchResponses", ".", "isEmpty", "(", ")", ")", ";", "log", ".", "error", "(", "\"Unable to retrieve matching Identifier values for {}.\"", ",", "idRegex", ")", ";", "return", "new", "String", "[", "]", "{", "}", ";", "}", "}" ]
Searches for any Identifier values that match the provided regular expression. @param idRegex a regular expression to match against Identifiers in the world model. @return all matching Identifiers.
[ "Searches", "for", "any", "Identifier", "values", "that", "match", "the", "provided", "regular", "expression", "." ]
a850e8b930c6e9787c7cad30c0de887858ca563d
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/client/ClientWorldConnection.java#L438-L456
154,010
OwlPlatform/java-owl-worldmodel
src/main/java/com/owlplatform/worldmodel/client/ClientWorldConnection.java
ClientWorldConnection.connectionInterrupted
void connectionInterrupted(ClientWorldModelInterface worldModel) { this.isReady = false; for (Iterator<Long> iter = this.outstandingSnapshots.keySet().iterator(); iter .hasNext();) { Long tix = iter.next(); Response resp = this.outstandingSnapshots.remove(tix); resp.setError(new RuntimeException("Connection to " + worldModel.toString() + " was closed.")); iter.remove(); } this.outstandingStates.clear(); for (Iterator<Long> iter = this.outstandingSteps.keySet().iterator(); iter .hasNext();) { Long tix = iter.next(); StepResponse resp = this.outstandingSteps.remove(tix); if (resp == null) { log.error("No step response found for {}", tix); } else { resp.setError(new RuntimeException("Connection to " + worldModel.toString() + " was closed.")); } iter.remove(); } }
java
void connectionInterrupted(ClientWorldModelInterface worldModel) { this.isReady = false; for (Iterator<Long> iter = this.outstandingSnapshots.keySet().iterator(); iter .hasNext();) { Long tix = iter.next(); Response resp = this.outstandingSnapshots.remove(tix); resp.setError(new RuntimeException("Connection to " + worldModel.toString() + " was closed.")); iter.remove(); } this.outstandingStates.clear(); for (Iterator<Long> iter = this.outstandingSteps.keySet().iterator(); iter .hasNext();) { Long tix = iter.next(); StepResponse resp = this.outstandingSteps.remove(tix); if (resp == null) { log.error("No step response found for {}", tix); } else { resp.setError(new RuntimeException("Connection to " + worldModel.toString() + " was closed.")); } iter.remove(); } }
[ "void", "connectionInterrupted", "(", "ClientWorldModelInterface", "worldModel", ")", "{", "this", ".", "isReady", "=", "false", ";", "for", "(", "Iterator", "<", "Long", ">", "iter", "=", "this", ".", "outstandingSnapshots", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "Long", "tix", "=", "iter", ".", "next", "(", ")", ";", "Response", "resp", "=", "this", ".", "outstandingSnapshots", ".", "remove", "(", "tix", ")", ";", "resp", ".", "setError", "(", "new", "RuntimeException", "(", "\"Connection to \"", "+", "worldModel", ".", "toString", "(", ")", "+", "\" was closed.\"", ")", ")", ";", "iter", ".", "remove", "(", ")", ";", "}", "this", ".", "outstandingStates", ".", "clear", "(", ")", ";", "for", "(", "Iterator", "<", "Long", ">", "iter", "=", "this", ".", "outstandingSteps", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "Long", "tix", "=", "iter", ".", "next", "(", ")", ";", "StepResponse", "resp", "=", "this", ".", "outstandingSteps", ".", "remove", "(", "tix", ")", ";", "if", "(", "resp", "==", "null", ")", "{", "log", ".", "error", "(", "\"No step response found for {}\"", ",", "tix", ")", ";", "}", "else", "{", "resp", ".", "setError", "(", "new", "RuntimeException", "(", "\"Connection to \"", "+", "worldModel", ".", "toString", "(", ")", "+", "\" was closed.\"", ")", ")", ";", "}", "iter", ".", "remove", "(", ")", ";", "}", "}" ]
Completes any outstanding requests with errors. @param worldModel the source of the connection interruption.
[ "Completes", "any", "outstanding", "requests", "with", "errors", "." ]
a850e8b930c6e9787c7cad30c0de887858ca563d
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/client/ClientWorldConnection.java#L475-L500
154,011
inkstand-io/scribble
scribble-jcr/src/main/java/io/inkstand/scribble/jcr/rules/ContentLoader.java
ContentLoader.setContentDefinition
@RuleSetup(RequirementLevel.OPTIONAL) public void setContentDefinition(final URL contentDef) { assertStateBefore(State.INITIALIZED); this.contentDef = contentDef; }
java
@RuleSetup(RequirementLevel.OPTIONAL) public void setContentDefinition(final URL contentDef) { assertStateBefore(State.INITIALIZED); this.contentDef = contentDef; }
[ "@", "RuleSetup", "(", "RequirementLevel", ".", "OPTIONAL", ")", "public", "void", "setContentDefinition", "(", "final", "URL", "contentDef", ")", "{", "assertStateBefore", "(", "State", ".", "INITIALIZED", ")", ";", "this", ".", "contentDef", "=", "contentDef", ";", "}" ]
Sets the locator pointing to the content definition. @param contentDef the url of the content definition.
[ "Sets", "the", "locator", "pointing", "to", "the", "content", "definition", "." ]
66e67553bad4b1ff817e1715fd1d3dd833406744
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-jcr/src/main/java/io/inkstand/scribble/jcr/rules/ContentLoader.java#L60-L65
154,012
inkstand-io/scribble
scribble-jcr/src/main/java/io/inkstand/scribble/jcr/rules/ContentLoader.java
ContentLoader.loadContent
public Node loadContent(URL contentDefinition) throws RepositoryException { LOG.info("Loading Content"); final Session session = repository.getAdminSession(); final XMLContentLoader loader = new XMLContentLoader(); return loader.loadContent(session, contentDefinition); }
java
public Node loadContent(URL contentDefinition) throws RepositoryException { LOG.info("Loading Content"); final Session session = repository.getAdminSession(); final XMLContentLoader loader = new XMLContentLoader(); return loader.loadContent(session, contentDefinition); }
[ "public", "Node", "loadContent", "(", "URL", "contentDefinition", ")", "throws", "RepositoryException", "{", "LOG", ".", "info", "(", "\"Loading Content\"", ")", ";", "final", "Session", "session", "=", "repository", ".", "getAdminSession", "(", ")", ";", "final", "XMLContentLoader", "loader", "=", "new", "XMLContentLoader", "(", ")", ";", "return", "loader", ".", "loadContent", "(", "session", ",", "contentDefinition", ")", ";", "}" ]
Loads content from an external content definition into the underlying repository. @param contentDefinition URL pointing to the resource that defines the content to be loaded. @return The root node, defined by the content's document element, is returned. @throws RepositoryException
[ "Loads", "content", "from", "an", "external", "content", "definition", "into", "the", "underlying", "repository", "." ]
66e67553bad4b1ff817e1715fd1d3dd833406744
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-jcr/src/main/java/io/inkstand/scribble/jcr/rules/ContentLoader.java#L98-L104
154,013
inkstand-io/scribble
scribble-file/src/main/java/io/inkstand/scribble/rules/builder/TemporaryFileBuilder.java
TemporaryFileBuilder.fromClasspathResource
public TemporaryFileBuilder fromClasspathResource(final String pathToResource) { final Class<?> callerClass = getCallerClass(); this.content = getResolver().resolve(pathToResource, callerClass); return this; }
java
public TemporaryFileBuilder fromClasspathResource(final String pathToResource) { final Class<?> callerClass = getCallerClass(); this.content = getResolver().resolve(pathToResource, callerClass); return this; }
[ "public", "TemporaryFileBuilder", "fromClasspathResource", "(", "final", "String", "pathToResource", ")", "{", "final", "Class", "<", "?", ">", "callerClass", "=", "getCallerClass", "(", ")", ";", "this", ".", "content", "=", "getResolver", "(", ")", ".", "resolve", "(", "pathToResource", ",", "callerClass", ")", ";", "return", "this", ";", "}" ]
Defines the classpath resource from where the content of the file should be retrieved @param pathToResource the path to the classpath resource @return the builder
[ "Defines", "the", "classpath", "resource", "from", "where", "the", "content", "of", "the", "file", "should", "be", "retrieved" ]
66e67553bad4b1ff817e1715fd1d3dd833406744
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-file/src/main/java/io/inkstand/scribble/rules/builder/TemporaryFileBuilder.java#L63-L67
154,014
inkstand-io/scribble
scribble-file/src/main/java/io/inkstand/scribble/rules/builder/TemporaryFileBuilder.java
TemporaryFileBuilder.asZip
public ZipFileBuilder asZip() { final ZipFileBuilder zfb = new ZipFileBuilder(folder, filename); if(this.content != null) { zfb.addResource(getContenFileName(), this.content); } return zfb; }
java
public ZipFileBuilder asZip() { final ZipFileBuilder zfb = new ZipFileBuilder(folder, filename); if(this.content != null) { zfb.addResource(getContenFileName(), this.content); } return zfb; }
[ "public", "ZipFileBuilder", "asZip", "(", ")", "{", "final", "ZipFileBuilder", "zfb", "=", "new", "ZipFileBuilder", "(", "folder", ",", "filename", ")", ";", "if", "(", "this", ".", "content", "!=", "null", ")", "{", "zfb", ".", "addResource", "(", "getContenFileName", "(", ")", ",", "this", ".", "content", ")", ";", "}", "return", "zfb", ";", "}" ]
Indicates the content for the file should be zipped. If only one content reference is provided, the zip will only contain this file. @return the builder
[ "Indicates", "the", "content", "for", "the", "file", "should", "be", "zipped", ".", "If", "only", "one", "content", "reference", "is", "provided", "the", "zip", "will", "only", "contain", "this", "file", "." ]
66e67553bad4b1ff817e1715fd1d3dd833406744
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-file/src/main/java/io/inkstand/scribble/rules/builder/TemporaryFileBuilder.java#L100-L106
154,015
inkstand-io/scribble
scribble-file/src/main/java/io/inkstand/scribble/rules/builder/TemporaryFileBuilder.java
TemporaryFileBuilder.getContenFileName
private String getContenFileName() { final String file = this.content.getPath(); if(file.indexOf('/') != -1){ return file.substring(file.lastIndexOf('/')); } return file; }
java
private String getContenFileName() { final String file = this.content.getPath(); if(file.indexOf('/') != -1){ return file.substring(file.lastIndexOf('/')); } return file; }
[ "private", "String", "getContenFileName", "(", ")", "{", "final", "String", "file", "=", "this", ".", "content", ".", "getPath", "(", ")", ";", "if", "(", "file", ".", "indexOf", "(", "'", "'", ")", "!=", "-", "1", ")", "{", "return", "file", ".", "substring", "(", "file", ".", "lastIndexOf", "(", "'", "'", ")", ")", ";", "}", "return", "file", ";", "}" ]
Extracts the name of the resource from the url itself. The filename from the path-part of the URL is extracted. @return the name of the resource that provided the content
[ "Extracts", "the", "name", "of", "the", "resource", "from", "the", "url", "itself", ".", "The", "filename", "from", "the", "path", "-", "part", "of", "the", "URL", "is", "extracted", "." ]
66e67553bad4b1ff817e1715fd1d3dd833406744
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-file/src/main/java/io/inkstand/scribble/rules/builder/TemporaryFileBuilder.java#L114-L120
154,016
jbundle/jbundle
base/message/service/src/main/java/org/jbundle/base/message/service/BaseServiceMessageTransport.java
BaseServiceMessageTransport.processMessage
public Object processMessage(Object message) { Utility.getLogger().info("processMessage called in service message"); BaseMessage msgReplyInternal = null; try { BaseMessage messageIn = new TreeMessage(null, null); new ServiceTrxMessageIn(messageIn, message); msgReplyInternal = this.processIncomingMessage(messageIn, null); Utility.getLogger().info("msgReplyInternal: " + msgReplyInternal); int iErrorCode = this.convertToExternal(msgReplyInternal, null); Utility.getLogger().info("externalMessageReply: " + msgReplyInternal); Object msg = null;//fac.createMessage(); if (iErrorCode == DBConstants.NORMAL_RETURN) { msg = msgReplyInternal.getExternalMessage().getRawData(); String strTrxID = (String)msgReplyInternal.getMessageHeader().get(TrxMessageHeader.LOG_TRX_ID); this.logMessage(strTrxID, msgReplyInternal, MessageInfoTypeModel.REPLY, MessageTypeModel.MESSAGE_OUT, MessageStatusModel.SENTOK, null, null); // Sent (no reply required) } return msg; } catch (Throwable ex) { ex.printStackTrace(); String strError = "Error in processing or replying to a message"; Utility.getLogger().warning(strError); if (msgReplyInternal != null) { String strTrxID = (String)msgReplyInternal.getMessageHeader().get(TrxMessageHeader.LOG_TRX_ID); this.logMessage(strTrxID, msgReplyInternal, MessageInfoTypeModel.REPLY, MessageTypeModel.MESSAGE_OUT, MessageStatusModel.ERROR, strError, null); } return null; } }
java
public Object processMessage(Object message) { Utility.getLogger().info("processMessage called in service message"); BaseMessage msgReplyInternal = null; try { BaseMessage messageIn = new TreeMessage(null, null); new ServiceTrxMessageIn(messageIn, message); msgReplyInternal = this.processIncomingMessage(messageIn, null); Utility.getLogger().info("msgReplyInternal: " + msgReplyInternal); int iErrorCode = this.convertToExternal(msgReplyInternal, null); Utility.getLogger().info("externalMessageReply: " + msgReplyInternal); Object msg = null;//fac.createMessage(); if (iErrorCode == DBConstants.NORMAL_RETURN) { msg = msgReplyInternal.getExternalMessage().getRawData(); String strTrxID = (String)msgReplyInternal.getMessageHeader().get(TrxMessageHeader.LOG_TRX_ID); this.logMessage(strTrxID, msgReplyInternal, MessageInfoTypeModel.REPLY, MessageTypeModel.MESSAGE_OUT, MessageStatusModel.SENTOK, null, null); // Sent (no reply required) } return msg; } catch (Throwable ex) { ex.printStackTrace(); String strError = "Error in processing or replying to a message"; Utility.getLogger().warning(strError); if (msgReplyInternal != null) { String strTrxID = (String)msgReplyInternal.getMessageHeader().get(TrxMessageHeader.LOG_TRX_ID); this.logMessage(strTrxID, msgReplyInternal, MessageInfoTypeModel.REPLY, MessageTypeModel.MESSAGE_OUT, MessageStatusModel.ERROR, strError, null); } return null; } }
[ "public", "Object", "processMessage", "(", "Object", "message", ")", "{", "Utility", ".", "getLogger", "(", ")", ".", "info", "(", "\"processMessage called in service message\"", ")", ";", "BaseMessage", "msgReplyInternal", "=", "null", ";", "try", "{", "BaseMessage", "messageIn", "=", "new", "TreeMessage", "(", "null", ",", "null", ")", ";", "new", "ServiceTrxMessageIn", "(", "messageIn", ",", "message", ")", ";", "msgReplyInternal", "=", "this", ".", "processIncomingMessage", "(", "messageIn", ",", "null", ")", ";", "Utility", ".", "getLogger", "(", ")", ".", "info", "(", "\"msgReplyInternal: \"", "+", "msgReplyInternal", ")", ";", "int", "iErrorCode", "=", "this", ".", "convertToExternal", "(", "msgReplyInternal", ",", "null", ")", ";", "Utility", ".", "getLogger", "(", ")", ".", "info", "(", "\"externalMessageReply: \"", "+", "msgReplyInternal", ")", ";", "Object", "msg", "=", "null", ";", "//fac.createMessage();", "if", "(", "iErrorCode", "==", "DBConstants", ".", "NORMAL_RETURN", ")", "{", "msg", "=", "msgReplyInternal", ".", "getExternalMessage", "(", ")", ".", "getRawData", "(", ")", ";", "String", "strTrxID", "=", "(", "String", ")", "msgReplyInternal", ".", "getMessageHeader", "(", ")", ".", "get", "(", "TrxMessageHeader", ".", "LOG_TRX_ID", ")", ";", "this", ".", "logMessage", "(", "strTrxID", ",", "msgReplyInternal", ",", "MessageInfoTypeModel", ".", "REPLY", ",", "MessageTypeModel", ".", "MESSAGE_OUT", ",", "MessageStatusModel", ".", "SENTOK", ",", "null", ",", "null", ")", ";", "// Sent (no reply required)", "}", "return", "msg", ";", "}", "catch", "(", "Throwable", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "String", "strError", "=", "\"Error in processing or replying to a message\"", ";", "Utility", ".", "getLogger", "(", ")", ".", "warning", "(", "strError", ")", ";", "if", "(", "msgReplyInternal", "!=", "null", ")", "{", "String", "strTrxID", "=", "(", "String", ")", "msgReplyInternal", ".", "getMessageHeader", "(", ")", ".", "get", "(", "TrxMessageHeader", ".", "LOG_TRX_ID", ")", ";", "this", ".", "logMessage", "(", "strTrxID", ",", "msgReplyInternal", ",", "MessageInfoTypeModel", ".", "REPLY", ",", "MessageTypeModel", ".", "MESSAGE_OUT", ",", "MessageStatusModel", ".", "ERROR", ",", "strError", ",", "null", ")", ";", "}", "return", "null", ";", "}", "}" ]
This is the application code for handling the message.. Once the message is received the application can retrieve the soap part, the attachment part if there are any, or any other information from the message. @param message The incoming message to process.
[ "This", "is", "the", "application", "code", "for", "handling", "the", "message", "..", "Once", "the", "message", "is", "received", "the", "application", "can", "retrieve", "the", "soap", "part", "the", "attachment", "part", "if", "there", "are", "any", "or", "any", "other", "information", "from", "the", "message", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/message/service/src/main/java/org/jbundle/base/message/service/BaseServiceMessageTransport.java#L63-L97
154,017
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/QueryRecord.java
QueryRecord.getDatabaseName
public String getDatabaseName() { // ****Override this****, If not, try to figure it out if (m_vRecordList != null) if (this.getRecordlistAt(0) != null) return this.getRecordlistAt(0).getDatabaseName(); return DBConstants.BLANK; // Blank }
java
public String getDatabaseName() { // ****Override this****, If not, try to figure it out if (m_vRecordList != null) if (this.getRecordlistAt(0) != null) return this.getRecordlistAt(0).getDatabaseName(); return DBConstants.BLANK; // Blank }
[ "public", "String", "getDatabaseName", "(", ")", "{", "// ****Override this****, If not, try to figure it out", "if", "(", "m_vRecordList", "!=", "null", ")", "if", "(", "this", ".", "getRecordlistAt", "(", "0", ")", "!=", "null", ")", "return", "this", ".", "getRecordlistAt", "(", "0", ")", ".", "getDatabaseName", "(", ")", ";", "return", "DBConstants", ".", "BLANK", ";", "// Blank", "}" ]
Get the Database Name. Always override this method. @return The database name.
[ "Get", "the", "Database", "Name", ".", "Always", "override", "this", "method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/QueryRecord.java#L95-L102
154,018
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/QueryRecord.java
QueryRecord.getDatabaseType
public int getDatabaseType() { // ****Override this****, If not, try to figure it out if (m_vRecordList != null) if (this.getRecordlistAt(0) != null) return this.getRecordlistAt(0).getDatabaseType() & DBConstants.TABLE_MASK; // Only type and location return super.getDatabaseType(); // LOCAL }
java
public int getDatabaseType() { // ****Override this****, If not, try to figure it out if (m_vRecordList != null) if (this.getRecordlistAt(0) != null) return this.getRecordlistAt(0).getDatabaseType() & DBConstants.TABLE_MASK; // Only type and location return super.getDatabaseType(); // LOCAL }
[ "public", "int", "getDatabaseType", "(", ")", "{", "// ****Override this****, If not, try to figure it out", "if", "(", "m_vRecordList", "!=", "null", ")", "if", "(", "this", ".", "getRecordlistAt", "(", "0", ")", "!=", "null", ")", "return", "this", ".", "getRecordlistAt", "(", "0", ")", ".", "getDatabaseType", "(", ")", "&", "DBConstants", ".", "TABLE_MASK", ";", "// Only type and location", "return", "super", ".", "getDatabaseType", "(", ")", ";", "// LOCAL", "}" ]
Get the database type. Always override this method. @return The database type (LOCAL/REMOTE/SCREEN/etc).
[ "Get", "the", "database", "type", ".", "Always", "override", "this", "method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/QueryRecord.java#L108-L115
154,019
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/QueryRecord.java
QueryRecord.free
public void free() { super.free(); // Free first in case you have to Update() the current record! while (m_LinkageList.size() > 0) { TableLink tableLink = (TableLink)m_LinkageList.elementAt(0); tableLink.free(); } m_LinkageList.removeAllElements(); m_LinkageList = null; m_vRecordList.free(); // Free all the records m_vRecordList = null; }
java
public void free() { super.free(); // Free first in case you have to Update() the current record! while (m_LinkageList.size() > 0) { TableLink tableLink = (TableLink)m_LinkageList.elementAt(0); tableLink.free(); } m_LinkageList.removeAllElements(); m_LinkageList = null; m_vRecordList.free(); // Free all the records m_vRecordList = null; }
[ "public", "void", "free", "(", ")", "{", "super", ".", "free", "(", ")", ";", "// Free first in case you have to Update() the current record!", "while", "(", "m_LinkageList", ".", "size", "(", ")", ">", "0", ")", "{", "TableLink", "tableLink", "=", "(", "TableLink", ")", "m_LinkageList", ".", "elementAt", "(", "0", ")", ";", "tableLink", ".", "free", "(", ")", ";", "}", "m_LinkageList", ".", "removeAllElements", "(", ")", ";", "m_LinkageList", "=", "null", ";", "m_vRecordList", ".", "free", "(", ")", ";", "// Free all the records", "m_vRecordList", "=", "null", ";", "}" ]
Free the query record.
[ "Free", "the", "query", "record", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/QueryRecord.java#L119-L131
154,020
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/QueryRecord.java
QueryRecord.addSelectParams
public String addSelectParams(String seekSign, int areaDesc, boolean bAddOnlyMods, boolean bIncludeFileName, boolean bUseCurrentValues, Vector<BaseField> vParamList, boolean bForceUniqueKey, boolean bIncludeTempFields) { String sFilter = super.addSelectParams(seekSign, areaDesc, bAddOnlyMods, bIncludeFileName, bUseCurrentValues, vParamList, bForceUniqueKey, bIncludeTempFields); if (sFilter.length() > 0) return sFilter; // Sort string was specified for this "QueryRecord" for (int iIndex = 0; iIndex < this.getRecordlistCount(); iIndex++) { Record stmtTable = this.getRecordlistAt(iIndex); if (stmtTable != null) sFilter += stmtTable.addSelectParams(seekSign, areaDesc, bAddOnlyMods, bIncludeFileName, bUseCurrentValues, vParamList, bForceUniqueKey, bIncludeTempFields); } return sFilter; }
java
public String addSelectParams(String seekSign, int areaDesc, boolean bAddOnlyMods, boolean bIncludeFileName, boolean bUseCurrentValues, Vector<BaseField> vParamList, boolean bForceUniqueKey, boolean bIncludeTempFields) { String sFilter = super.addSelectParams(seekSign, areaDesc, bAddOnlyMods, bIncludeFileName, bUseCurrentValues, vParamList, bForceUniqueKey, bIncludeTempFields); if (sFilter.length() > 0) return sFilter; // Sort string was specified for this "QueryRecord" for (int iIndex = 0; iIndex < this.getRecordlistCount(); iIndex++) { Record stmtTable = this.getRecordlistAt(iIndex); if (stmtTable != null) sFilter += stmtTable.addSelectParams(seekSign, areaDesc, bAddOnlyMods, bIncludeFileName, bUseCurrentValues, vParamList, bForceUniqueKey, bIncludeTempFields); } return sFilter; }
[ "public", "String", "addSelectParams", "(", "String", "seekSign", ",", "int", "areaDesc", ",", "boolean", "bAddOnlyMods", ",", "boolean", "bIncludeFileName", ",", "boolean", "bUseCurrentValues", ",", "Vector", "<", "BaseField", ">", "vParamList", ",", "boolean", "bForceUniqueKey", ",", "boolean", "bIncludeTempFields", ")", "{", "String", "sFilter", "=", "super", ".", "addSelectParams", "(", "seekSign", ",", "areaDesc", ",", "bAddOnlyMods", ",", "bIncludeFileName", ",", "bUseCurrentValues", ",", "vParamList", ",", "bForceUniqueKey", ",", "bIncludeTempFields", ")", ";", "if", "(", "sFilter", ".", "length", "(", ")", ">", "0", ")", "return", "sFilter", ";", "// Sort string was specified for this \"QueryRecord\"", "for", "(", "int", "iIndex", "=", "0", ";", "iIndex", "<", "this", ".", "getRecordlistCount", "(", ")", ";", "iIndex", "++", ")", "{", "Record", "stmtTable", "=", "this", ".", "getRecordlistAt", "(", "iIndex", ")", ";", "if", "(", "stmtTable", "!=", "null", ")", "sFilter", "+=", "stmtTable", ".", "addSelectParams", "(", "seekSign", ",", "areaDesc", ",", "bAddOnlyMods", ",", "bIncludeFileName", ",", "bUseCurrentValues", ",", "vParamList", ",", "bForceUniqueKey", ",", "bIncludeTempFields", ")", ";", "}", "return", "sFilter", ";", "}" ]
Add to this SQL Key Filter. @param seekSign The seek sign. @param bAddOnlyMods Add only the keys which have modified? @param bIncludeFileName Include the file name in the string? @param bUseCurrentValues Use current values? @param vParamList The parameter list. @param bForceUniqueKey If params must be unique, if they aren't, add the unique key to the end. @param iAreaDesc The key area to select. @return The select string.
[ "Add", "to", "this", "SQL", "Key", "Filter", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/QueryRecord.java#L191-L203
154,021
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/QueryRecord.java
QueryRecord.getFieldCount
public int getFieldCount() { int iFieldCount = 0; for (int i = 0; i < this.getRecordlistCount(); i++) { iFieldCount += this.getRecordlistAt(i).getFieldCount(); } return iFieldCount; }
java
public int getFieldCount() { int iFieldCount = 0; for (int i = 0; i < this.getRecordlistCount(); i++) { iFieldCount += this.getRecordlistAt(i).getFieldCount(); } return iFieldCount; }
[ "public", "int", "getFieldCount", "(", ")", "{", "int", "iFieldCount", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "getRecordlistCount", "(", ")", ";", "i", "++", ")", "{", "iFieldCount", "+=", "this", ".", "getRecordlistAt", "(", "i", ")", ".", "getFieldCount", "(", ")", ";", "}", "return", "iFieldCount", ";", "}" ]
Number of Fields in this record. @return The field count.
[ "Number", "of", "Fields", "in", "this", "record", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/QueryRecord.java#L351-L359
154,022
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/QueryRecord.java
QueryRecord.getRecord
public Record getRecord(String sFileName) { Record pQueryCore = null; Record pStmtTable = null; pQueryCore = super.getRecord(sFileName); if (pQueryCore != null) return pQueryCore; for (int i = 0; i < this.getRecordlistCount(); i++) { pStmtTable = this.getRecordlistAt(i); pQueryCore = pStmtTable.getRecord(sFileName); if (pQueryCore != null) return pQueryCore; } return null; }
java
public Record getRecord(String sFileName) { Record pQueryCore = null; Record pStmtTable = null; pQueryCore = super.getRecord(sFileName); if (pQueryCore != null) return pQueryCore; for (int i = 0; i < this.getRecordlistCount(); i++) { pStmtTable = this.getRecordlistAt(i); pQueryCore = pStmtTable.getRecord(sFileName); if (pQueryCore != null) return pQueryCore; } return null; }
[ "public", "Record", "getRecord", "(", "String", "sFileName", ")", "{", "Record", "pQueryCore", "=", "null", ";", "Record", "pStmtTable", "=", "null", ";", "pQueryCore", "=", "super", ".", "getRecord", "(", "sFileName", ")", ";", "if", "(", "pQueryCore", "!=", "null", ")", "return", "pQueryCore", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "getRecordlistCount", "(", ")", ";", "i", "++", ")", "{", "pStmtTable", "=", "this", ".", "getRecordlistAt", "(", "i", ")", ";", "pQueryCore", "=", "pStmtTable", ".", "getRecord", "(", "sFileName", ")", ";", "if", "(", "pQueryCore", "!=", "null", ")", "return", "pQueryCore", ";", "}", "return", "null", ";", "}" ]
Get this table in the query. @param strFileName The record to retrieve. @return The record with this name.
[ "Get", "this", "table", "in", "the", "query", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/QueryRecord.java#L365-L380
154,023
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/QueryRecord.java
QueryRecord.moveTableQuery
public Record moveTableQuery(int iRelPosition) throws DBException { BaseTable table = null; Record record = null; Record recordLeft = null; boolean bFirstTime = true; for (Enumeration<TableLink> e = m_LinkageList.elements() ; e.hasMoreElements() ;) { TableLink tableLink = e.nextElement(); table = tableLink.getLeftRecord().getTable(); if (bFirstTime) { // First time through - far left table! recordLeft = record = (Record)table.move(iRelPosition); if (record == null) break; } table = tableLink.getRightRecord().getTable(); record = table.getRecord(); record.addNew(); tableLink.moveDataRight(); // Fill the right table with key boolean bFound = record.seek("="); if (!bFound) { if (tableLink.getJoinType() == DBConstants.LEFT_OUTER) // DBConstants.LEFT_INNER) record.initRecord(DBConstants.DISPLAY); else { // Skip this record **NOT TESTED** if ((iRelPosition > 0) || (iRelPosition == DBConstants.FIRST_RECORD)) return this.moveTableQuery(+1); return this.moveTableQuery(-1); } } bFirstTime = false; } // Sync the mode if (recordLeft != null) { // Special test for local criteria if ((this.handleLocalCriteria(null, false, null) == false) || (this.handleRemoteCriteria(null, false, null) == false)) { // This record didn't pass the test, get the next one that matches if ((iRelPosition > 0) || (iRelPosition == DBConstants.FIRST_RECORD)) return this.moveTableQuery(+1); return this.moveTableQuery(-1); } this.setEditMode(recordLeft.getEditMode()); } else this.setEditMode(DBConstants.END_OF_FILE); return recordLeft; }
java
public Record moveTableQuery(int iRelPosition) throws DBException { BaseTable table = null; Record record = null; Record recordLeft = null; boolean bFirstTime = true; for (Enumeration<TableLink> e = m_LinkageList.elements() ; e.hasMoreElements() ;) { TableLink tableLink = e.nextElement(); table = tableLink.getLeftRecord().getTable(); if (bFirstTime) { // First time through - far left table! recordLeft = record = (Record)table.move(iRelPosition); if (record == null) break; } table = tableLink.getRightRecord().getTable(); record = table.getRecord(); record.addNew(); tableLink.moveDataRight(); // Fill the right table with key boolean bFound = record.seek("="); if (!bFound) { if (tableLink.getJoinType() == DBConstants.LEFT_OUTER) // DBConstants.LEFT_INNER) record.initRecord(DBConstants.DISPLAY); else { // Skip this record **NOT TESTED** if ((iRelPosition > 0) || (iRelPosition == DBConstants.FIRST_RECORD)) return this.moveTableQuery(+1); return this.moveTableQuery(-1); } } bFirstTime = false; } // Sync the mode if (recordLeft != null) { // Special test for local criteria if ((this.handleLocalCriteria(null, false, null) == false) || (this.handleRemoteCriteria(null, false, null) == false)) { // This record didn't pass the test, get the next one that matches if ((iRelPosition > 0) || (iRelPosition == DBConstants.FIRST_RECORD)) return this.moveTableQuery(+1); return this.moveTableQuery(-1); } this.setEditMode(recordLeft.getEditMode()); } else this.setEditMode(DBConstants.END_OF_FILE); return recordLeft; }
[ "public", "Record", "moveTableQuery", "(", "int", "iRelPosition", ")", "throws", "DBException", "{", "BaseTable", "table", "=", "null", ";", "Record", "record", "=", "null", ";", "Record", "recordLeft", "=", "null", ";", "boolean", "bFirstTime", "=", "true", ";", "for", "(", "Enumeration", "<", "TableLink", ">", "e", "=", "m_LinkageList", ".", "elements", "(", ")", ";", "e", ".", "hasMoreElements", "(", ")", ";", ")", "{", "TableLink", "tableLink", "=", "e", ".", "nextElement", "(", ")", ";", "table", "=", "tableLink", ".", "getLeftRecord", "(", ")", ".", "getTable", "(", ")", ";", "if", "(", "bFirstTime", ")", "{", "// First time through - far left table!", "recordLeft", "=", "record", "=", "(", "Record", ")", "table", ".", "move", "(", "iRelPosition", ")", ";", "if", "(", "record", "==", "null", ")", "break", ";", "}", "table", "=", "tableLink", ".", "getRightRecord", "(", ")", ".", "getTable", "(", ")", ";", "record", "=", "table", ".", "getRecord", "(", ")", ";", "record", ".", "addNew", "(", ")", ";", "tableLink", ".", "moveDataRight", "(", ")", ";", "// Fill the right table with key", "boolean", "bFound", "=", "record", ".", "seek", "(", "\"=\"", ")", ";", "if", "(", "!", "bFound", ")", "{", "if", "(", "tableLink", ".", "getJoinType", "(", ")", "==", "DBConstants", ".", "LEFT_OUTER", ")", "// DBConstants.LEFT_INNER)", "record", ".", "initRecord", "(", "DBConstants", ".", "DISPLAY", ")", ";", "else", "{", "// Skip this record **NOT TESTED**", "if", "(", "(", "iRelPosition", ">", "0", ")", "||", "(", "iRelPosition", "==", "DBConstants", ".", "FIRST_RECORD", ")", ")", "return", "this", ".", "moveTableQuery", "(", "+", "1", ")", ";", "return", "this", ".", "moveTableQuery", "(", "-", "1", ")", ";", "}", "}", "bFirstTime", "=", "false", ";", "}", "// Sync the mode", "if", "(", "recordLeft", "!=", "null", ")", "{", "// Special test for local criteria", "if", "(", "(", "this", ".", "handleLocalCriteria", "(", "null", ",", "false", ",", "null", ")", "==", "false", ")", "||", "(", "this", ".", "handleRemoteCriteria", "(", "null", ",", "false", ",", "null", ")", "==", "false", ")", ")", "{", "// This record didn't pass the test, get the next one that matches", "if", "(", "(", "iRelPosition", ">", "0", ")", "||", "(", "iRelPosition", "==", "DBConstants", ".", "FIRST_RECORD", ")", ")", "return", "this", ".", "moveTableQuery", "(", "+", "1", ")", ";", "return", "this", ".", "moveTableQuery", "(", "-", "1", ")", ";", "}", "this", ".", "setEditMode", "(", "recordLeft", ".", "getEditMode", "(", ")", ")", ";", "}", "else", "this", ".", "setEditMode", "(", "DBConstants", ".", "END_OF_FILE", ")", ";", "return", "recordLeft", ";", "}" ]
Special logic to move a QueryRecord using the tables. The method also retrives any linked record. @param iRelPosition The positions to move. @return The record at this location. @exception DBException File exception.
[ "Special", "logic", "to", "move", "a", "QueryRecord", "using", "the", "tables", ".", "The", "method", "also", "retrives", "any", "linked", "record", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/QueryRecord.java#L438-L487
154,024
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/QueryRecord.java
QueryRecord.openTableQuery
public void openTableQuery() throws DBException { Record record = null; boolean bFirstTime = true; for (Enumeration<TableLink> e = m_LinkageList.elements() ; e.hasMoreElements() ;) { TableLink tableLink = e.nextElement(); record = tableLink.getLeftRecord(); if (bFirstTime) { if (!record.isOpen()) record.open(); } record = tableLink.getRightRecord(); if (!record.isOpen()) record.open(); bFirstTime = false; } }
java
public void openTableQuery() throws DBException { Record record = null; boolean bFirstTime = true; for (Enumeration<TableLink> e = m_LinkageList.elements() ; e.hasMoreElements() ;) { TableLink tableLink = e.nextElement(); record = tableLink.getLeftRecord(); if (bFirstTime) { if (!record.isOpen()) record.open(); } record = tableLink.getRightRecord(); if (!record.isOpen()) record.open(); bFirstTime = false; } }
[ "public", "void", "openTableQuery", "(", ")", "throws", "DBException", "{", "Record", "record", "=", "null", ";", "boolean", "bFirstTime", "=", "true", ";", "for", "(", "Enumeration", "<", "TableLink", ">", "e", "=", "m_LinkageList", ".", "elements", "(", ")", ";", "e", ".", "hasMoreElements", "(", ")", ";", ")", "{", "TableLink", "tableLink", "=", "e", ".", "nextElement", "(", ")", ";", "record", "=", "tableLink", ".", "getLeftRecord", "(", ")", ";", "if", "(", "bFirstTime", ")", "{", "if", "(", "!", "record", ".", "isOpen", "(", ")", ")", "record", ".", "open", "(", ")", ";", "}", "record", "=", "tableLink", ".", "getRightRecord", "(", ")", ";", "if", "(", "!", "record", ".", "isOpen", "(", ")", ")", "record", ".", "open", "(", ")", ";", "bFirstTime", "=", "false", ";", "}", "}" ]
Special logic to open a QueryRecord using the tables. @exception DBException File exception.
[ "Special", "logic", "to", "open", "a", "QueryRecord", "using", "the", "tables", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/QueryRecord.java#L492-L510
154,025
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/QueryRecord.java
QueryRecord.checkLinkedFields
public void checkLinkedFields() { if (this.isManualQuery()) // ? Manually set up query? { // It is a requirement that all linked fields be selected in case a manual query is needed for (Enumeration<TableLink> e = m_LinkageList.elements() ; e.hasMoreElements() ;) { TableLink tableLink = e.nextElement(); for (int i = 0; i < 3; i++) { if (tableLink.getLeftField(i) != null) tableLink.getLeftField(i).setSelected(true); if (tableLink.getRightField(i) != null) tableLink.getRightField(i).setSelected(true); } } } }
java
public void checkLinkedFields() { if (this.isManualQuery()) // ? Manually set up query? { // It is a requirement that all linked fields be selected in case a manual query is needed for (Enumeration<TableLink> e = m_LinkageList.elements() ; e.hasMoreElements() ;) { TableLink tableLink = e.nextElement(); for (int i = 0; i < 3; i++) { if (tableLink.getLeftField(i) != null) tableLink.getLeftField(i).setSelected(true); if (tableLink.getRightField(i) != null) tableLink.getRightField(i).setSelected(true); } } } }
[ "public", "void", "checkLinkedFields", "(", ")", "{", "if", "(", "this", ".", "isManualQuery", "(", ")", ")", "// ? Manually set up query?", "{", "// It is a requirement that all linked fields be selected in case a manual query is needed", "for", "(", "Enumeration", "<", "TableLink", ">", "e", "=", "m_LinkageList", ".", "elements", "(", ")", ";", "e", ".", "hasMoreElements", "(", ")", ";", ")", "{", "TableLink", "tableLink", "=", "e", ".", "nextElement", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "3", ";", "i", "++", ")", "{", "if", "(", "tableLink", ".", "getLeftField", "(", "i", ")", "!=", "null", ")", "tableLink", ".", "getLeftField", "(", "i", ")", ".", "setSelected", "(", "true", ")", ";", "if", "(", "tableLink", ".", "getRightField", "(", "i", ")", "!=", "null", ")", "tableLink", ".", "getRightField", "(", "i", ")", ".", "setSelected", "(", "true", ")", ";", "}", "}", "}", "}" ]
Make sure all the linked fields are selected.
[ "Make", "sure", "all", "the", "linked", "fields", "are", "selected", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/QueryRecord.java#L564-L580
154,026
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/QueryRecord.java
QueryRecord.isComplexQuery
public boolean isComplexQuery() { for (int i = 0; i < this.getRecordlistCount(); i++) { if (this.getRecordlistAt(i).getTable() instanceof org.jbundle.base.db.shared.MultiTable) return true; } return false; }
java
public boolean isComplexQuery() { for (int i = 0; i < this.getRecordlistCount(); i++) { if (this.getRecordlistAt(i).getTable() instanceof org.jbundle.base.db.shared.MultiTable) return true; } return false; }
[ "public", "boolean", "isComplexQuery", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "getRecordlistCount", "(", ")", ";", "i", "++", ")", "{", "if", "(", "this", ".", "getRecordlistAt", "(", "i", ")", ".", "getTable", "(", ")", "instanceof", "org", ".", "jbundle", ".", "base", ".", "db", ".", "shared", ".", "MultiTable", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
Is one of the sub-queries a multi-table. @return true if this is a query on top of an object query.
[ "Is", "one", "of", "the", "sub", "-", "queries", "a", "multi", "-", "table", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/QueryRecord.java#L633-L641
154,027
lshift/jamume
src/main/java/net/lshift/java/dispatch/DefaultDirectSuperclasses.java
DefaultDirectSuperclasses.makeArrayClasses
public static List<Class<?>> makeArrayClasses(List<Class<?>> classes, int dims) { Iterator<Class<?>> i = classes.iterator(); LinkedList<Class<?>> arrayClasses = new LinkedList<Class<?>>(); while(i.hasNext()) arrayClasses.add(makeArrayClass(i.next(), dims)); return arrayClasses; }
java
public static List<Class<?>> makeArrayClasses(List<Class<?>> classes, int dims) { Iterator<Class<?>> i = classes.iterator(); LinkedList<Class<?>> arrayClasses = new LinkedList<Class<?>>(); while(i.hasNext()) arrayClasses.add(makeArrayClass(i.next(), dims)); return arrayClasses; }
[ "public", "static", "List", "<", "Class", "<", "?", ">", ">", "makeArrayClasses", "(", "List", "<", "Class", "<", "?", ">", ">", "classes", ",", "int", "dims", ")", "{", "Iterator", "<", "Class", "<", "?", ">", ">", "i", "=", "classes", ".", "iterator", "(", ")", ";", "LinkedList", "<", "Class", "<", "?", ">", ">", "arrayClasses", "=", "new", "LinkedList", "<", "Class", "<", "?", ">", ">", "(", ")", ";", "while", "(", "i", ".", "hasNext", "(", ")", ")", "arrayClasses", ".", "add", "(", "makeArrayClass", "(", "i", ".", "next", "(", ")", ",", "dims", ")", ")", ";", "return", "arrayClasses", ";", "}" ]
this compensates for the lack of map
[ "this", "compensates", "for", "the", "lack", "of", "map" ]
754d9ab29311601328a2f39928775e4e010305b7
https://github.com/lshift/jamume/blob/754d9ab29311601328a2f39928775e4e010305b7/src/main/java/net/lshift/java/dispatch/DefaultDirectSuperclasses.java#L133-L140
154,028
jbundle/jbundle
main/remote/src/main/java/org/jbundle/main/remote/MenusSession.java
MenusSession.addListeners
public void addListeners() { super.addListeners(); try { this.doRemoteAction(DBConstants.BLANK, null); // Initial default menu } catch (Exception ex) { // Never } Record recMenus = this.getMainRecord(); recMenus.setOpenMode(DBConstants.OPEN_NORMAL); // Double check to see that I don't update on change recMenus.addListener(new FileListener(null) { /** * Called when a valid record is read from the table/query. * @param bDisplayOption If true, display any changes. */ public void doValidRecord(boolean bDisplayOption) // init this field override for other value { // Convert the XMLProperties field to a URL type string (yikes... in the same field) Record recMenus = this.getOwner(); XMLPropertiesField field = (XMLPropertiesField)recMenus.getField(Menus.PARAMS); Map<String,Object> properties = field.getProperties(); String strURL = null; strURL = Utility.propertiesToURL(strURL, properties); if (strURL != null) if (strURL.length() > 0) if (strURL.charAt(0) == '?') strURL = strURL.substring(1); field.setString(strURL); super.doValidRecord(bDisplayOption); } }); }
java
public void addListeners() { super.addListeners(); try { this.doRemoteAction(DBConstants.BLANK, null); // Initial default menu } catch (Exception ex) { // Never } Record recMenus = this.getMainRecord(); recMenus.setOpenMode(DBConstants.OPEN_NORMAL); // Double check to see that I don't update on change recMenus.addListener(new FileListener(null) { /** * Called when a valid record is read from the table/query. * @param bDisplayOption If true, display any changes. */ public void doValidRecord(boolean bDisplayOption) // init this field override for other value { // Convert the XMLProperties field to a URL type string (yikes... in the same field) Record recMenus = this.getOwner(); XMLPropertiesField field = (XMLPropertiesField)recMenus.getField(Menus.PARAMS); Map<String,Object> properties = field.getProperties(); String strURL = null; strURL = Utility.propertiesToURL(strURL, properties); if (strURL != null) if (strURL.length() > 0) if (strURL.charAt(0) == '?') strURL = strURL.substring(1); field.setString(strURL); super.doValidRecord(bDisplayOption); } }); }
[ "public", "void", "addListeners", "(", ")", "{", "super", ".", "addListeners", "(", ")", ";", "try", "{", "this", ".", "doRemoteAction", "(", "DBConstants", ".", "BLANK", ",", "null", ")", ";", "// Initial default menu", "}", "catch", "(", "Exception", "ex", ")", "{", "// Never", "}", "Record", "recMenus", "=", "this", ".", "getMainRecord", "(", ")", ";", "recMenus", ".", "setOpenMode", "(", "DBConstants", ".", "OPEN_NORMAL", ")", ";", "// Double check to see that I don't update on change", "recMenus", ".", "addListener", "(", "new", "FileListener", "(", "null", ")", "{", "/**\n * Called when a valid record is read from the table/query.\n * @param bDisplayOption If true, display any changes.\n */", "public", "void", "doValidRecord", "(", "boolean", "bDisplayOption", ")", "// init this field override for other value", "{", "// Convert the XMLProperties field to a URL type string (yikes... in the same field)", "Record", "recMenus", "=", "this", ".", "getOwner", "(", ")", ";", "XMLPropertiesField", "field", "=", "(", "XMLPropertiesField", ")", "recMenus", ".", "getField", "(", "Menus", ".", "PARAMS", ")", ";", "Map", "<", "String", ",", "Object", ">", "properties", "=", "field", ".", "getProperties", "(", ")", ";", "String", "strURL", "=", "null", ";", "strURL", "=", "Utility", ".", "propertiesToURL", "(", "strURL", ",", "properties", ")", ";", "if", "(", "strURL", "!=", "null", ")", "if", "(", "strURL", ".", "length", "(", ")", ">", "0", ")", "if", "(", "strURL", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "strURL", "=", "strURL", ".", "substring", "(", "1", ")", ";", "field", ".", "setString", "(", "strURL", ")", ";", "super", ".", "doValidRecord", "(", "bDisplayOption", ")", ";", "}", "}", ")", ";", "}" ]
Add behaviors to this session.
[ "Add", "behaviors", "to", "this", "session", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/remote/src/main/java/org/jbundle/main/remote/MenusSession.java#L65-L96
154,029
jbundle/jbundle
main/remote/src/main/java/org/jbundle/main/remote/MenusSession.java
MenusSession.setupSubMenus
public void setupSubMenus(String strMenu) { Record recMenu = this.getMainRecord(); try { String strCommandNoCommas = Utility.replace(strMenu, ",", null); // Get any commas out boolean bIsNumeric = Utility.isNumeric(strCommandNoCommas); if (bIsNumeric) { recMenu.setKeyArea(Menus.ID_KEY); recMenu.getField(Menus.ID).setString(strCommandNoCommas); bIsNumeric = recMenu.seek("="); } if (!bIsNumeric) { recMenu.setKeyArea(Menus.CODE_KEY); recMenu.getField(Menus.CODE).setString(strMenu); if (!recMenu.seek("=")) { // Not found, try the default main menu recMenu.getField(Menus.CODE).setString(HtmlConstants.MAIN_MENU_KEY); recMenu.seek("="); } } } catch (DBException ex) { ex.printStackTrace(); // Never } String strParentID = recMenu.getField(Menus.ID).toString(); BaseListener listener = recMenu.getListener(StringSubFileFilter.class.getName()); if (listener != null) { // Should just change the string recMenu.removeListener(listener, true); } recMenu.setKeyArea(Menus.PARENT_FOLDER_ID_KEY); recMenu.addListener(new StringSubFileFilter(strParentID, recMenu.getField(Menus.PARENT_FOLDER_ID), null, null, null, null)); }
java
public void setupSubMenus(String strMenu) { Record recMenu = this.getMainRecord(); try { String strCommandNoCommas = Utility.replace(strMenu, ",", null); // Get any commas out boolean bIsNumeric = Utility.isNumeric(strCommandNoCommas); if (bIsNumeric) { recMenu.setKeyArea(Menus.ID_KEY); recMenu.getField(Menus.ID).setString(strCommandNoCommas); bIsNumeric = recMenu.seek("="); } if (!bIsNumeric) { recMenu.setKeyArea(Menus.CODE_KEY); recMenu.getField(Menus.CODE).setString(strMenu); if (!recMenu.seek("=")) { // Not found, try the default main menu recMenu.getField(Menus.CODE).setString(HtmlConstants.MAIN_MENU_KEY); recMenu.seek("="); } } } catch (DBException ex) { ex.printStackTrace(); // Never } String strParentID = recMenu.getField(Menus.ID).toString(); BaseListener listener = recMenu.getListener(StringSubFileFilter.class.getName()); if (listener != null) { // Should just change the string recMenu.removeListener(listener, true); } recMenu.setKeyArea(Menus.PARENT_FOLDER_ID_KEY); recMenu.addListener(new StringSubFileFilter(strParentID, recMenu.getField(Menus.PARENT_FOLDER_ID), null, null, null, null)); }
[ "public", "void", "setupSubMenus", "(", "String", "strMenu", ")", "{", "Record", "recMenu", "=", "this", ".", "getMainRecord", "(", ")", ";", "try", "{", "String", "strCommandNoCommas", "=", "Utility", ".", "replace", "(", "strMenu", ",", "\",\"", ",", "null", ")", ";", "// Get any commas out", "boolean", "bIsNumeric", "=", "Utility", ".", "isNumeric", "(", "strCommandNoCommas", ")", ";", "if", "(", "bIsNumeric", ")", "{", "recMenu", ".", "setKeyArea", "(", "Menus", ".", "ID_KEY", ")", ";", "recMenu", ".", "getField", "(", "Menus", ".", "ID", ")", ".", "setString", "(", "strCommandNoCommas", ")", ";", "bIsNumeric", "=", "recMenu", ".", "seek", "(", "\"=\"", ")", ";", "}", "if", "(", "!", "bIsNumeric", ")", "{", "recMenu", ".", "setKeyArea", "(", "Menus", ".", "CODE_KEY", ")", ";", "recMenu", ".", "getField", "(", "Menus", ".", "CODE", ")", ".", "setString", "(", "strMenu", ")", ";", "if", "(", "!", "recMenu", ".", "seek", "(", "\"=\"", ")", ")", "{", "// Not found, try the default main menu", "recMenu", ".", "getField", "(", "Menus", ".", "CODE", ")", ".", "setString", "(", "HtmlConstants", ".", "MAIN_MENU_KEY", ")", ";", "recMenu", ".", "seek", "(", "\"=\"", ")", ";", "}", "}", "}", "catch", "(", "DBException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "// Never", "}", "String", "strParentID", "=", "recMenu", ".", "getField", "(", "Menus", ".", "ID", ")", ".", "toString", "(", ")", ";", "BaseListener", "listener", "=", "recMenu", ".", "getListener", "(", "StringSubFileFilter", ".", "class", ".", "getName", "(", ")", ")", ";", "if", "(", "listener", "!=", "null", ")", "{", "// Should just change the string", "recMenu", ".", "removeListener", "(", "listener", ",", "true", ")", ";", "}", "recMenu", ".", "setKeyArea", "(", "Menus", ".", "PARENT_FOLDER_ID_KEY", ")", ";", "recMenu", ".", "addListener", "(", "new", "StringSubFileFilter", "(", "strParentID", ",", "recMenu", ".", "getField", "(", "Menus", ".", "PARENT_FOLDER_ID", ")", ",", "null", ",", "null", ",", "null", ",", "null", ")", ")", ";", "}" ]
SetupSubMenus Method.
[ "SetupSubMenus", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/remote/src/main/java/org/jbundle/main/remote/MenusSession.java#L131-L164
154,030
Joe0/Feather
src/main/java/com/joepritzel/feather/PSBrokerBuilder.java
PSBrokerBuilder.typeToSubscriberMapping
public PSBrokerBuilder typeToSubscriberMapping( ConcurrentMap<Class<?>, List<SubscriberParent>> mapping) { broker.mapping = mapping; return this; }
java
public PSBrokerBuilder typeToSubscriberMapping( ConcurrentMap<Class<?>, List<SubscriberParent>> mapping) { broker.mapping = mapping; return this; }
[ "public", "PSBrokerBuilder", "typeToSubscriberMapping", "(", "ConcurrentMap", "<", "Class", "<", "?", ">", ",", "List", "<", "SubscriberParent", ">", ">", "mapping", ")", "{", "broker", ".", "mapping", "=", "mapping", ";", "return", "this", ";", "}" ]
The map that should be used internally, that maps types to a list of subscribers. @param mapping - The map to be used.
[ "The", "map", "that", "should", "be", "used", "internally", "that", "maps", "types", "to", "a", "list", "of", "subscribers", "." ]
d17b1bc38326b8b86f1068898a59c8a34678d499
https://github.com/Joe0/Feather/blob/d17b1bc38326b8b86f1068898a59c8a34678d499/src/main/java/com/joepritzel/feather/PSBrokerBuilder.java#L65-L69
154,031
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/QueryTable.java
QueryTable.init
public void init(BaseDatabase database, Record record) { super.init(database, record); if (((QueryRecord)record).getBaseRecord() != null) m_tableNext = ((QueryRecord)record).getBaseRecord().getTable(); // Pass most commands thru to the main record's table }
java
public void init(BaseDatabase database, Record record) { super.init(database, record); if (((QueryRecord)record).getBaseRecord() != null) m_tableNext = ((QueryRecord)record).getBaseRecord().getTable(); // Pass most commands thru to the main record's table }
[ "public", "void", "init", "(", "BaseDatabase", "database", ",", "Record", "record", ")", "{", "super", ".", "init", "(", "database", ",", "record", ")", ";", "if", "(", "(", "(", "QueryRecord", ")", "record", ")", ".", "getBaseRecord", "(", ")", "!=", "null", ")", "m_tableNext", "=", "(", "(", "QueryRecord", ")", "record", ")", ".", "getBaseRecord", "(", ")", ".", "getTable", "(", ")", ";", "// Pass most commands thru to the main record's table", "}" ]
QueryTable Constructor. @param database The database for this table. @param record The queryRecord for this table.
[ "QueryTable", "Constructor", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/QueryTable.java#L46-L51
154,032
gdx-libs/gdx-autumn
src/com/github/czyzby/autumn/context/ContextInitializer.java
ContextInitializer.addIfNotNull
protected <Type> void addIfNotNull(final Array<Type> array, final Type object) { if (object != null) { array.add(object); } }
java
protected <Type> void addIfNotNull(final Array<Type> array, final Type object) { if (object != null) { array.add(object); } }
[ "protected", "<", "Type", ">", "void", "addIfNotNull", "(", "final", "Array", "<", "Type", ">", "array", ",", "final", "Type", "object", ")", "{", "if", "(", "object", "!=", "null", ")", "{", "array", ".", "add", "(", "object", ")", ";", "}", "}" ]
Simple array utility. @param array will contain the object if it's not null. @param object if not null, will be added to the array. @param <Type> type of values stored in the array.
[ "Simple", "array", "utility", "." ]
75a7d8e0c838b69a06ae847f5a3c13a3bcd1d914
https://github.com/gdx-libs/gdx-autumn/blob/75a7d8e0c838b69a06ae847f5a3c13a3bcd1d914/src/com/github/czyzby/autumn/context/ContextInitializer.java#L394-L398
154,033
mbenson/uelbox
src/main/java/uelbox/IterableELResolver.java
IterableELResolver.seek
private static Iterator<?> seek(ELContext context, Object base, Object property) { if (base instanceof Iterable<?>) { context.setPropertyResolved(true); int index = toIndex(context, property); if (index >= 0) { Iterator<?> result = ((Iterable<?>) base).iterator(); for (int i = 0; i < index && result.hasNext(); i++) { result.next(); } if (result.hasNext()) { return result; } throw new PropertyNotFoundException(String.valueOf(property)); } } return null; }
java
private static Iterator<?> seek(ELContext context, Object base, Object property) { if (base instanceof Iterable<?>) { context.setPropertyResolved(true); int index = toIndex(context, property); if (index >= 0) { Iterator<?> result = ((Iterable<?>) base).iterator(); for (int i = 0; i < index && result.hasNext(); i++) { result.next(); } if (result.hasNext()) { return result; } throw new PropertyNotFoundException(String.valueOf(property)); } } return null; }
[ "private", "static", "Iterator", "<", "?", ">", "seek", "(", "ELContext", "context", ",", "Object", "base", ",", "Object", "property", ")", "{", "if", "(", "base", "instanceof", "Iterable", "<", "?", ">", ")", "{", "context", ".", "setPropertyResolved", "(", "true", ")", ";", "int", "index", "=", "toIndex", "(", "context", ",", "property", ")", ";", "if", "(", "index", ">=", "0", ")", "{", "Iterator", "<", "?", ">", "result", "=", "(", "(", "Iterable", "<", "?", ">", ")", "base", ")", ".", "iterator", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "index", "&&", "result", ".", "hasNext", "(", ")", ";", "i", "++", ")", "{", "result", ".", "next", "(", ")", ";", "}", "if", "(", "result", ".", "hasNext", "(", ")", ")", "{", "return", "result", ";", "}", "throw", "new", "PropertyNotFoundException", "(", "String", ".", "valueOf", "(", "property", ")", ")", ";", "}", "}", "return", "null", ";", "}" ]
Establishes an Iterator and advances it to the specified index. If this operation succeeds the context will be set as having been resolved. @param context @param base @param property @return Iterator @throws PropertyNotFoundException if index is out of bounds
[ "Establishes", "an", "Iterator", "and", "advances", "it", "to", "the", "specified", "index", ".", "If", "this", "operation", "succeeds", "the", "context", "will", "be", "set", "as", "having", "been", "resolved", "." ]
b0c2df2c738295bddfd3c16a916e67c9c7c512ef
https://github.com/mbenson/uelbox/blob/b0c2df2c738295bddfd3c16a916e67c9c7c512ef/src/main/java/uelbox/IterableELResolver.java#L90-L106
154,034
GII/broccoli
broccoli-owls/src/main/java/com/hi3project/broccoli/bsdf/impl/owls/serviceBuilder/DynamicAtomicJavaGroundingFactory.java
DynamicAtomicJavaGroundingFactory.generateOWLGrounding
public Grounding generateOWLGrounding(Service service) throws DynamicGroundingBuildingException { JavaGrounding javaGrounding = service.getOntology().createJavaGrounding(null); JavaAtomicGrounding javaAtomicGrounding = service.getOntology().createJavaAtomicGrounding(null); AtomicProcess atomicProcess = service.getProcess().castTo(AtomicProcess.class); URI javaTransformatorURI = null; try { javaTransformatorURI = new URI(javaTransformatorURL); } catch (URISyntaxException ex) { throw new DynamicGroundingBuildingException("cannot load needed ontology on " + javaTransformatorURL); } // set Output with transformatorClass javaAtomicGrounding.setOutput(null, method().getReturnType().getName(), atomicProcess.getOutput()); javaAtomicGrounding.getOutput().addProperty(javaTransformatorURI, service.getKB().createDataValue(javaTransformatorClass)); // add Inputs with transformatorClass OWLIndividualList<Input> inputs = atomicProcess.getInputs(); Class<?>[] methodParameterTypes = method().getParameterTypes(); if (inputs.size() != methodParameterTypes.length) { throw new DynamicGroundingBuildingException("the method (" + ") and the service have different number of input parameters"); } for (int i = 0; i < inputs.size(); i++) { javaAtomicGrounding.addInputParameter(null, methodParameterTypes[i].getName(), i, inputs.get(i)); } for (Iterator<Input> it = inputs.iterator(); it.hasNext();) { javaAtomicGrounding.getInputParamter(it.next()).addProperty(javaTransformatorURI, service.getKB().createDataValue(javaTransformatorClass)); } // set Class and Method javaAtomicGrounding.setClazz(clas.getName()); javaAtomicGrounding.setMethod(methodName); javaAtomicGrounding.setProcess(atomicProcess); javaGrounding.addGrounding(javaAtomicGrounding); javaGrounding.setService(service); service.addGrounding(javaGrounding); return javaGrounding; }
java
public Grounding generateOWLGrounding(Service service) throws DynamicGroundingBuildingException { JavaGrounding javaGrounding = service.getOntology().createJavaGrounding(null); JavaAtomicGrounding javaAtomicGrounding = service.getOntology().createJavaAtomicGrounding(null); AtomicProcess atomicProcess = service.getProcess().castTo(AtomicProcess.class); URI javaTransformatorURI = null; try { javaTransformatorURI = new URI(javaTransformatorURL); } catch (URISyntaxException ex) { throw new DynamicGroundingBuildingException("cannot load needed ontology on " + javaTransformatorURL); } // set Output with transformatorClass javaAtomicGrounding.setOutput(null, method().getReturnType().getName(), atomicProcess.getOutput()); javaAtomicGrounding.getOutput().addProperty(javaTransformatorURI, service.getKB().createDataValue(javaTransformatorClass)); // add Inputs with transformatorClass OWLIndividualList<Input> inputs = atomicProcess.getInputs(); Class<?>[] methodParameterTypes = method().getParameterTypes(); if (inputs.size() != methodParameterTypes.length) { throw new DynamicGroundingBuildingException("the method (" + ") and the service have different number of input parameters"); } for (int i = 0; i < inputs.size(); i++) { javaAtomicGrounding.addInputParameter(null, methodParameterTypes[i].getName(), i, inputs.get(i)); } for (Iterator<Input> it = inputs.iterator(); it.hasNext();) { javaAtomicGrounding.getInputParamter(it.next()).addProperty(javaTransformatorURI, service.getKB().createDataValue(javaTransformatorClass)); } // set Class and Method javaAtomicGrounding.setClazz(clas.getName()); javaAtomicGrounding.setMethod(methodName); javaAtomicGrounding.setProcess(atomicProcess); javaGrounding.addGrounding(javaAtomicGrounding); javaGrounding.setService(service); service.addGrounding(javaGrounding); return javaGrounding; }
[ "public", "Grounding", "generateOWLGrounding", "(", "Service", "service", ")", "throws", "DynamicGroundingBuildingException", "{", "JavaGrounding", "javaGrounding", "=", "service", ".", "getOntology", "(", ")", ".", "createJavaGrounding", "(", "null", ")", ";", "JavaAtomicGrounding", "javaAtomicGrounding", "=", "service", ".", "getOntology", "(", ")", ".", "createJavaAtomicGrounding", "(", "null", ")", ";", "AtomicProcess", "atomicProcess", "=", "service", ".", "getProcess", "(", ")", ".", "castTo", "(", "AtomicProcess", ".", "class", ")", ";", "URI", "javaTransformatorURI", "=", "null", ";", "try", "{", "javaTransformatorURI", "=", "new", "URI", "(", "javaTransformatorURL", ")", ";", "}", "catch", "(", "URISyntaxException", "ex", ")", "{", "throw", "new", "DynamicGroundingBuildingException", "(", "\"cannot load needed ontology on \"", "+", "javaTransformatorURL", ")", ";", "}", "// set Output with transformatorClass", "javaAtomicGrounding", ".", "setOutput", "(", "null", ",", "method", "(", ")", ".", "getReturnType", "(", ")", ".", "getName", "(", ")", ",", "atomicProcess", ".", "getOutput", "(", ")", ")", ";", "javaAtomicGrounding", ".", "getOutput", "(", ")", ".", "addProperty", "(", "javaTransformatorURI", ",", "service", ".", "getKB", "(", ")", ".", "createDataValue", "(", "javaTransformatorClass", ")", ")", ";", "// add Inputs with transformatorClass ", "OWLIndividualList", "<", "Input", ">", "inputs", "=", "atomicProcess", ".", "getInputs", "(", ")", ";", "Class", "<", "?", ">", "[", "]", "methodParameterTypes", "=", "method", "(", ")", ".", "getParameterTypes", "(", ")", ";", "if", "(", "inputs", ".", "size", "(", ")", "!=", "methodParameterTypes", ".", "length", ")", "{", "throw", "new", "DynamicGroundingBuildingException", "(", "\"the method (\"", "+", "\") and the service have different number of input parameters\"", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "inputs", ".", "size", "(", ")", ";", "i", "++", ")", "{", "javaAtomicGrounding", ".", "addInputParameter", "(", "null", ",", "methodParameterTypes", "[", "i", "]", ".", "getName", "(", ")", ",", "i", ",", "inputs", ".", "get", "(", "i", ")", ")", ";", "}", "for", "(", "Iterator", "<", "Input", ">", "it", "=", "inputs", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "javaAtomicGrounding", ".", "getInputParamter", "(", "it", ".", "next", "(", ")", ")", ".", "addProperty", "(", "javaTransformatorURI", ",", "service", ".", "getKB", "(", ")", ".", "createDataValue", "(", "javaTransformatorClass", ")", ")", ";", "}", "// set Class and Method", "javaAtomicGrounding", ".", "setClazz", "(", "clas", ".", "getName", "(", ")", ")", ";", "javaAtomicGrounding", ".", "setMethod", "(", "methodName", ")", ";", "javaAtomicGrounding", ".", "setProcess", "(", "atomicProcess", ")", ";", "javaGrounding", ".", "addGrounding", "(", "javaAtomicGrounding", ")", ";", "javaGrounding", ".", "setService", "(", "service", ")", ";", "service", ".", "addGrounding", "(", "javaGrounding", ")", ";", "return", "javaGrounding", ";", "}" ]
It automatically creates Output and Inputs assigning them a Java Transformator class @param service @return @throws DynamicGroundingBuildingException
[ "It", "automatically", "creates", "Output", "and", "Inputs", "assigning", "them", "a", "Java", "Transformator", "class" ]
a3033a90322cbcee4dc0f1719143b84b822bc4ba
https://github.com/GII/broccoli/blob/a3033a90322cbcee4dc0f1719143b84b822bc4ba/broccoli-owls/src/main/java/com/hi3project/broccoli/bsdf/impl/owls/serviceBuilder/DynamicAtomicJavaGroundingFactory.java#L75-L112
154,035
Stratio/stratio-connector-commons
connector-commons/src/main/java/com/stratio/connector/commons/engine/query/ProjectParsed.java
ProjectParsed.addLogicalStep
private void addLogicalStep(LogicalStep lStep) throws ExecutionException { if (lStep instanceof Project) { project = (Project) lStep; } else if (lStep instanceof Filter) { decideTypeFilterToAdd((Filter) lStep); } else if (lStep instanceof FunctionFilter){ functionFilters.add((FunctionFilter) lStep); }else if (lStep instanceof Select) { select = (Select) lStep; } else if (lStep instanceof Limit) { limit = (Limit) lStep; } else if (lStep instanceof GroupBy) { groupBy = (GroupBy) lStep; } else if (lStep instanceof Window) { window = (Window) lStep; } else if (lStep instanceof OrderBy) { orderBy = (OrderBy) lStep; }else if (lStep instanceof Disjunction){ switchDisjunctionList((Disjunction) lStep); } else { String message = "LogicalStep [" + lStep.getClass().getCanonicalName() + " not supported"; logger.error(message); throw new ExecutionException(message); } }
java
private void addLogicalStep(LogicalStep lStep) throws ExecutionException { if (lStep instanceof Project) { project = (Project) lStep; } else if (lStep instanceof Filter) { decideTypeFilterToAdd((Filter) lStep); } else if (lStep instanceof FunctionFilter){ functionFilters.add((FunctionFilter) lStep); }else if (lStep instanceof Select) { select = (Select) lStep; } else if (lStep instanceof Limit) { limit = (Limit) lStep; } else if (lStep instanceof GroupBy) { groupBy = (GroupBy) lStep; } else if (lStep instanceof Window) { window = (Window) lStep; } else if (lStep instanceof OrderBy) { orderBy = (OrderBy) lStep; }else if (lStep instanceof Disjunction){ switchDisjunctionList((Disjunction) lStep); } else { String message = "LogicalStep [" + lStep.getClass().getCanonicalName() + " not supported"; logger.error(message); throw new ExecutionException(message); } }
[ "private", "void", "addLogicalStep", "(", "LogicalStep", "lStep", ")", "throws", "ExecutionException", "{", "if", "(", "lStep", "instanceof", "Project", ")", "{", "project", "=", "(", "Project", ")", "lStep", ";", "}", "else", "if", "(", "lStep", "instanceof", "Filter", ")", "{", "decideTypeFilterToAdd", "(", "(", "Filter", ")", "lStep", ")", ";", "}", "else", "if", "(", "lStep", "instanceof", "FunctionFilter", ")", "{", "functionFilters", ".", "add", "(", "(", "FunctionFilter", ")", "lStep", ")", ";", "}", "else", "if", "(", "lStep", "instanceof", "Select", ")", "{", "select", "=", "(", "Select", ")", "lStep", ";", "}", "else", "if", "(", "lStep", "instanceof", "Limit", ")", "{", "limit", "=", "(", "Limit", ")", "lStep", ";", "}", "else", "if", "(", "lStep", "instanceof", "GroupBy", ")", "{", "groupBy", "=", "(", "GroupBy", ")", "lStep", ";", "}", "else", "if", "(", "lStep", "instanceof", "Window", ")", "{", "window", "=", "(", "Window", ")", "lStep", ";", "}", "else", "if", "(", "lStep", "instanceof", "OrderBy", ")", "{", "orderBy", "=", "(", "OrderBy", ")", "lStep", ";", "}", "else", "if", "(", "lStep", "instanceof", "Disjunction", ")", "{", "switchDisjunctionList", "(", "(", "Disjunction", ")", "lStep", ")", ";", "}", "else", "{", "String", "message", "=", "\"LogicalStep [\"", "+", "lStep", ".", "getClass", "(", ")", ".", "getCanonicalName", "(", ")", "+", "\" not supported\"", ";", "logger", ".", "error", "(", "message", ")", ";", "throw", "new", "ExecutionException", "(", "message", ")", ";", "}", "}" ]
This method add the correct logical step. @param lStep logical step. @throws ExecutionException if the logical step is not supported.
[ "This", "method", "add", "the", "correct", "logical", "step", "." ]
d7cc66cb9591344a13055962e87a91f01c3707d1
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/engine/query/ProjectParsed.java#L205-L237
154,036
Stratio/stratio-connector-commons
connector-commons/src/main/java/com/stratio/connector/commons/engine/query/ProjectParsed.java
ProjectParsed.decideTypeFilterToAdd
private void decideTypeFilterToAdd(Filter filter) { Filter step = filter; if (Operator.MATCH == step.getRelation().getOperator() || step.getRelation().getRightTerm() instanceof FunctionSelector) { if (matchList.isEmpty()) { matchList = new ArrayList<>(); } matchList.add(filter); } else { if (filterList.isEmpty()) { filterList = new ArrayList<>(); } filterList.add(filter); } }
java
private void decideTypeFilterToAdd(Filter filter) { Filter step = filter; if (Operator.MATCH == step.getRelation().getOperator() || step.getRelation().getRightTerm() instanceof FunctionSelector) { if (matchList.isEmpty()) { matchList = new ArrayList<>(); } matchList.add(filter); } else { if (filterList.isEmpty()) { filterList = new ArrayList<>(); } filterList.add(filter); } }
[ "private", "void", "decideTypeFilterToAdd", "(", "Filter", "filter", ")", "{", "Filter", "step", "=", "filter", ";", "if", "(", "Operator", ".", "MATCH", "==", "step", ".", "getRelation", "(", ")", ".", "getOperator", "(", ")", "||", "step", ".", "getRelation", "(", ")", ".", "getRightTerm", "(", ")", "instanceof", "FunctionSelector", ")", "{", "if", "(", "matchList", ".", "isEmpty", "(", ")", ")", "{", "matchList", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "matchList", ".", "add", "(", "filter", ")", ";", "}", "else", "{", "if", "(", "filterList", ".", "isEmpty", "(", ")", ")", "{", "filterList", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "filterList", ".", "add", "(", "filter", ")", ";", "}", "}" ]
Add filter in the correct list. @param filter the filter.
[ "Add", "filter", "in", "the", "correct", "list", "." ]
d7cc66cb9591344a13055962e87a91f01c3707d1
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/engine/query/ProjectParsed.java#L296-L311
154,037
jbundle/jbundle
thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageQueue.java
BaseMessageQueue.free
public void free() { if (m_receiver != null) m_receiver.free(); m_receiver = null; if (m_sender != null) m_sender.free(); m_sender = null; if (m_manager != null) m_manager.removeMessageQueue(this); m_manager = null; m_strQueueName = null; m_strQueueType = null; }
java
public void free() { if (m_receiver != null) m_receiver.free(); m_receiver = null; if (m_sender != null) m_sender.free(); m_sender = null; if (m_manager != null) m_manager.removeMessageQueue(this); m_manager = null; m_strQueueName = null; m_strQueueType = null; }
[ "public", "void", "free", "(", ")", "{", "if", "(", "m_receiver", "!=", "null", ")", "m_receiver", ".", "free", "(", ")", ";", "m_receiver", "=", "null", ";", "if", "(", "m_sender", "!=", "null", ")", "m_sender", ".", "free", "(", ")", ";", "m_sender", "=", "null", ";", "if", "(", "m_manager", "!=", "null", ")", "m_manager", ".", "removeMessageQueue", "(", "this", ")", ";", "m_manager", "=", "null", ";", "m_strQueueName", "=", "null", ";", "m_strQueueType", "=", "null", ";", "}" ]
Free all the resources belonging to this object.
[ "Free", "all", "the", "resources", "belonging", "to", "this", "object", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageQueue.java#L73-L88
154,038
jbundle/jbundle
thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageQueue.java
BaseMessageQueue.getMessageReceiver
public BaseMessageReceiver getMessageReceiver() { if (m_receiver == null) { m_receiver = this.createMessageReceiver(); if (m_receiver != null) new Thread(m_receiver, "MessageReceiver").start(); } return m_receiver; }
java
public BaseMessageReceiver getMessageReceiver() { if (m_receiver == null) { m_receiver = this.createMessageReceiver(); if (m_receiver != null) new Thread(m_receiver, "MessageReceiver").start(); } return m_receiver; }
[ "public", "BaseMessageReceiver", "getMessageReceiver", "(", ")", "{", "if", "(", "m_receiver", "==", "null", ")", "{", "m_receiver", "=", "this", ".", "createMessageReceiver", "(", ")", ";", "if", "(", "m_receiver", "!=", "null", ")", "new", "Thread", "(", "m_receiver", ",", "\"MessageReceiver\"", ")", ".", "start", "(", ")", ";", "}", "return", "m_receiver", ";", "}" ]
Get the message receiver. Create it if it doesn't exist. @return The message receiver.
[ "Get", "the", "message", "receiver", ".", "Create", "it", "if", "it", "doesn", "t", "exist", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageQueue.java#L170-L179
154,039
Stratio/stratio-connector-commons
connector-commons/src/main/java/com/stratio/connector/commons/util/ManifestUtil.java
ManifestUtil.getDatastoreName
public static String[] getDatastoreName(String pathManifest) throws InitializationException { String[] datastoreName = {""}; try { Document document = getDocument(pathManifest); // Search for the limit properties and connectorName Object result = getResult(document, "//DataStores/DataStoreName/text()"); datastoreName = new String[((NodeList) result).getLength()]; for (int i = 0; i < ((NodeList) result).getLength(); i++) { datastoreName[i] = ((NodeList) result).item(i).getNodeValue(); } } catch (SAXException | XPathExpressionException | IOException | ParserConfigurationException e) { String msg = "Impossible to read DataStoreName in Manifest with the connector configuration." + e.getCause(); LOGGER.error(msg); throw new InitializationException(msg, e); } return datastoreName; }
java
public static String[] getDatastoreName(String pathManifest) throws InitializationException { String[] datastoreName = {""}; try { Document document = getDocument(pathManifest); // Search for the limit properties and connectorName Object result = getResult(document, "//DataStores/DataStoreName/text()"); datastoreName = new String[((NodeList) result).getLength()]; for (int i = 0; i < ((NodeList) result).getLength(); i++) { datastoreName[i] = ((NodeList) result).item(i).getNodeValue(); } } catch (SAXException | XPathExpressionException | IOException | ParserConfigurationException e) { String msg = "Impossible to read DataStoreName in Manifest with the connector configuration." + e.getCause(); LOGGER.error(msg); throw new InitializationException(msg, e); } return datastoreName; }
[ "public", "static", "String", "[", "]", "getDatastoreName", "(", "String", "pathManifest", ")", "throws", "InitializationException", "{", "String", "[", "]", "datastoreName", "=", "{", "\"\"", "}", ";", "try", "{", "Document", "document", "=", "getDocument", "(", "pathManifest", ")", ";", "// Search for the limit properties and connectorName", "Object", "result", "=", "getResult", "(", "document", ",", "\"//DataStores/DataStoreName/text()\"", ")", ";", "datastoreName", "=", "new", "String", "[", "(", "(", "NodeList", ")", "result", ")", ".", "getLength", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "(", "(", "NodeList", ")", "result", ")", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "datastoreName", "[", "i", "]", "=", "(", "(", "NodeList", ")", "result", ")", ".", "item", "(", "i", ")", ".", "getNodeValue", "(", ")", ";", "}", "}", "catch", "(", "SAXException", "|", "XPathExpressionException", "|", "IOException", "|", "ParserConfigurationException", "e", ")", "{", "String", "msg", "=", "\"Impossible to read DataStoreName in Manifest with the connector configuration.\"", "+", "e", ".", "getCause", "(", ")", ";", "LOGGER", ".", "error", "(", "msg", ")", ";", "throw", "new", "InitializationException", "(", "msg", ",", "e", ")", ";", "}", "return", "datastoreName", ";", "}" ]
Recovered the datastoreName form Manifest. @param pathManifest the manifest path. @return the datastoreName. @throws InitializationException if an error happens while XML is reading.
[ "Recovered", "the", "datastoreName", "form", "Manifest", "." ]
d7cc66cb9591344a13055962e87a91f01c3707d1
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/util/ManifestUtil.java#L57-L77
154,040
Stratio/stratio-connector-commons
connector-commons/src/main/java/com/stratio/connector/commons/util/ManifestUtil.java
ManifestUtil.getConectorName
public static String getConectorName(String pathManifest) throws InitializationException { String connectionName = ""; try { Document document = getDocument(pathManifest); Object result = getResult(document, "//ConnectorName/text()"); connectionName = ((NodeList) result).item(0).getNodeValue(); } catch (SAXException | XPathExpressionException | IOException | ParserConfigurationException e) { String msg = "Impossible to read DataStoreName in Manifest with the connector configuration." + e.getCause(); LOGGER.error(msg); throw new InitializationException(msg, e); } return connectionName; }
java
public static String getConectorName(String pathManifest) throws InitializationException { String connectionName = ""; try { Document document = getDocument(pathManifest); Object result = getResult(document, "//ConnectorName/text()"); connectionName = ((NodeList) result).item(0).getNodeValue(); } catch (SAXException | XPathExpressionException | IOException | ParserConfigurationException e) { String msg = "Impossible to read DataStoreName in Manifest with the connector configuration." + e.getCause(); LOGGER.error(msg); throw new InitializationException(msg, e); } return connectionName; }
[ "public", "static", "String", "getConectorName", "(", "String", "pathManifest", ")", "throws", "InitializationException", "{", "String", "connectionName", "=", "\"\"", ";", "try", "{", "Document", "document", "=", "getDocument", "(", "pathManifest", ")", ";", "Object", "result", "=", "getResult", "(", "document", ",", "\"//ConnectorName/text()\"", ")", ";", "connectionName", "=", "(", "(", "NodeList", ")", "result", ")", ".", "item", "(", "0", ")", ".", "getNodeValue", "(", ")", ";", "}", "catch", "(", "SAXException", "|", "XPathExpressionException", "|", "IOException", "|", "ParserConfigurationException", "e", ")", "{", "String", "msg", "=", "\"Impossible to read DataStoreName in Manifest with the connector configuration.\"", "+", "e", ".", "getCause", "(", ")", ";", "LOGGER", ".", "error", "(", "msg", ")", ";", "throw", "new", "InitializationException", "(", "msg", ",", "e", ")", ";", "}", "return", "connectionName", ";", "}" ]
Recovered the ConecrtorName form Manifest. @param pathManifest the manifest path. @return the ConectionName. @throws InitializationException if an error happens while XML is reading.
[ "Recovered", "the", "ConecrtorName", "form", "Manifest", "." ]
d7cc66cb9591344a13055962e87a91f01c3707d1
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/util/ManifestUtil.java#L86-L103
154,041
Stratio/stratio-connector-commons
connector-commons/src/main/java/com/stratio/connector/commons/util/ManifestUtil.java
ManifestUtil.getResult
private static Object getResult(Document document, String node) throws XPathExpressionException { // create an XPath object XPath xpath = XPathFactory.newInstance().newXPath(); Object result; XPathExpression expr = null; expr = xpath.compile(node); result = expr.evaluate(document, XPathConstants.NODESET); return result; }
java
private static Object getResult(Document document, String node) throws XPathExpressionException { // create an XPath object XPath xpath = XPathFactory.newInstance().newXPath(); Object result; XPathExpression expr = null; expr = xpath.compile(node); result = expr.evaluate(document, XPathConstants.NODESET); return result; }
[ "private", "static", "Object", "getResult", "(", "Document", "document", ",", "String", "node", ")", "throws", "XPathExpressionException", "{", "// create an XPath object", "XPath", "xpath", "=", "XPathFactory", ".", "newInstance", "(", ")", ".", "newXPath", "(", ")", ";", "Object", "result", ";", "XPathExpression", "expr", "=", "null", ";", "expr", "=", "xpath", ".", "compile", "(", "node", ")", ";", "result", "=", "expr", ".", "evaluate", "(", "document", ",", "XPathConstants", ".", "NODESET", ")", ";", "return", "result", ";", "}" ]
Get the node value. @param document the document. @param node the node. @return the node value. @throws XPathExpressionException if an exception happens.
[ "Get", "the", "node", "value", "." ]
d7cc66cb9591344a13055962e87a91f01c3707d1
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/util/ManifestUtil.java#L113-L121
154,042
Stratio/stratio-connector-commons
connector-commons/src/main/java/com/stratio/connector/commons/util/ManifestUtil.java
ManifestUtil.getDocument
private static Document getDocument(String pathManifest) throws SAXException, IOException, ParserConfigurationException { InputStream inputStream = ManifestUtil.class.getClassLoader().getResourceAsStream(pathManifest); return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream); }
java
private static Document getDocument(String pathManifest) throws SAXException, IOException, ParserConfigurationException { InputStream inputStream = ManifestUtil.class.getClassLoader().getResourceAsStream(pathManifest); return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream); }
[ "private", "static", "Document", "getDocument", "(", "String", "pathManifest", ")", "throws", "SAXException", ",", "IOException", ",", "ParserConfigurationException", "{", "InputStream", "inputStream", "=", "ManifestUtil", ".", "class", ".", "getClassLoader", "(", ")", ".", "getResourceAsStream", "(", "pathManifest", ")", ";", "return", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ".", "newDocumentBuilder", "(", ")", ".", "parse", "(", "inputStream", ")", ";", "}" ]
Create the documento. @param pathManifest the manifest Path. @return the document. @throws SAXException if an exception happens. @throws IOException if an exception happens. @throws ParserConfigurationException if an exception happens.
[ "Create", "the", "documento", "." ]
d7cc66cb9591344a13055962e87a91f01c3707d1
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/util/ManifestUtil.java#L132-L136
154,043
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/field/FaxField.java
FaxField.getHyperlink
public String getHyperlink() { String strMailTo = this.getString(); if (strMailTo != null) if (strMailTo.length() > 0) strMailTo = DBParams.FAX + ":" + strMailTo; return strMailTo; }
java
public String getHyperlink() { String strMailTo = this.getString(); if (strMailTo != null) if (strMailTo.length() > 0) strMailTo = DBParams.FAX + ":" + strMailTo; return strMailTo; }
[ "public", "String", "getHyperlink", "(", ")", "{", "String", "strMailTo", "=", "this", ".", "getString", "(", ")", ";", "if", "(", "strMailTo", "!=", "null", ")", "if", "(", "strMailTo", ".", "length", "(", ")", ">", "0", ")", "strMailTo", "=", "DBParams", ".", "FAX", "+", "\":\"", "+", "strMailTo", ";", "return", "strMailTo", ";", "}" ]
Get the faxto HTML Hyperlink.
[ "Get", "the", "faxto", "HTML", "Hyperlink", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/FaxField.java#L58-L64
154,044
js-lib-com/commons
src/main/java/js/util/Strings.java
Strings.join
public static String join(Iterable<?> objects, char separator) { return join(objects, Character.toString(separator)); }
java
public static String join(Iterable<?> objects, char separator) { return join(objects, Character.toString(separator)); }
[ "public", "static", "String", "join", "(", "Iterable", "<", "?", ">", "objects", ",", "char", "separator", ")", "{", "return", "join", "(", "objects", ",", "Character", ".", "toString", "(", "separator", ")", ")", ";", "}" ]
Join collection of objects, converted to string, using specified char separator. Returns null if given objects array is null and empty if empty. @param objects collection of objects to join, @param separator character used as separator. @return joined string.
[ "Join", "collection", "of", "objects", "converted", "to", "string", "using", "specified", "char", "separator", ".", "Returns", "null", "if", "given", "objects", "array", "is", "null", "and", "empty", "if", "empty", "." ]
f8c64482142b163487745da74feb106f0765c16b
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Strings.java#L493-L496
154,045
js-lib-com/commons
src/main/java/js/util/Strings.java
Strings.split
public static List<String> split(String string, String separator) { final int separatorLength = separator.length(); final List<String> list = new ArrayList<String>(); int fromIndex = 0; for(;;) { int endIndex = string.indexOf(separator, fromIndex); if(endIndex == -1) { break; } if(fromIndex < endIndex) { list.add(string.substring(fromIndex, endIndex).trim()); } fromIndex = endIndex + separatorLength; } if(fromIndex < string.length()) { list.add(string.substring(fromIndex).trim()); } return list; }
java
public static List<String> split(String string, String separator) { final int separatorLength = separator.length(); final List<String> list = new ArrayList<String>(); int fromIndex = 0; for(;;) { int endIndex = string.indexOf(separator, fromIndex); if(endIndex == -1) { break; } if(fromIndex < endIndex) { list.add(string.substring(fromIndex, endIndex).trim()); } fromIndex = endIndex + separatorLength; } if(fromIndex < string.length()) { list.add(string.substring(fromIndex).trim()); } return list; }
[ "public", "static", "List", "<", "String", ">", "split", "(", "String", "string", ",", "String", "separator", ")", "{", "final", "int", "separatorLength", "=", "separator", ".", "length", "(", ")", ";", "final", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "int", "fromIndex", "=", "0", ";", "for", "(", ";", ";", ")", "{", "int", "endIndex", "=", "string", ".", "indexOf", "(", "separator", ",", "fromIndex", ")", ";", "if", "(", "endIndex", "==", "-", "1", ")", "{", "break", ";", "}", "if", "(", "fromIndex", "<", "endIndex", ")", "{", "list", ".", "add", "(", "string", ".", "substring", "(", "fromIndex", ",", "endIndex", ")", ".", "trim", "(", ")", ")", ";", "}", "fromIndex", "=", "endIndex", "+", "separatorLength", ";", "}", "if", "(", "fromIndex", "<", "string", ".", "length", "(", ")", ")", "{", "list", ".", "add", "(", "string", ".", "substring", "(", "fromIndex", ")", ".", "trim", "(", ")", ")", ";", "}", "return", "list", ";", "}" ]
Splits string using specified string separator and returns trimmed values. Returns null if string argument is null and empty list if is empty. @param string source string, @param separator string used as separator. @return strings list, possible empty.
[ "Splits", "string", "using", "specified", "string", "separator", "and", "returns", "trimmed", "values", ".", "Returns", "null", "if", "string", "argument", "is", "null", "and", "empty", "list", "if", "is", "empty", "." ]
f8c64482142b163487745da74feb106f0765c16b
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Strings.java#L628-L648
154,046
js-lib-com/commons
src/main/java/js/util/Strings.java
Strings.isNumeric
public static boolean isNumeric(String string) { if(string == null || string.isEmpty()) return false; State state = State.SIGN; for(int i = 0; i < string.length(); ++i) { char c = string.charAt(i); switch(state) { case SIGN: if(c == '-' || c == '+') { state = State.INTEGER; break; } if(c == DECIMAL_SEPARATOR) { state = State.FRACTIONAL; break; } if(Character.isDigit(c)) { state = State.INTEGER; break; } return false; case INTEGER: if(Character.isDigit(c)) { break; } if(c == GROUPING_SEPARATOR) { break; } if(c == DECIMAL_SEPARATOR) { state = State.FRACTIONAL; break; } if(c == 'e' || c == 'E') { state = State.EXPONENT_SIGN; break; } if(isNumericSuffix(c)) { state = State.END; break; } return false; case FRACTIONAL: if(c == 'e' || c == 'E') { state = State.EXPONENT_SIGN; break; } if(isNumericSuffix(c)) { state = State.END; break; } if(Character.isDigit(c)) { break; } return false; case EXPONENT_SIGN: if(c == '-' || c == '+') { state = State.EXPONENT; break; } if(Character.isDigit(c)) { break; } return false; case EXPONENT: if(isNumericSuffix(c)) { state = State.END; break; } if(Character.isDigit(c)) { break; } return false; case END: return false; default: throw new IllegalStateException(); } } return true; }
java
public static boolean isNumeric(String string) { if(string == null || string.isEmpty()) return false; State state = State.SIGN; for(int i = 0; i < string.length(); ++i) { char c = string.charAt(i); switch(state) { case SIGN: if(c == '-' || c == '+') { state = State.INTEGER; break; } if(c == DECIMAL_SEPARATOR) { state = State.FRACTIONAL; break; } if(Character.isDigit(c)) { state = State.INTEGER; break; } return false; case INTEGER: if(Character.isDigit(c)) { break; } if(c == GROUPING_SEPARATOR) { break; } if(c == DECIMAL_SEPARATOR) { state = State.FRACTIONAL; break; } if(c == 'e' || c == 'E') { state = State.EXPONENT_SIGN; break; } if(isNumericSuffix(c)) { state = State.END; break; } return false; case FRACTIONAL: if(c == 'e' || c == 'E') { state = State.EXPONENT_SIGN; break; } if(isNumericSuffix(c)) { state = State.END; break; } if(Character.isDigit(c)) { break; } return false; case EXPONENT_SIGN: if(c == '-' || c == '+') { state = State.EXPONENT; break; } if(Character.isDigit(c)) { break; } return false; case EXPONENT: if(isNumericSuffix(c)) { state = State.END; break; } if(Character.isDigit(c)) { break; } return false; case END: return false; default: throw new IllegalStateException(); } } return true; }
[ "public", "static", "boolean", "isNumeric", "(", "String", "string", ")", "{", "if", "(", "string", "==", "null", "||", "string", ".", "isEmpty", "(", ")", ")", "return", "false", ";", "State", "state", "=", "State", ".", "SIGN", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "string", ".", "length", "(", ")", ";", "++", "i", ")", "{", "char", "c", "=", "string", ".", "charAt", "(", "i", ")", ";", "switch", "(", "state", ")", "{", "case", "SIGN", ":", "if", "(", "c", "==", "'", "'", "||", "c", "==", "'", "'", ")", "{", "state", "=", "State", ".", "INTEGER", ";", "break", ";", "}", "if", "(", "c", "==", "DECIMAL_SEPARATOR", ")", "{", "state", "=", "State", ".", "FRACTIONAL", ";", "break", ";", "}", "if", "(", "Character", ".", "isDigit", "(", "c", ")", ")", "{", "state", "=", "State", ".", "INTEGER", ";", "break", ";", "}", "return", "false", ";", "case", "INTEGER", ":", "if", "(", "Character", ".", "isDigit", "(", "c", ")", ")", "{", "break", ";", "}", "if", "(", "c", "==", "GROUPING_SEPARATOR", ")", "{", "break", ";", "}", "if", "(", "c", "==", "DECIMAL_SEPARATOR", ")", "{", "state", "=", "State", ".", "FRACTIONAL", ";", "break", ";", "}", "if", "(", "c", "==", "'", "'", "||", "c", "==", "'", "'", ")", "{", "state", "=", "State", ".", "EXPONENT_SIGN", ";", "break", ";", "}", "if", "(", "isNumericSuffix", "(", "c", ")", ")", "{", "state", "=", "State", ".", "END", ";", "break", ";", "}", "return", "false", ";", "case", "FRACTIONAL", ":", "if", "(", "c", "==", "'", "'", "||", "c", "==", "'", "'", ")", "{", "state", "=", "State", ".", "EXPONENT_SIGN", ";", "break", ";", "}", "if", "(", "isNumericSuffix", "(", "c", ")", ")", "{", "state", "=", "State", ".", "END", ";", "break", ";", "}", "if", "(", "Character", ".", "isDigit", "(", "c", ")", ")", "{", "break", ";", "}", "return", "false", ";", "case", "EXPONENT_SIGN", ":", "if", "(", "c", "==", "'", "'", "||", "c", "==", "'", "'", ")", "{", "state", "=", "State", ".", "EXPONENT", ";", "break", ";", "}", "if", "(", "Character", ".", "isDigit", "(", "c", ")", ")", "{", "break", ";", "}", "return", "false", ";", "case", "EXPONENT", ":", "if", "(", "isNumericSuffix", "(", "c", ")", ")", "{", "state", "=", "State", ".", "END", ";", "break", ";", "}", "if", "(", "Character", ".", "isDigit", "(", "c", ")", ")", "{", "break", ";", "}", "return", "false", ";", "case", "END", ":", "return", "false", ";", "default", ":", "throw", "new", "IllegalStateException", "(", ")", ";", "}", "}", "return", "true", ";", "}" ]
Test if string is a numeric value. Returns false if string argument is null or empty. @param string string to test. @return true if given string denote a number.
[ "Test", "if", "string", "is", "a", "numeric", "value", ".", "Returns", "false", "if", "string", "argument", "is", "null", "or", "empty", "." ]
f8c64482142b163487745da74feb106f0765c16b
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Strings.java#L754-L842
154,047
js-lib-com/commons
src/main/java/js/util/Strings.java
Strings.isInteger
public static boolean isInteger(String string) { if(string == null || string.isEmpty()) return false; int startIndex = string.charAt(0) == '-' ? 1 : string.charAt(0) == '+' ? 1 : 0; for(int i = startIndex, l = string.length(); i < l; i++) { if(string.charAt(i) == GROUPING_SEPARATOR) continue; if(!Character.isDigit(string.charAt(i))) { return false; } } return true; }
java
public static boolean isInteger(String string) { if(string == null || string.isEmpty()) return false; int startIndex = string.charAt(0) == '-' ? 1 : string.charAt(0) == '+' ? 1 : 0; for(int i = startIndex, l = string.length(); i < l; i++) { if(string.charAt(i) == GROUPING_SEPARATOR) continue; if(!Character.isDigit(string.charAt(i))) { return false; } } return true; }
[ "public", "static", "boolean", "isInteger", "(", "String", "string", ")", "{", "if", "(", "string", "==", "null", "||", "string", ".", "isEmpty", "(", ")", ")", "return", "false", ";", "int", "startIndex", "=", "string", ".", "charAt", "(", "0", ")", "==", "'", "'", "?", "1", ":", "string", ".", "charAt", "(", "0", ")", "==", "'", "'", "?", "1", ":", "0", ";", "for", "(", "int", "i", "=", "startIndex", ",", "l", "=", "string", ".", "length", "(", ")", ";", "i", "<", "l", ";", "i", "++", ")", "{", "if", "(", "string", ".", "charAt", "(", "i", ")", "==", "GROUPING_SEPARATOR", ")", "continue", ";", "if", "(", "!", "Character", ".", "isDigit", "(", "string", ".", "charAt", "(", "i", ")", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Test if string is an integer numeric value. Returns false if string is null or empty. @param string string to test. @return true if string is an integer.
[ "Test", "if", "string", "is", "an", "integer", "numeric", "value", ".", "Returns", "false", "if", "string", "is", "null", "or", "empty", "." ]
f8c64482142b163487745da74feb106f0765c16b
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Strings.java#L850-L861
154,048
js-lib-com/commons
src/main/java/js/util/Strings.java
Strings.escapeXML
public static String escapeXML(String text) { StringWriter writer = new StringWriter(); try { escapeXML(text, writer); } catch(IOException e) { // there is no reason for IO exception on a string writer throw new BugError("IO failure while attempting to write to string."); } return writer.toString(); }
java
public static String escapeXML(String text) { StringWriter writer = new StringWriter(); try { escapeXML(text, writer); } catch(IOException e) { // there is no reason for IO exception on a string writer throw new BugError("IO failure while attempting to write to string."); } return writer.toString(); }
[ "public", "static", "String", "escapeXML", "(", "String", "text", ")", "{", "StringWriter", "writer", "=", "new", "StringWriter", "(", ")", ";", "try", "{", "escapeXML", "(", "text", ",", "writer", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// there is no reason for IO exception on a string writer\r", "throw", "new", "BugError", "(", "\"IO failure while attempting to write to string.\"", ")", ";", "}", "return", "writer", ".", "toString", "(", ")", ";", "}" ]
Escape text for reserved XML characters. Replace quotes, apostrophe, ampersand, left and right angular brackets with entities. Return the newly created, escaped string; if text argument is null or empty returns an empty string. @param text string to escape. @return the newly created string.
[ "Escape", "text", "for", "reserved", "XML", "characters", ".", "Replace", "quotes", "apostrophe", "ampersand", "left", "and", "right", "angular", "brackets", "with", "entities", ".", "Return", "the", "newly", "created", "escaped", "string", ";", "if", "text", "argument", "is", "null", "or", "empty", "returns", "an", "empty", "string", "." ]
f8c64482142b163487745da74feb106f0765c16b
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Strings.java#L870-L881
154,049
js-lib-com/commons
src/main/java/js/util/Strings.java
Strings.escapeRegExp
public static String escapeRegExp(String string) { if(string == null) { return null; } return string.replaceAll(REGEXP_PATTERN, REPLACE_ARG_REX); }
java
public static String escapeRegExp(String string) { if(string == null) { return null; } return string.replaceAll(REGEXP_PATTERN, REPLACE_ARG_REX); }
[ "public", "static", "String", "escapeRegExp", "(", "String", "string", ")", "{", "if", "(", "string", "==", "null", ")", "{", "return", "null", ";", "}", "return", "string", ".", "replaceAll", "(", "REGEXP_PATTERN", ",", "REPLACE_ARG_REX", ")", ";", "}" ]
Escape string for regular expression reserved characters. Return null if string argument is null and empty if empty. @param string regular expression to escape. @return newly created, escaped string.
[ "Escape", "string", "for", "regular", "expression", "reserved", "characters", ".", "Return", "null", "if", "string", "argument", "is", "null", "and", "empty", "if", "empty", "." ]
f8c64482142b163487745da74feb106f0765c16b
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Strings.java#L948-L954
154,050
js-lib-com/commons
src/main/java/js/util/Strings.java
Strings.last
public static String last(String string, char separator) { if(string == null) { return null; } if(string.isEmpty()) { return ""; } return string.substring(string.lastIndexOf(separator) + 1); }
java
public static String last(String string, char separator) { if(string == null) { return null; } if(string.isEmpty()) { return ""; } return string.substring(string.lastIndexOf(separator) + 1); }
[ "public", "static", "String", "last", "(", "String", "string", ",", "char", "separator", ")", "{", "if", "(", "string", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "string", ".", "isEmpty", "(", ")", ")", "{", "return", "\"\"", ";", "}", "return", "string", ".", "substring", "(", "string", ".", "lastIndexOf", "(", "separator", ")", "+", "1", ")", ";", "}" ]
Get last string sequence following given character. If separator character is missing from the source string returns entire string. Return null if string argument is null and empty if empty. @param string source string, @param separator character used as separator. @return last string sequence.
[ "Get", "last", "string", "sequence", "following", "given", "character", ".", "If", "separator", "character", "is", "missing", "from", "the", "source", "string", "returns", "entire", "string", ".", "Return", "null", "if", "string", "argument", "is", "null", "and", "empty", "if", "empty", "." ]
f8c64482142b163487745da74feb106f0765c16b
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Strings.java#L980-L989
154,051
js-lib-com/commons
src/main/java/js/util/Strings.java
Strings.removeTrailing
public static String removeTrailing(String string, char c) { if(string == null) { return null; } final int lastCharIndex = string.length() - 1; return string.charAt(lastCharIndex) == c ? string.substring(0, lastCharIndex) : string; }
java
public static String removeTrailing(String string, char c) { if(string == null) { return null; } final int lastCharIndex = string.length() - 1; return string.charAt(lastCharIndex) == c ? string.substring(0, lastCharIndex) : string; }
[ "public", "static", "String", "removeTrailing", "(", "String", "string", ",", "char", "c", ")", "{", "if", "(", "string", "==", "null", ")", "{", "return", "null", ";", "}", "final", "int", "lastCharIndex", "=", "string", ".", "length", "(", ")", "-", "1", ";", "return", "string", ".", "charAt", "(", "lastCharIndex", ")", "==", "c", "?", "string", ".", "substring", "(", "0", ",", "lastCharIndex", ")", ":", "string", ";", "}" ]
Remove trailing character, if exists. @param string source string, @param c trailing character to eliminate. @return source string guaranteed to not end in requested character.
[ "Remove", "trailing", "character", "if", "exists", "." ]
f8c64482142b163487745da74feb106f0765c16b
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Strings.java#L1328-L1335
154,052
js-lib-com/commons
src/main/java/js/util/Strings.java
Strings.load
public static String load(InputStream inputStream, Integer... maxCount) throws IOException { return load(new InputStreamReader(inputStream, "UTF-8"), maxCount); }
java
public static String load(InputStream inputStream, Integer... maxCount) throws IOException { return load(new InputStreamReader(inputStream, "UTF-8"), maxCount); }
[ "public", "static", "String", "load", "(", "InputStream", "inputStream", ",", "Integer", "...", "maxCount", ")", "throws", "IOException", "{", "return", "load", "(", "new", "InputStreamReader", "(", "inputStream", ",", "\"UTF-8\"", ")", ",", "maxCount", ")", ";", "}" ]
Load string from UTF-8 bytes stream then closes it. @param inputStream source input stream, @param maxCount optional maximum number of characters to read, default to MAX_VALUE. @return string from input stream. @throws NullPointerException if input stream is null. @throws IOException if input stream read operation fails.
[ "Load", "string", "from", "UTF", "-", "8", "bytes", "stream", "then", "closes", "it", "." ]
f8c64482142b163487745da74feb106f0765c16b
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Strings.java#L1433-L1436
154,053
js-lib-com/commons
src/main/java/js/util/Strings.java
Strings.load
public static String load(File file, Integer... maxCount) throws IOException { return load(new FileReader(file), maxCount); }
java
public static String load(File file, Integer... maxCount) throws IOException { return load(new FileReader(file), maxCount); }
[ "public", "static", "String", "load", "(", "File", "file", ",", "Integer", "...", "maxCount", ")", "throws", "IOException", "{", "return", "load", "(", "new", "FileReader", "(", "file", ")", ",", "maxCount", ")", ";", "}" ]
Load string from UTF-8 file content. @param file source file, @param maxCount optional maximum character count to load, default to entire file. @return loaded string, possible empty but never null. @throws IOException if file not found or file read operation fails.
[ "Load", "string", "from", "UTF", "-", "8", "file", "content", "." ]
f8c64482142b163487745da74feb106f0765c16b
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Strings.java#L1446-L1449
154,054
js-lib-com/commons
src/main/java/js/util/Strings.java
Strings.load
public static String load(Reader reader, Integer... maxCount) throws IOException { long maxCountValue = maxCount.length > 0 ? maxCount[0] : Long.MAX_VALUE; StringWriter writer = new StringWriter(); try { char[] buffer = new char[1024]; for(;;) { int readChars = reader.read(buffer, 0, (int)Math.min(buffer.length, maxCountValue)); if(readChars <= 0) { break; } writer.write(buffer, 0, readChars); maxCountValue -= readChars; } } finally { Files.close(reader); Files.close(writer); } return writer.toString(); }
java
public static String load(Reader reader, Integer... maxCount) throws IOException { long maxCountValue = maxCount.length > 0 ? maxCount[0] : Long.MAX_VALUE; StringWriter writer = new StringWriter(); try { char[] buffer = new char[1024]; for(;;) { int readChars = reader.read(buffer, 0, (int)Math.min(buffer.length, maxCountValue)); if(readChars <= 0) { break; } writer.write(buffer, 0, readChars); maxCountValue -= readChars; } } finally { Files.close(reader); Files.close(writer); } return writer.toString(); }
[ "public", "static", "String", "load", "(", "Reader", "reader", ",", "Integer", "...", "maxCount", ")", "throws", "IOException", "{", "long", "maxCountValue", "=", "maxCount", ".", "length", ">", "0", "?", "maxCount", "[", "0", "]", ":", "Long", ".", "MAX_VALUE", ";", "StringWriter", "writer", "=", "new", "StringWriter", "(", ")", ";", "try", "{", "char", "[", "]", "buffer", "=", "new", "char", "[", "1024", "]", ";", "for", "(", ";", ";", ")", "{", "int", "readChars", "=", "reader", ".", "read", "(", "buffer", ",", "0", ",", "(", "int", ")", "Math", ".", "min", "(", "buffer", ".", "length", ",", "maxCountValue", ")", ")", ";", "if", "(", "readChars", "<=", "0", ")", "{", "break", ";", "}", "writer", ".", "write", "(", "buffer", ",", "0", ",", "readChars", ")", ";", "maxCountValue", "-=", "readChars", ";", "}", "}", "finally", "{", "Files", ".", "close", "(", "reader", ")", ";", "Files", ".", "close", "(", "writer", ")", ";", "}", "return", "writer", ".", "toString", "(", ")", ";", "}" ]
Load string from character stream then closes it. @param reader source character stream. @param maxCount optional maximum character count to load, default to entire file. @return loaded string, possible empty but never null. @throws IOException if read operation fails.
[ "Load", "string", "from", "character", "stream", "then", "closes", "it", "." ]
f8c64482142b163487745da74feb106f0765c16b
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Strings.java#L1459-L1481
154,055
js-lib-com/commons
src/main/java/js/util/Strings.java
Strings.md5
public static String md5(String text) { MessageDigest md; try { md = MessageDigest.getInstance("MD5"); } catch(NoSuchAlgorithmException e) { throw new BugError("Java runtime without MD5 support."); } md.update(text.getBytes()); byte[] md5 = md.digest(); char[] buffer = new char[32]; for(int i = 0; i < 16; i++) { buffer[i * 2] = HEXA[(md5[i] & 0xf0) >> 4]; buffer[i * 2 + 1] = HEXA[md5[i] & 0x0f]; } return new String(buffer); }
java
public static String md5(String text) { MessageDigest md; try { md = MessageDigest.getInstance("MD5"); } catch(NoSuchAlgorithmException e) { throw new BugError("Java runtime without MD5 support."); } md.update(text.getBytes()); byte[] md5 = md.digest(); char[] buffer = new char[32]; for(int i = 0; i < 16; i++) { buffer[i * 2] = HEXA[(md5[i] & 0xf0) >> 4]; buffer[i * 2 + 1] = HEXA[md5[i] & 0x0f]; } return new String(buffer); }
[ "public", "static", "String", "md5", "(", "String", "text", ")", "{", "MessageDigest", "md", ";", "try", "{", "md", "=", "MessageDigest", ".", "getInstance", "(", "\"MD5\"", ")", ";", "}", "catch", "(", "NoSuchAlgorithmException", "e", ")", "{", "throw", "new", "BugError", "(", "\"Java runtime without MD5 support.\"", ")", ";", "}", "md", ".", "update", "(", "text", ".", "getBytes", "(", ")", ")", ";", "byte", "[", "]", "md5", "=", "md", ".", "digest", "(", ")", ";", "char", "[", "]", "buffer", "=", "new", "char", "[", "32", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "16", ";", "i", "++", ")", "{", "buffer", "[", "i", "*", "2", "]", "=", "HEXA", "[", "(", "md5", "[", "i", "]", "&", "0xf0", ")", ">>", "4", "]", ";", "buffer", "[", "i", "*", "2", "+", "1", "]", "=", "HEXA", "[", "md5", "[", "i", "]", "&", "0x0f", "]", ";", "}", "return", "new", "String", "(", "buffer", ")", ";", "}" ]
Generate text MD5 hash into hexadecimal format. Returned string will be exactly 32 characters long. This function is designed, but not limited, to store password into databases. Anyway, be aware that MD5 is not a strong enough hash function to be used on public transfers. @param text source text. @return MD5 hash in hexadecimal format.
[ "Generate", "text", "MD5", "hash", "into", "hexadecimal", "format", ".", "Returned", "string", "will", "be", "exactly", "32", "characters", "long", ".", "This", "function", "is", "designed", "but", "not", "limited", "to", "store", "password", "into", "databases", ".", "Anyway", "be", "aware", "that", "MD5", "is", "not", "a", "strong", "enough", "hash", "function", "to", "be", "used", "on", "public", "transfers", "." ]
f8c64482142b163487745da74feb106f0765c16b
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Strings.java#L1603-L1621
154,056
js-lib-com/commons
src/main/java/js/util/Strings.java
Strings.getProtocol
public static String getProtocol(String url) { if(url == null) { return null; } int protocolSeparatorIndex = url.indexOf("://"); if(protocolSeparatorIndex == -1) { return null; } return url.substring(0, protocolSeparatorIndex).toLowerCase(); }
java
public static String getProtocol(String url) { if(url == null) { return null; } int protocolSeparatorIndex = url.indexOf("://"); if(protocolSeparatorIndex == -1) { return null; } return url.substring(0, protocolSeparatorIndex).toLowerCase(); }
[ "public", "static", "String", "getProtocol", "(", "String", "url", ")", "{", "if", "(", "url", "==", "null", ")", "{", "return", "null", ";", "}", "int", "protocolSeparatorIndex", "=", "url", ".", "indexOf", "(", "\"://\"", ")", ";", "if", "(", "protocolSeparatorIndex", "==", "-", "1", ")", "{", "return", "null", ";", "}", "return", "url", ".", "substring", "(", "0", ",", "protocolSeparatorIndex", ")", ".", "toLowerCase", "(", ")", ";", "}" ]
Get URL protocol - lower case, or null if given URL does not contains one. Returns null if given URL argument is null or empty. @param url URL to retrieve the protocol. @return lower case URL protocol, possible null.
[ "Get", "URL", "protocol", "-", "lower", "case", "or", "null", "if", "given", "URL", "does", "not", "contains", "one", ".", "Returns", "null", "if", "given", "URL", "argument", "is", "null", "or", "empty", "." ]
f8c64482142b163487745da74feb106f0765c16b
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Strings.java#L1630-L1640
154,057
mijecu25/dsa
src/main/java/com/mijecu25/dsa/algorithms/swap/XORSwap.java
XORSwap.swap
public static void swap(short[] shortArray1, short[] shortArray2, int index) { XORSwap.swap(shortArray1, index, shortArray2, index); }
java
public static void swap(short[] shortArray1, short[] shortArray2, int index) { XORSwap.swap(shortArray1, index, shortArray2, index); }
[ "public", "static", "void", "swap", "(", "short", "[", "]", "shortArray1", ",", "short", "[", "]", "shortArray2", ",", "int", "index", ")", "{", "XORSwap", ".", "swap", "(", "shortArray1", ",", "index", ",", "shortArray2", ",", "index", ")", ";", "}" ]
Swap the elements of short long arrays at the same position @param shortArray1 one of the arrays that will have one of its values swapped. @param shortArray2 other array that will have one of its values swapped. @param index index of the arrays that will have their values swapped.
[ "Swap", "the", "elements", "of", "short", "long", "arrays", "at", "the", "same", "position" ]
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/swap/XORSwap.java#L264-L266
154,058
Stratio/stratio-connector-commons
connector-commons/src/main/java/com/stratio/connector/commons/metadata/TableMetadataBuilder.java
TableMetadataBuilder.withColumns
@TimerJ public TableMetadataBuilder withColumns(List<ColumnMetadata> columnsMetadata) { for (ColumnMetadata colMetadata : columnsMetadata) { columns.put(colMetadata.getName(), colMetadata); } return this; }
java
@TimerJ public TableMetadataBuilder withColumns(List<ColumnMetadata> columnsMetadata) { for (ColumnMetadata colMetadata : columnsMetadata) { columns.put(colMetadata.getName(), colMetadata); } return this; }
[ "@", "TimerJ", "public", "TableMetadataBuilder", "withColumns", "(", "List", "<", "ColumnMetadata", ">", "columnsMetadata", ")", "{", "for", "(", "ColumnMetadata", "colMetadata", ":", "columnsMetadata", ")", "{", "columns", ".", "put", "(", "colMetadata", ".", "getName", "(", ")", ",", "colMetadata", ")", ";", "}", "return", "this", ";", "}" ]
Add new columns. The columns previously created are not removed. @param columnsMetadata the columns metadata @return the table metadata builder
[ "Add", "new", "columns", ".", "The", "columns", "previously", "created", "are", "not", "removed", "." ]
d7cc66cb9591344a13055962e87a91f01c3707d1
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/metadata/TableMetadataBuilder.java#L122-L128
154,059
Stratio/stratio-connector-commons
connector-commons/src/main/java/com/stratio/connector/commons/metadata/TableMetadataBuilder.java
TableMetadataBuilder.addIndex
@TimerJ public TableMetadataBuilder addIndex(IndexType indType, String indexName, String... fields) throws ExecutionException { IndexName indName = new IndexName(tableName.getName(), tableName.getName(), indexName); Map<ColumnName, ColumnMetadata> columnsMetadata = new HashMap<ColumnName, ColumnMetadata>(fields.length); // recover the columns from the table metadata for (String field : fields) { ColumnMetadata cMetadata = columns.get(new ColumnName(tableName, field)); if (cMetadata == null) { throw new ExecutionException("Trying to index a not existing column: " + field); } columnsMetadata.put(new ColumnName(tableName, field), cMetadata); } IndexMetadata indMetadata = new IndexMetadata(indName, columnsMetadata, indType, null); indexes.put(indName, indMetadata); return this; }
java
@TimerJ public TableMetadataBuilder addIndex(IndexType indType, String indexName, String... fields) throws ExecutionException { IndexName indName = new IndexName(tableName.getName(), tableName.getName(), indexName); Map<ColumnName, ColumnMetadata> columnsMetadata = new HashMap<ColumnName, ColumnMetadata>(fields.length); // recover the columns from the table metadata for (String field : fields) { ColumnMetadata cMetadata = columns.get(new ColumnName(tableName, field)); if (cMetadata == null) { throw new ExecutionException("Trying to index a not existing column: " + field); } columnsMetadata.put(new ColumnName(tableName, field), cMetadata); } IndexMetadata indMetadata = new IndexMetadata(indName, columnsMetadata, indType, null); indexes.put(indName, indMetadata); return this; }
[ "@", "TimerJ", "public", "TableMetadataBuilder", "addIndex", "(", "IndexType", "indType", ",", "String", "indexName", ",", "String", "...", "fields", ")", "throws", "ExecutionException", "{", "IndexName", "indName", "=", "new", "IndexName", "(", "tableName", ".", "getName", "(", ")", ",", "tableName", ".", "getName", "(", ")", ",", "indexName", ")", ";", "Map", "<", "ColumnName", ",", "ColumnMetadata", ">", "columnsMetadata", "=", "new", "HashMap", "<", "ColumnName", ",", "ColumnMetadata", ">", "(", "fields", ".", "length", ")", ";", "// recover the columns from the table metadata", "for", "(", "String", "field", ":", "fields", ")", "{", "ColumnMetadata", "cMetadata", "=", "columns", ".", "get", "(", "new", "ColumnName", "(", "tableName", ",", "field", ")", ")", ";", "if", "(", "cMetadata", "==", "null", ")", "{", "throw", "new", "ExecutionException", "(", "\"Trying to index a not existing column: \"", "+", "field", ")", ";", "}", "columnsMetadata", ".", "put", "(", "new", "ColumnName", "(", "tableName", ",", "field", ")", ",", "cMetadata", ")", ";", "}", "IndexMetadata", "indMetadata", "=", "new", "IndexMetadata", "(", "indName", ",", "columnsMetadata", ",", "indType", ",", "null", ")", ";", "indexes", ".", "put", "(", "indName", ",", "indMetadata", ")", ";", "return", "this", ";", "}" ]
Add an index. Must be called after including columns because columnMetadata is recovered from the tableMetadata. Options in indexMetadata will be null. @param indType the index type. @param indexName the index name. @param fields the columns which define the index. @return the table metadata builder. @throws if an error happens.
[ "Add", "an", "index", ".", "Must", "be", "called", "after", "including", "columns", "because", "columnMetadata", "is", "recovered", "from", "the", "tableMetadata", ".", "Options", "in", "indexMetadata", "will", "be", "null", "." ]
d7cc66cb9591344a13055962e87a91f01c3707d1
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/metadata/TableMetadataBuilder.java#L155-L172
154,060
Stratio/stratio-connector-commons
connector-commons/src/main/java/com/stratio/connector/commons/metadata/TableMetadataBuilder.java
TableMetadataBuilder.addIndex
@TimerJ public TableMetadataBuilder addIndex(IndexMetadata indexMetadata) { indexes.put(indexMetadata.getName(), indexMetadata); return this; }
java
@TimerJ public TableMetadataBuilder addIndex(IndexMetadata indexMetadata) { indexes.put(indexMetadata.getName(), indexMetadata); return this; }
[ "@", "TimerJ", "public", "TableMetadataBuilder", "addIndex", "(", "IndexMetadata", "indexMetadata", ")", "{", "indexes", ".", "put", "(", "indexMetadata", ".", "getName", "(", ")", ",", "indexMetadata", ")", ";", "return", "this", ";", "}" ]
Add an index. @param indexMetadata the index metadata @return the table metadata builder
[ "Add", "an", "index", "." ]
d7cc66cb9591344a13055962e87a91f01c3707d1
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/metadata/TableMetadataBuilder.java#L180-L184
154,061
Stratio/stratio-connector-commons
connector-commons/src/main/java/com/stratio/connector/commons/metadata/TableMetadataBuilder.java
TableMetadataBuilder.withPartitionKey
@TimerJ public TableMetadataBuilder withPartitionKey(String... fields) { for (String field : fields) { partitionKey.add(new ColumnName(tableName, field)); } return this; }
java
@TimerJ public TableMetadataBuilder withPartitionKey(String... fields) { for (String field : fields) { partitionKey.add(new ColumnName(tableName, field)); } return this; }
[ "@", "TimerJ", "public", "TableMetadataBuilder", "withPartitionKey", "(", "String", "...", "fields", ")", "{", "for", "(", "String", "field", ":", "fields", ")", "{", "partitionKey", ".", "add", "(", "new", "ColumnName", "(", "tableName", ",", "field", ")", ")", ";", "}", "return", "this", ";", "}" ]
Set the partition key. @param fields the fields @return the table metadata builder
[ "Set", "the", "partition", "key", "." ]
d7cc66cb9591344a13055962e87a91f01c3707d1
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/metadata/TableMetadataBuilder.java#L192-L200
154,062
Stratio/stratio-connector-commons
connector-commons/src/main/java/com/stratio/connector/commons/metadata/TableMetadataBuilder.java
TableMetadataBuilder.withClusterKey
@TimerJ public TableMetadataBuilder withClusterKey(String... fields) { for (String field : fields) { clusterKey.add(new ColumnName(tableName, field)); } return this; }
java
@TimerJ public TableMetadataBuilder withClusterKey(String... fields) { for (String field : fields) { clusterKey.add(new ColumnName(tableName, field)); } return this; }
[ "@", "TimerJ", "public", "TableMetadataBuilder", "withClusterKey", "(", "String", "...", "fields", ")", "{", "for", "(", "String", "field", ":", "fields", ")", "{", "clusterKey", ".", "add", "(", "new", "ColumnName", "(", "tableName", ",", "field", ")", ")", ";", "}", "return", "this", ";", "}" ]
Set the cluster key. @param fields the fields @return the table metadata builder
[ "Set", "the", "cluster", "key", "." ]
d7cc66cb9591344a13055962e87a91f01c3707d1
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/metadata/TableMetadataBuilder.java#L208-L214
154,063
Stratio/stratio-connector-commons
connector-commons/src/main/java/com/stratio/connector/commons/metadata/TableMetadataBuilder.java
TableMetadataBuilder.build
@TimerJ public TableMetadata build(boolean isPKRequired) { if (isPKRequired && partitionKey.isEmpty()) { this.withPartitionKey(columns.keySet().iterator().next().getName()); } return new TableMetadata(tableName, options, new LinkedHashMap<>(columns), indexes, clusterName, partitionKey, clusterKey); }
java
@TimerJ public TableMetadata build(boolean isPKRequired) { if (isPKRequired && partitionKey.isEmpty()) { this.withPartitionKey(columns.keySet().iterator().next().getName()); } return new TableMetadata(tableName, options, new LinkedHashMap<>(columns), indexes, clusterName, partitionKey, clusterKey); }
[ "@", "TimerJ", "public", "TableMetadata", "build", "(", "boolean", "isPKRequired", ")", "{", "if", "(", "isPKRequired", "&&", "partitionKey", ".", "isEmpty", "(", ")", ")", "{", "this", ".", "withPartitionKey", "(", "columns", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ".", "next", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "return", "new", "TableMetadata", "(", "tableName", ",", "options", ",", "new", "LinkedHashMap", "<>", "(", "columns", ")", ",", "indexes", ",", "clusterName", ",", "partitionKey", ",", "clusterKey", ")", ";", "}" ]
Builds the table metadata. @param isPKRequired whether the pk is required or not @return the table metadata
[ "Builds", "the", "table", "metadata", "." ]
d7cc66cb9591344a13055962e87a91f01c3707d1
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/metadata/TableMetadataBuilder.java#L246-L252
154,064
tvesalainen/util
util/src/main/java/org/vesalainen/util/BitGrid.java
BitGrid.patternOverflow
public boolean patternOverflow() { BitArray lin = new BitArray(width); bits.forEach((i)->lin.set(column(i), true)); return lin.isSet(0) && lin.isSet(width-1); }
java
public boolean patternOverflow() { BitArray lin = new BitArray(width); bits.forEach((i)->lin.set(column(i), true)); return lin.isSet(0) && lin.isSet(width-1); }
[ "public", "boolean", "patternOverflow", "(", ")", "{", "BitArray", "lin", "=", "new", "BitArray", "(", "width", ")", ";", "bits", ".", "forEach", "(", "(", "i", ")", "-", ">", "lin", ".", "set", "(", "column", "(", "i", ")", ",", "true", ")", ")", ";", "return", "lin", ".", "isSet", "(", "0", ")", "&&", "lin", ".", "isSet", "(", "width", "-", "1", ")", ";", "}" ]
Returns true if pattern overflows line @return
[ "Returns", "true", "if", "pattern", "overflows", "line" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/BitGrid.java#L84-L89
154,065
tvesalainen/util
util/src/main/java/org/vesalainen/util/BitGrid.java
BitGrid.patternLineCoverage
public float patternLineCoverage() { BitArray lin = new BitArray(width); bits.forEach((i)->lin.set(column(i), true)); return (float)lin.count()/(float)width; }
java
public float patternLineCoverage() { BitArray lin = new BitArray(width); bits.forEach((i)->lin.set(column(i), true)); return (float)lin.count()/(float)width; }
[ "public", "float", "patternLineCoverage", "(", ")", "{", "BitArray", "lin", "=", "new", "BitArray", "(", "width", ")", ";", "bits", ".", "forEach", "(", "(", "i", ")", "-", ">", "lin", ".", "set", "(", "column", "(", "i", ")", ",", "true", ")", ")", ";", "return", "(", "float", ")", "lin", ".", "count", "(", ")", "/", "(", "float", ")", "width", ";", "}" ]
Returns 1.0 if all columns have set bits or less @return
[ "Returns", "1", ".", "0", "if", "all", "columns", "have", "set", "bits", "or", "less" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/BitGrid.java#L94-L99
154,066
tvesalainen/util
util/src/main/java/org/vesalainen/util/BitGrid.java
BitGrid.patternSquareness
public float patternSquareness() { int patternStart = patternStart(); int patternEnd = patternEnd(); int sy = line(patternStart); int ey = line(patternEnd); int sx = column(patternStart); int ex = column(patternEnd); float actCnt = 0; int w = ex-sx+1; int h = ey-sy+1; for (int ii=0;ii<h;ii++) { for (int jj=0;jj<w;jj++) { if (getColor(sx+jj, sy+ii)) { actCnt++; } } } float allCnt = getSetCount(); return actCnt/allCnt; }
java
public float patternSquareness() { int patternStart = patternStart(); int patternEnd = patternEnd(); int sy = line(patternStart); int ey = line(patternEnd); int sx = column(patternStart); int ex = column(patternEnd); float actCnt = 0; int w = ex-sx+1; int h = ey-sy+1; for (int ii=0;ii<h;ii++) { for (int jj=0;jj<w;jj++) { if (getColor(sx+jj, sy+ii)) { actCnt++; } } } float allCnt = getSetCount(); return actCnt/allCnt; }
[ "public", "float", "patternSquareness", "(", ")", "{", "int", "patternStart", "=", "patternStart", "(", ")", ";", "int", "patternEnd", "=", "patternEnd", "(", ")", ";", "int", "sy", "=", "line", "(", "patternStart", ")", ";", "int", "ey", "=", "line", "(", "patternEnd", ")", ";", "int", "sx", "=", "column", "(", "patternStart", ")", ";", "int", "ex", "=", "column", "(", "patternEnd", ")", ";", "float", "actCnt", "=", "0", ";", "int", "w", "=", "ex", "-", "sx", "+", "1", ";", "int", "h", "=", "ey", "-", "sy", "+", "1", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "h", ";", "ii", "++", ")", "{", "for", "(", "int", "jj", "=", "0", ";", "jj", "<", "w", ";", "jj", "++", ")", "{", "if", "(", "getColor", "(", "sx", "+", "jj", ",", "sy", "+", "ii", ")", ")", "{", "actCnt", "++", ";", "}", "}", "}", "float", "allCnt", "=", "getSetCount", "(", ")", ";", "return", "actCnt", "/", "allCnt", ";", "}" ]
Returns 1.0 if pattern is square or less if not. @return
[ "Returns", "1", ".", "0", "if", "pattern", "is", "square", "or", "less", "if", "not", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/BitGrid.java#L104-L127
154,067
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/field/EMailField.java
EMailField.getHyperlink
public String getHyperlink() { String strMailTo = this.getString(); if (strMailTo != null) if (strMailTo.length() > 0) strMailTo = BaseApplication.MAIL_TO + ":" + strMailTo; return strMailTo; }
java
public String getHyperlink() { String strMailTo = this.getString(); if (strMailTo != null) if (strMailTo.length() > 0) strMailTo = BaseApplication.MAIL_TO + ":" + strMailTo; return strMailTo; }
[ "public", "String", "getHyperlink", "(", ")", "{", "String", "strMailTo", "=", "this", ".", "getString", "(", ")", ";", "if", "(", "strMailTo", "!=", "null", ")", "if", "(", "strMailTo", ".", "length", "(", ")", ">", "0", ")", "strMailTo", "=", "BaseApplication", ".", "MAIL_TO", "+", "\":\"", "+", "strMailTo", ";", "return", "strMailTo", ";", "}" ]
Get the HTML mailto Hyperlink. @return The hyperlink.
[ "Get", "the", "HTML", "mailto", "Hyperlink", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/EMailField.java#L72-L78
154,068
TrueNight/Utils
utils/src/main/java/xyz/truenight/utils/Utils.java
Utils.sorted
public static <T extends Comparable<? super T>> List<T> sorted(List<T> list) { List<T> result = new ArrayList<>(list); Collections.sort(result); return result; }
java
public static <T extends Comparable<? super T>> List<T> sorted(List<T> list) { List<T> result = new ArrayList<>(list); Collections.sort(result); return result; }
[ "public", "static", "<", "T", "extends", "Comparable", "<", "?", "super", "T", ">", ">", "List", "<", "T", ">", "sorted", "(", "List", "<", "T", ">", "list", ")", "{", "List", "<", "T", ">", "result", "=", "new", "ArrayList", "<>", "(", "list", ")", ";", "Collections", ".", "sort", "(", "result", ")", ";", "return", "result", ";", "}" ]
Sorts the given list in ascending natural order. The algorithm is stable which means equal elements don't get reordered. @throws ClassCastException if any element does not implement {@code Comparable}, or if {@code compareTo} throws for any pair of elements.
[ "Sorts", "the", "given", "list", "in", "ascending", "natural", "order", ".", "The", "algorithm", "is", "stable", "which", "means", "equal", "elements", "don", "t", "get", "reordered", "." ]
78a11faa16258b09f08826797370310ab650530c
https://github.com/TrueNight/Utils/blob/78a11faa16258b09f08826797370310ab650530c/utils/src/main/java/xyz/truenight/utils/Utils.java#L1017-L1021
154,069
TrueNight/Utils
utils/src/main/java/xyz/truenight/utils/Utils.java
Utils.sorted
@SuppressWarnings("unchecked") public static <T> List<T> sorted(List<T> list, Comparator<? super T> comparator) { List<T> result = new ArrayList<>(list); Collections.sort(result, comparator); return result; }
java
@SuppressWarnings("unchecked") public static <T> List<T> sorted(List<T> list, Comparator<? super T> comparator) { List<T> result = new ArrayList<>(list); Collections.sort(result, comparator); return result; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "List", "<", "T", ">", "sorted", "(", "List", "<", "T", ">", "list", ",", "Comparator", "<", "?", "super", "T", ">", "comparator", ")", "{", "List", "<", "T", ">", "result", "=", "new", "ArrayList", "<>", "(", "list", ")", ";", "Collections", ".", "sort", "(", "result", ",", "comparator", ")", ";", "return", "result", ";", "}" ]
Sorts the given list using the given comparator. The algorithm is stable which means equal elements don't get reordered. @throws ClassCastException if any element does not implement {@code Comparable}, or if {@code compareTo} throws for any pair of elements.
[ "Sorts", "the", "given", "list", "using", "the", "given", "comparator", ".", "The", "algorithm", "is", "stable", "which", "means", "equal", "elements", "don", "t", "get", "reordered", "." ]
78a11faa16258b09f08826797370310ab650530c
https://github.com/TrueNight/Utils/blob/78a11faa16258b09f08826797370310ab650530c/utils/src/main/java/xyz/truenight/utils/Utils.java#L1043-L1048
154,070
TrueNight/Utils
utils/src/main/java/xyz/truenight/utils/Utils.java
Utils.addFirst
public static <T> List<T> addFirst(List<T> to, T what) { List<T> data = safeList(to); data.add(0, what); return data; }
java
public static <T> List<T> addFirst(List<T> to, T what) { List<T> data = safeList(to); data.add(0, what); return data; }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "addFirst", "(", "List", "<", "T", ">", "to", ",", "T", "what", ")", "{", "List", "<", "T", ">", "data", "=", "safeList", "(", "to", ")", ";", "data", ".", "add", "(", "0", ",", "what", ")", ";", "return", "data", ";", "}" ]
Add element to start of list
[ "Add", "element", "to", "start", "of", "list" ]
78a11faa16258b09f08826797370310ab650530c
https://github.com/TrueNight/Utils/blob/78a11faa16258b09f08826797370310ab650530c/utils/src/main/java/xyz/truenight/utils/Utils.java#L1139-L1143
154,071
TrueNight/Utils
utils/src/main/java/xyz/truenight/utils/Utils.java
Utils.filter
public static <T> Collection<T> filter(Collection<T> data, Filter<T> filter) { if (!Utils.isEmpty(data)) { Iterator<T> iterator = data.iterator(); while (iterator.hasNext()) { T item = iterator.next(); if (!filter.accept(item)) { iterator.remove(); } } } return data; }
java
public static <T> Collection<T> filter(Collection<T> data, Filter<T> filter) { if (!Utils.isEmpty(data)) { Iterator<T> iterator = data.iterator(); while (iterator.hasNext()) { T item = iterator.next(); if (!filter.accept(item)) { iterator.remove(); } } } return data; }
[ "public", "static", "<", "T", ">", "Collection", "<", "T", ">", "filter", "(", "Collection", "<", "T", ">", "data", ",", "Filter", "<", "T", ">", "filter", ")", "{", "if", "(", "!", "Utils", ".", "isEmpty", "(", "data", ")", ")", "{", "Iterator", "<", "T", ">", "iterator", "=", "data", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "T", "item", "=", "iterator", ".", "next", "(", ")", ";", "if", "(", "!", "filter", ".", "accept", "(", "item", ")", ")", "{", "iterator", ".", "remove", "(", ")", ";", "}", "}", "}", "return", "data", ";", "}" ]
Removes items which not accepted by filter
[ "Removes", "items", "which", "not", "accepted", "by", "filter" ]
78a11faa16258b09f08826797370310ab650530c
https://github.com/TrueNight/Utils/blob/78a11faa16258b09f08826797370310ab650530c/utils/src/main/java/xyz/truenight/utils/Utils.java#L1383-L1394
154,072
TrueNight/Utils
utils/src/main/java/xyz/truenight/utils/Utils.java
Utils.filtered
public static <T> List<T> filtered(Collection<T> data, Filter<T> filter) { List<T> list = new ArrayList<>(); if (!Utils.isEmpty(data)) { for (T item : data) { if (filter.accept(item)) { list.add(item); } } } return list; }
java
public static <T> List<T> filtered(Collection<T> data, Filter<T> filter) { List<T> list = new ArrayList<>(); if (!Utils.isEmpty(data)) { for (T item : data) { if (filter.accept(item)) { list.add(item); } } } return list; }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "filtered", "(", "Collection", "<", "T", ">", "data", ",", "Filter", "<", "T", ">", "filter", ")", "{", "List", "<", "T", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "!", "Utils", ".", "isEmpty", "(", "data", ")", ")", "{", "for", "(", "T", "item", ":", "data", ")", "{", "if", "(", "filter", ".", "accept", "(", "item", ")", ")", "{", "list", ".", "add", "(", "item", ")", ";", "}", "}", "}", "return", "list", ";", "}" ]
Returns new List without items which not accepted by filter
[ "Returns", "new", "List", "without", "items", "which", "not", "accepted", "by", "filter" ]
78a11faa16258b09f08826797370310ab650530c
https://github.com/TrueNight/Utils/blob/78a11faa16258b09f08826797370310ab650530c/utils/src/main/java/xyz/truenight/utils/Utils.java#L1399-L1409
154,073
jbundle/jbundle
main/db/src/main/java/org/jbundle/main/user/db/SetupNewUserHandler.java
SetupNewUserHandler.getUserTemplate
public UserInfo getUserTemplate() { if (userControl == null) userControl = new UserControl(this.getOwner().findRecordOwner()); if (userControl != null) if ((userControl.getEditMode() == DBConstants.EDIT_CURRENT) || (userControl.getEditMode() == DBConstants.EDIT_IN_PROGRESS)) { UserInfo userInfo = (UserInfo)((ReferenceField)userControl.getField(UserControl.TEMPLATE_USER_ID)).getReference(); if (userInfo != null) if ((userInfo.getEditMode() == DBConstants.EDIT_CURRENT) || (userInfo.getEditMode() == DBConstants.EDIT_IN_PROGRESS)) return userInfo; } return null; }
java
public UserInfo getUserTemplate() { if (userControl == null) userControl = new UserControl(this.getOwner().findRecordOwner()); if (userControl != null) if ((userControl.getEditMode() == DBConstants.EDIT_CURRENT) || (userControl.getEditMode() == DBConstants.EDIT_IN_PROGRESS)) { UserInfo userInfo = (UserInfo)((ReferenceField)userControl.getField(UserControl.TEMPLATE_USER_ID)).getReference(); if (userInfo != null) if ((userInfo.getEditMode() == DBConstants.EDIT_CURRENT) || (userInfo.getEditMode() == DBConstants.EDIT_IN_PROGRESS)) return userInfo; } return null; }
[ "public", "UserInfo", "getUserTemplate", "(", ")", "{", "if", "(", "userControl", "==", "null", ")", "userControl", "=", "new", "UserControl", "(", "this", ".", "getOwner", "(", ")", ".", "findRecordOwner", "(", ")", ")", ";", "if", "(", "userControl", "!=", "null", ")", "if", "(", "(", "userControl", ".", "getEditMode", "(", ")", "==", "DBConstants", ".", "EDIT_CURRENT", ")", "||", "(", "userControl", ".", "getEditMode", "(", ")", "==", "DBConstants", ".", "EDIT_IN_PROGRESS", ")", ")", "{", "UserInfo", "userInfo", "=", "(", "UserInfo", ")", "(", "(", "ReferenceField", ")", "userControl", ".", "getField", "(", "UserControl", ".", "TEMPLATE_USER_ID", ")", ")", ".", "getReference", "(", ")", ";", "if", "(", "userInfo", "!=", "null", ")", "if", "(", "(", "userInfo", ".", "getEditMode", "(", ")", "==", "DBConstants", ".", "EDIT_CURRENT", ")", "||", "(", "userInfo", ".", "getEditMode", "(", ")", "==", "DBConstants", ".", "EDIT_IN_PROGRESS", ")", ")", "return", "userInfo", ";", "}", "return", "null", ";", "}" ]
GetUserTemplate Method.
[ "GetUserTemplate", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/db/src/main/java/org/jbundle/main/user/db/SetupNewUserHandler.java#L131-L144
154,074
jbundle/jbundle
thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/BaseBuffer.java
BaseBuffer.addNextField
public void addNextField(FieldInfo field) { if (((m_iFieldsTypes & MODIFIED_ONLY) == MODIFIED_ONLY) && (!field.isModified())) this.addNextData(DATA_SKIP); else this.addNextData(field.getData()); }
java
public void addNextField(FieldInfo field) { if (((m_iFieldsTypes & MODIFIED_ONLY) == MODIFIED_ONLY) && (!field.isModified())) this.addNextData(DATA_SKIP); else this.addNextData(field.getData()); }
[ "public", "void", "addNextField", "(", "FieldInfo", "field", ")", "{", "if", "(", "(", "(", "m_iFieldsTypes", "&", "MODIFIED_ONLY", ")", "==", "MODIFIED_ONLY", ")", "&&", "(", "!", "field", ".", "isModified", "(", ")", ")", ")", "this", ".", "addNextData", "(", "DATA_SKIP", ")", ";", "else", "this", ".", "addNextData", "(", "field", ".", "getData", "(", ")", ")", ";", "}" ]
Add this field to the buffer. @param field The field to add to this buffer.
[ "Add", "this", "field", "to", "the", "buffer", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/BaseBuffer.java#L141-L147
154,075
jbundle/jbundle
thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/BaseBuffer.java
BaseBuffer.bufferToFields
public int bufferToFields(FieldList record, boolean bDisplayOption, int iMoveMode) { this.resetPosition(); // Start at the first field int iFieldCount = record.getFieldCount(); // Number of fields to read in int iErrorCode = Constants.NORMAL_RETURN; int iTempError; for (int iFieldSeq = Constants.MAIN_FIELD; iFieldSeq <= iFieldCount + Constants.MAIN_FIELD - 1; iFieldSeq++) { FieldInfo field = record.getField(iFieldSeq); if (this.skipField(field)) iTempError = field.initField(bDisplayOption); else iTempError = this.getNextField(field, bDisplayOption, iMoveMode); if (iTempError != Constants.NORMAL_RETURN) iErrorCode = iTempError; } return iErrorCode; }
java
public int bufferToFields(FieldList record, boolean bDisplayOption, int iMoveMode) { this.resetPosition(); // Start at the first field int iFieldCount = record.getFieldCount(); // Number of fields to read in int iErrorCode = Constants.NORMAL_RETURN; int iTempError; for (int iFieldSeq = Constants.MAIN_FIELD; iFieldSeq <= iFieldCount + Constants.MAIN_FIELD - 1; iFieldSeq++) { FieldInfo field = record.getField(iFieldSeq); if (this.skipField(field)) iTempError = field.initField(bDisplayOption); else iTempError = this.getNextField(field, bDisplayOption, iMoveMode); if (iTempError != Constants.NORMAL_RETURN) iErrorCode = iTempError; } return iErrorCode; }
[ "public", "int", "bufferToFields", "(", "FieldList", "record", ",", "boolean", "bDisplayOption", ",", "int", "iMoveMode", ")", "{", "this", ".", "resetPosition", "(", ")", ";", "// Start at the first field", "int", "iFieldCount", "=", "record", ".", "getFieldCount", "(", ")", ";", "// Number of fields to read in", "int", "iErrorCode", "=", "Constants", ".", "NORMAL_RETURN", ";", "int", "iTempError", ";", "for", "(", "int", "iFieldSeq", "=", "Constants", ".", "MAIN_FIELD", ";", "iFieldSeq", "<=", "iFieldCount", "+", "Constants", ".", "MAIN_FIELD", "-", "1", ";", "iFieldSeq", "++", ")", "{", "FieldInfo", "field", "=", "record", ".", "getField", "(", "iFieldSeq", ")", ";", "if", "(", "this", ".", "skipField", "(", "field", ")", ")", "iTempError", "=", "field", ".", "initField", "(", "bDisplayOption", ")", ";", "else", "iTempError", "=", "this", ".", "getNextField", "(", "field", ",", "bDisplayOption", ",", "iMoveMode", ")", ";", "if", "(", "iTempError", "!=", "Constants", ".", "NORMAL_RETURN", ")", "iErrorCode", "=", "iTempError", ";", "}", "return", "iErrorCode", ";", "}" ]
Move the output buffer to all the fields. This is a utility method that populates the record. @param record The target record. @param bDisplayOption The display option for the movetofield call. @param iMoveMove The move mode for the movetofield call. @return The error code.
[ "Move", "the", "output", "buffer", "to", "all", "the", "fields", ".", "This", "is", "a", "utility", "method", "that", "populates", "the", "record", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/BaseBuffer.java#L171-L188
154,076
jbundle/jbundle
thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/BaseBuffer.java
BaseBuffer.bufferToFields
public int bufferToFields(FieldList record, int iFieldsTypes, boolean bDisplayOption, int iMoveMode) { m_iFieldsTypes = iFieldsTypes; return this.bufferToFields(record, bDisplayOption, iMoveMode); }
java
public int bufferToFields(FieldList record, int iFieldsTypes, boolean bDisplayOption, int iMoveMode) { m_iFieldsTypes = iFieldsTypes; return this.bufferToFields(record, bDisplayOption, iMoveMode); }
[ "public", "int", "bufferToFields", "(", "FieldList", "record", ",", "int", "iFieldsTypes", ",", "boolean", "bDisplayOption", ",", "int", "iMoveMode", ")", "{", "m_iFieldsTypes", "=", "iFieldsTypes", ";", "return", "this", ".", "bufferToFields", "(", "record", ",", "bDisplayOption", ",", "iMoveMode", ")", ";", "}" ]
Move the output buffer to all the fields. This is the same as the bufferToFields method, specifying the fieldTypes to move. @param record The target record. @param iFieldTypes The field types to move. @param bDisplayOption The display option for the movetofield call. @param iMoveMove The move mode for the movetofield call. @return The error code.
[ "Move", "the", "output", "buffer", "to", "all", "the", "fields", ".", "This", "is", "the", "same", "as", "the", "bufferToFields", "method", "specifying", "the", "fieldTypes", "to", "move", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/BaseBuffer.java#L198-L202
154,077
jbundle/jbundle
thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/BaseBuffer.java
BaseBuffer.fieldsToBuffer
public void fieldsToBuffer(FieldList record, int iFieldsTypes) { m_iFieldsTypes = iFieldsTypes; if (this.getHeaderCount() == 0) this.clearBuffer(); // Being careful. (Remember to call this at the start anyway) int fieldCount = record.getFieldCount(); // Number of fields to write out for (int iFieldSeq = Constants.MAIN_FIELD; iFieldSeq <= fieldCount + Constants.MAIN_FIELD - 1; iFieldSeq++) { FieldInfo field = record.getField(iFieldSeq); if (!this.skipField(field)) this.addNextField(field); } this.finishBuffer(); //pDestBuff, recordLength, physicalFieldCount); // two bytes for record length, two for field count }
java
public void fieldsToBuffer(FieldList record, int iFieldsTypes) { m_iFieldsTypes = iFieldsTypes; if (this.getHeaderCount() == 0) this.clearBuffer(); // Being careful. (Remember to call this at the start anyway) int fieldCount = record.getFieldCount(); // Number of fields to write out for (int iFieldSeq = Constants.MAIN_FIELD; iFieldSeq <= fieldCount + Constants.MAIN_FIELD - 1; iFieldSeq++) { FieldInfo field = record.getField(iFieldSeq); if (!this.skipField(field)) this.addNextField(field); } this.finishBuffer(); //pDestBuff, recordLength, physicalFieldCount); // two bytes for record length, two for field count }
[ "public", "void", "fieldsToBuffer", "(", "FieldList", "record", ",", "int", "iFieldsTypes", ")", "{", "m_iFieldsTypes", "=", "iFieldsTypes", ";", "if", "(", "this", ".", "getHeaderCount", "(", ")", "==", "0", ")", "this", ".", "clearBuffer", "(", ")", ";", "// Being careful. (Remember to call this at the start anyway)", "int", "fieldCount", "=", "record", ".", "getFieldCount", "(", ")", ";", "// Number of fields to write out", "for", "(", "int", "iFieldSeq", "=", "Constants", ".", "MAIN_FIELD", ";", "iFieldSeq", "<=", "fieldCount", "+", "Constants", ".", "MAIN_FIELD", "-", "1", ";", "iFieldSeq", "++", ")", "{", "FieldInfo", "field", "=", "record", ".", "getField", "(", "iFieldSeq", ")", ";", "if", "(", "!", "this", ".", "skipField", "(", "field", ")", ")", "this", ".", "addNextField", "(", "field", ")", ";", "}", "this", ".", "finishBuffer", "(", ")", ";", "//pDestBuff, recordLength, physicalFieldCount); // two bytes for record length, two for field count", "}" ]
Move all the fields to the output buffer. This is the same as the fieldsToBuffer method, specifying the fieldTypes to move. @param record The target record. @param iFieldTypes The field types to move.
[ "Move", "all", "the", "fields", "to", "the", "output", "buffer", ".", "This", "is", "the", "same", "as", "the", "fieldsToBuffer", "method", "specifying", "the", "fieldTypes", "to", "move", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/BaseBuffer.java#L225-L238
154,078
jbundle/jbundle
thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/BaseBuffer.java
BaseBuffer.skipField
public boolean skipField(FieldInfo field) { boolean bSkipField = true; if ((m_iFieldsTypes & DATA_TYPE_MASK) == ALL_FIELDS) bSkipField = false; // Don't skip any if ((m_iFieldsTypes & DATA_TYPE_MASK) == SELECTED_FIELDS) if (field.isSelected()) bSkipField = false; // Don't skip selected if ((m_iFieldsTypes & DATA_TYPE_MASK) == PHYSICAL_FIELDS) if (!field.isVirtual()) bSkipField = false; // Don't skip non-virtuals (Skip virtuals) if ((m_iFieldsTypes & DATA_TYPE_MASK) == DATA_FIELDS) // SELECTED_FIELDS | PHYSICAL_FIELDS if (field.isSelected()) if (!field.isVirtual()) bSkipField = false; // Don't skip selected (Skip virtuals) return bSkipField; }
java
public boolean skipField(FieldInfo field) { boolean bSkipField = true; if ((m_iFieldsTypes & DATA_TYPE_MASK) == ALL_FIELDS) bSkipField = false; // Don't skip any if ((m_iFieldsTypes & DATA_TYPE_MASK) == SELECTED_FIELDS) if (field.isSelected()) bSkipField = false; // Don't skip selected if ((m_iFieldsTypes & DATA_TYPE_MASK) == PHYSICAL_FIELDS) if (!field.isVirtual()) bSkipField = false; // Don't skip non-virtuals (Skip virtuals) if ((m_iFieldsTypes & DATA_TYPE_MASK) == DATA_FIELDS) // SELECTED_FIELDS | PHYSICAL_FIELDS if (field.isSelected()) if (!field.isVirtual()) bSkipField = false; // Don't skip selected (Skip virtuals) return bSkipField; }
[ "public", "boolean", "skipField", "(", "FieldInfo", "field", ")", "{", "boolean", "bSkipField", "=", "true", ";", "if", "(", "(", "m_iFieldsTypes", "&", "DATA_TYPE_MASK", ")", "==", "ALL_FIELDS", ")", "bSkipField", "=", "false", ";", "// Don't skip any", "if", "(", "(", "m_iFieldsTypes", "&", "DATA_TYPE_MASK", ")", "==", "SELECTED_FIELDS", ")", "if", "(", "field", ".", "isSelected", "(", ")", ")", "bSkipField", "=", "false", ";", "// Don't skip selected", "if", "(", "(", "m_iFieldsTypes", "&", "DATA_TYPE_MASK", ")", "==", "PHYSICAL_FIELDS", ")", "if", "(", "!", "field", ".", "isVirtual", "(", ")", ")", "bSkipField", "=", "false", ";", "// Don't skip non-virtuals (Skip virtuals)", "if", "(", "(", "m_iFieldsTypes", "&", "DATA_TYPE_MASK", ")", "==", "DATA_FIELDS", ")", "// SELECTED_FIELDS | PHYSICAL_FIELDS", "if", "(", "field", ".", "isSelected", "(", ")", ")", "if", "(", "!", "field", ".", "isVirtual", "(", ")", ")", "bSkipField", "=", "false", ";", "// Don't skip selected (Skip virtuals)", "return", "bSkipField", ";", "}" ]
Do I skip this field, based on the m_iFieldsTypes flag? @param field Should I skip this field? @return If true, skip this field.
[ "Do", "I", "skip", "this", "field", "based", "on", "the", "m_iFieldsTypes", "flag?" ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/BaseBuffer.java#L244-L260
154,079
jbundle/jbundle
thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/BaseBuffer.java
BaseBuffer.compareToBuffer
public boolean compareToBuffer(FieldList record) { boolean bBufferEqual = true; this.resetPosition(); // Start at the first field int iFieldCount = record.getFieldCount(); // Number of fields to read in for (int iFieldSeq = Constants.MAIN_FIELD; iFieldSeq <= iFieldCount + Constants.MAIN_FIELD - 1; iFieldSeq++) { FieldInfo field = record.getField(iFieldSeq); if (!this.skipField(field)) bBufferEqual = this.compareNextToField(field); if (!bBufferEqual) break; } return bBufferEqual; }
java
public boolean compareToBuffer(FieldList record) { boolean bBufferEqual = true; this.resetPosition(); // Start at the first field int iFieldCount = record.getFieldCount(); // Number of fields to read in for (int iFieldSeq = Constants.MAIN_FIELD; iFieldSeq <= iFieldCount + Constants.MAIN_FIELD - 1; iFieldSeq++) { FieldInfo field = record.getField(iFieldSeq); if (!this.skipField(field)) bBufferEqual = this.compareNextToField(field); if (!bBufferEqual) break; } return bBufferEqual; }
[ "public", "boolean", "compareToBuffer", "(", "FieldList", "record", ")", "{", "boolean", "bBufferEqual", "=", "true", ";", "this", ".", "resetPosition", "(", ")", ";", "// Start at the first field", "int", "iFieldCount", "=", "record", ".", "getFieldCount", "(", ")", ";", "// Number of fields to read in", "for", "(", "int", "iFieldSeq", "=", "Constants", ".", "MAIN_FIELD", ";", "iFieldSeq", "<=", "iFieldCount", "+", "Constants", ".", "MAIN_FIELD", "-", "1", ";", "iFieldSeq", "++", ")", "{", "FieldInfo", "field", "=", "record", ".", "getField", "(", "iFieldSeq", ")", ";", "if", "(", "!", "this", ".", "skipField", "(", "field", ")", ")", "bBufferEqual", "=", "this", ".", "compareNextToField", "(", "field", ")", ";", "if", "(", "!", "bBufferEqual", ")", "break", ";", "}", "return", "bBufferEqual", ";", "}" ]
Compare this output buffer to all the fields. This is a utility method that compares the record. @param record The target record. @return True if they are equal.
[ "Compare", "this", "output", "buffer", "to", "all", "the", "fields", ".", "This", "is", "a", "utility", "method", "that", "compares", "the", "record", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/BaseBuffer.java#L273-L287
154,080
jbundle/jbundle
thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/BaseBuffer.java
BaseBuffer.compareNextToField
public boolean compareNextToField(FieldInfo field) // Must be to call right Get calls { Object objNext = this.getNextData(); if (objNext == DATA_ERROR) return false; // EOF if (objNext == DATA_EOF) return false; // EOF if (objNext == DATA_SKIP) return true; // Don't set this field Object objField = field.getData(); if ((objNext == null) || (objField == null)) { if ((objNext == null) && (objField == null)) return true; return false; } return objNext.equals(objField); }
java
public boolean compareNextToField(FieldInfo field) // Must be to call right Get calls { Object objNext = this.getNextData(); if (objNext == DATA_ERROR) return false; // EOF if (objNext == DATA_EOF) return false; // EOF if (objNext == DATA_SKIP) return true; // Don't set this field Object objField = field.getData(); if ((objNext == null) || (objField == null)) { if ((objNext == null) && (objField == null)) return true; return false; } return objNext.equals(objField); }
[ "public", "boolean", "compareNextToField", "(", "FieldInfo", "field", ")", "// Must be to call right Get calls", "{", "Object", "objNext", "=", "this", ".", "getNextData", "(", ")", ";", "if", "(", "objNext", "==", "DATA_ERROR", ")", "return", "false", ";", "// EOF", "if", "(", "objNext", "==", "DATA_EOF", ")", "return", "false", ";", "// EOF", "if", "(", "objNext", "==", "DATA_SKIP", ")", "return", "true", ";", "// Don't set this field", "Object", "objField", "=", "field", ".", "getData", "(", ")", ";", "if", "(", "(", "objNext", "==", "null", ")", "||", "(", "objField", "==", "null", ")", ")", "{", "if", "(", "(", "objNext", "==", "null", ")", "&&", "(", "objField", "==", "null", ")", ")", "return", "true", ";", "return", "false", ";", "}", "return", "objNext", ".", "equals", "(", "objField", ")", ";", "}" ]
Compare this fields with the next data in the buffer. This is a utility method that compares the record. @param field The target field. @return True if they are equal.
[ "Compare", "this", "fields", "with", "the", "next", "data", "in", "the", "buffer", ".", "This", "is", "a", "utility", "method", "that", "compares", "the", "record", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/BaseBuffer.java#L294-L311
154,081
jbundle/jbundle
thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/BaseBuffer.java
BaseBuffer.getNextString
public String getNextString() { Object data = this.getNextData(); if (data instanceof String) return (String)data; return null; // EOF }
java
public String getNextString() { Object data = this.getNextData(); if (data instanceof String) return (String)data; return null; // EOF }
[ "public", "String", "getNextString", "(", ")", "{", "Object", "data", "=", "this", ".", "getNextData", "(", ")", ";", "if", "(", "data", "instanceof", "String", ")", "return", "(", "String", ")", "data", ";", "return", "null", ";", "// EOF", "}" ]
Get next next string. @param Retrieve the next object from this buffer and return it if it is a string.
[ "Get", "next", "next", "string", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/base/src/main/java/org/jbundle/thin/base/db/buff/BaseBuffer.java#L351-L357
154,082
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.init
private void init() throws IndexerException { if (!loaded) { loaded = true; String storageType = config.getString(null, "storage", "type"); try { storage = PluginManager.getStorage(storageType); storage.init(config.toString()); } catch (PluginException pe) { throw new IndexerException(pe); } // Credentials usernameMap = new HashMap<String, String>(); passwordMap = new HashMap<String, String>(); solr = initCore("solr"); anotar = initCore("anotar"); // initialise non-hardcoded indexers solrServerMap = new HashMap<String, SolrServer>(); JsonObject indexerConfig = config.getObject("indexer"); List<String> hardcodedValues = Arrays.asList("type", "properties", "useCache", "buffer", "solr", "anotar"); for (Object key : indexerConfig.keySet()) { if (key instanceof String) { String keyString = (String) key; if (!hardcodedValues.contains(keyString)) { solrServerMap.put(keyString, initCore(keyString)); } } } anotarAutoCommit = config.getBoolean(true, "indexer", "anotar", "autocommit"); propertiesId = config.getString(DEFAULT_METADATA_PAYLOAD, "indexer", "propertiesId"); customParams = new HashMap<String, String>(); // Caching scriptCache = new HashMap<String, PyObject>(); groovyScriptCache = new HashMap<String, String>(); configCache = new HashMap<String, JsonSimpleConfig>(); useCache = config.getBoolean(true, "indexer", "useCache"); } loaded = true; }
java
private void init() throws IndexerException { if (!loaded) { loaded = true; String storageType = config.getString(null, "storage", "type"); try { storage = PluginManager.getStorage(storageType); storage.init(config.toString()); } catch (PluginException pe) { throw new IndexerException(pe); } // Credentials usernameMap = new HashMap<String, String>(); passwordMap = new HashMap<String, String>(); solr = initCore("solr"); anotar = initCore("anotar"); // initialise non-hardcoded indexers solrServerMap = new HashMap<String, SolrServer>(); JsonObject indexerConfig = config.getObject("indexer"); List<String> hardcodedValues = Arrays.asList("type", "properties", "useCache", "buffer", "solr", "anotar"); for (Object key : indexerConfig.keySet()) { if (key instanceof String) { String keyString = (String) key; if (!hardcodedValues.contains(keyString)) { solrServerMap.put(keyString, initCore(keyString)); } } } anotarAutoCommit = config.getBoolean(true, "indexer", "anotar", "autocommit"); propertiesId = config.getString(DEFAULT_METADATA_PAYLOAD, "indexer", "propertiesId"); customParams = new HashMap<String, String>(); // Caching scriptCache = new HashMap<String, PyObject>(); groovyScriptCache = new HashMap<String, String>(); configCache = new HashMap<String, JsonSimpleConfig>(); useCache = config.getBoolean(true, "indexer", "useCache"); } loaded = true; }
[ "private", "void", "init", "(", ")", "throws", "IndexerException", "{", "if", "(", "!", "loaded", ")", "{", "loaded", "=", "true", ";", "String", "storageType", "=", "config", ".", "getString", "(", "null", ",", "\"storage\"", ",", "\"type\"", ")", ";", "try", "{", "storage", "=", "PluginManager", ".", "getStorage", "(", "storageType", ")", ";", "storage", ".", "init", "(", "config", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "PluginException", "pe", ")", "{", "throw", "new", "IndexerException", "(", "pe", ")", ";", "}", "// Credentials", "usernameMap", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "passwordMap", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "solr", "=", "initCore", "(", "\"solr\"", ")", ";", "anotar", "=", "initCore", "(", "\"anotar\"", ")", ";", "// initialise non-hardcoded indexers", "solrServerMap", "=", "new", "HashMap", "<", "String", ",", "SolrServer", ">", "(", ")", ";", "JsonObject", "indexerConfig", "=", "config", ".", "getObject", "(", "\"indexer\"", ")", ";", "List", "<", "String", ">", "hardcodedValues", "=", "Arrays", ".", "asList", "(", "\"type\"", ",", "\"properties\"", ",", "\"useCache\"", ",", "\"buffer\"", ",", "\"solr\"", ",", "\"anotar\"", ")", ";", "for", "(", "Object", "key", ":", "indexerConfig", ".", "keySet", "(", ")", ")", "{", "if", "(", "key", "instanceof", "String", ")", "{", "String", "keyString", "=", "(", "String", ")", "key", ";", "if", "(", "!", "hardcodedValues", ".", "contains", "(", "keyString", ")", ")", "{", "solrServerMap", ".", "put", "(", "keyString", ",", "initCore", "(", "keyString", ")", ")", ";", "}", "}", "}", "anotarAutoCommit", "=", "config", ".", "getBoolean", "(", "true", ",", "\"indexer\"", ",", "\"anotar\"", ",", "\"autocommit\"", ")", ";", "propertiesId", "=", "config", ".", "getString", "(", "DEFAULT_METADATA_PAYLOAD", ",", "\"indexer\"", ",", "\"propertiesId\"", ")", ";", "customParams", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "// Caching", "scriptCache", "=", "new", "HashMap", "<", "String", ",", "PyObject", ">", "(", ")", ";", "groovyScriptCache", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "configCache", "=", "new", "HashMap", "<", "String", ",", "JsonSimpleConfig", ">", "(", ")", ";", "useCache", "=", "config", ".", "getBoolean", "(", "true", ",", "\"indexer\"", ",", "\"useCache\"", ")", ";", "}", "loaded", "=", "true", ";", "}" ]
Private method wrapped by the above two methods to perform the actual initialization after the JSON config is accessed. @throws IndexerException if errors occur during initialization
[ "Private", "method", "wrapped", "by", "the", "above", "two", "methods", "to", "perform", "the", "actual", "initialization", "after", "the", "JSON", "config", "is", "accessed", "." ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L328-L374
154,083
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.search
@Override public void search(SearchRequest request, OutputStream response, String format) throws IndexerException { SolrSearcher searcher = new SolrSearcher(((CommonsHttpSolrServer) solr).getBaseURL()); String username = usernameMap.get("solr"); String password = passwordMap.get("solr"); if (username != null && password != null) { searcher.authenticate(username, password); } InputStream result; try { request.addParam("wt", format); result = searcher.get(request.getQuery(), request.getParamsMap(), false); IOUtils.copy(result, response); result.close(); } catch (IOException ioe) { throw new IndexerException(ioe); } }
java
@Override public void search(SearchRequest request, OutputStream response, String format) throws IndexerException { SolrSearcher searcher = new SolrSearcher(((CommonsHttpSolrServer) solr).getBaseURL()); String username = usernameMap.get("solr"); String password = passwordMap.get("solr"); if (username != null && password != null) { searcher.authenticate(username, password); } InputStream result; try { request.addParam("wt", format); result = searcher.get(request.getQuery(), request.getParamsMap(), false); IOUtils.copy(result, response); result.close(); } catch (IOException ioe) { throw new IndexerException(ioe); } }
[ "@", "Override", "public", "void", "search", "(", "SearchRequest", "request", ",", "OutputStream", "response", ",", "String", "format", ")", "throws", "IndexerException", "{", "SolrSearcher", "searcher", "=", "new", "SolrSearcher", "(", "(", "(", "CommonsHttpSolrServer", ")", "solr", ")", ".", "getBaseURL", "(", ")", ")", ";", "String", "username", "=", "usernameMap", ".", "get", "(", "\"solr\"", ")", ";", "String", "password", "=", "passwordMap", ".", "get", "(", "\"solr\"", ")", ";", "if", "(", "username", "!=", "null", "&&", "password", "!=", "null", ")", "{", "searcher", ".", "authenticate", "(", "username", ",", "password", ")", ";", "}", "InputStream", "result", ";", "try", "{", "request", ".", "addParam", "(", "\"wt\"", ",", "format", ")", ";", "result", "=", "searcher", ".", "get", "(", "request", ".", "getQuery", "(", ")", ",", "request", ".", "getParamsMap", "(", ")", ",", "false", ")", ";", "IOUtils", ".", "copy", "(", "result", ",", "response", ")", ";", "result", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "throw", "new", "IndexerException", "(", "ioe", ")", ";", "}", "}" ]
Perform a Solr search and stream the results into the provided output format @param request : A prepared SearchRequest object @param response : The OutputStream to send results to @param format : Output format - passed directly to SOlr as the "wt" parameter @throws IndexerException if there were errors during the search
[ "Perform", "a", "Solr", "search", "and", "stream", "the", "results", "into", "the", "provided", "output", "format" ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L486-L503
154,084
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.remove
@Override public void remove(String oid) throws IndexerException { log.debug("Deleting " + oid + " from index"); try { solr.deleteByQuery("storage_id:\"" + oid + "\""); solr.commit(); } catch (SolrServerException sse) { throw new IndexerException(sse); } catch (IOException ioe) { throw new IndexerException(ioe); } }
java
@Override public void remove(String oid) throws IndexerException { log.debug("Deleting " + oid + " from index"); try { solr.deleteByQuery("storage_id:\"" + oid + "\""); solr.commit(); } catch (SolrServerException sse) { throw new IndexerException(sse); } catch (IOException ioe) { throw new IndexerException(ioe); } }
[ "@", "Override", "public", "void", "remove", "(", "String", "oid", ")", "throws", "IndexerException", "{", "log", ".", "debug", "(", "\"Deleting \"", "+", "oid", "+", "\" from index\"", ")", ";", "try", "{", "solr", ".", "deleteByQuery", "(", "\"storage_id:\\\"\"", "+", "oid", "+", "\"\\\"\"", ")", ";", "solr", ".", "commit", "(", ")", ";", "}", "catch", "(", "SolrServerException", "sse", ")", "{", "throw", "new", "IndexerException", "(", "sse", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "throw", "new", "IndexerException", "(", "ioe", ")", ";", "}", "}" ]
Remove the specified object from the index @param oid : The identifier of the object to remove @throws IndexerException if there were errors during removal
[ "Remove", "the", "specified", "object", "from", "the", "index" ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L513-L524
154,085
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.annotateRemove
@Override public void annotateRemove(String oid) throws IndexerException { log.debug("Deleting " + oid + " from Anotar index"); try { anotar.deleteByQuery("rootUri:\"" + oid + "\""); anotar.commit(); } catch (SolrServerException sse) { throw new IndexerException(sse); } catch (IOException ioe) { throw new IndexerException(ioe); } }
java
@Override public void annotateRemove(String oid) throws IndexerException { log.debug("Deleting " + oid + " from Anotar index"); try { anotar.deleteByQuery("rootUri:\"" + oid + "\""); anotar.commit(); } catch (SolrServerException sse) { throw new IndexerException(sse); } catch (IOException ioe) { throw new IndexerException(ioe); } }
[ "@", "Override", "public", "void", "annotateRemove", "(", "String", "oid", ")", "throws", "IndexerException", "{", "log", ".", "debug", "(", "\"Deleting \"", "+", "oid", "+", "\" from Anotar index\"", ")", ";", "try", "{", "anotar", ".", "deleteByQuery", "(", "\"rootUri:\\\"\"", "+", "oid", "+", "\"\\\"\"", ")", ";", "anotar", ".", "commit", "(", ")", ";", "}", "catch", "(", "SolrServerException", "sse", ")", "{", "throw", "new", "IndexerException", "(", "sse", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "throw", "new", "IndexerException", "(", "ioe", ")", ";", "}", "}" ]
Remove all annotations from the index against an object @param oid : The identifier of the object @throws IndexerException if there were errors during removal
[ "Remove", "all", "annotations", "from", "the", "index", "against", "an", "object" ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L557-L568
154,086
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.index
@Override public void index(String oid) throws IndexerException { try { DigitalObject object = storage.getObject(oid); // Some workflow actions create payloads, so we can't iterate // directly against the object. String[] oldManifest = {}; oldManifest = object.getPayloadIdList().toArray(oldManifest); for (String payloadId : oldManifest) { Payload payload = object.getPayload(payloadId); if (!payload.getLabel().matches("version_tfpackage_.*")) { index(object, payload); } } } catch (StorageException ex) { throw new IndexerException(ex); } }
java
@Override public void index(String oid) throws IndexerException { try { DigitalObject object = storage.getObject(oid); // Some workflow actions create payloads, so we can't iterate // directly against the object. String[] oldManifest = {}; oldManifest = object.getPayloadIdList().toArray(oldManifest); for (String payloadId : oldManifest) { Payload payload = object.getPayload(payloadId); if (!payload.getLabel().matches("version_tfpackage_.*")) { index(object, payload); } } } catch (StorageException ex) { throw new IndexerException(ex); } }
[ "@", "Override", "public", "void", "index", "(", "String", "oid", ")", "throws", "IndexerException", "{", "try", "{", "DigitalObject", "object", "=", "storage", ".", "getObject", "(", "oid", ")", ";", "// Some workflow actions create payloads, so we can't iterate", "// directly against the object.", "String", "[", "]", "oldManifest", "=", "{", "}", ";", "oldManifest", "=", "object", ".", "getPayloadIdList", "(", ")", ".", "toArray", "(", "oldManifest", ")", ";", "for", "(", "String", "payloadId", ":", "oldManifest", ")", "{", "Payload", "payload", "=", "object", ".", "getPayload", "(", "payloadId", ")", ";", "if", "(", "!", "payload", ".", "getLabel", "(", ")", ".", "matches", "(", "\"version_tfpackage_.*\"", ")", ")", "{", "index", "(", "object", ",", "payload", ")", ";", "}", "}", "}", "catch", "(", "StorageException", "ex", ")", "{", "throw", "new", "IndexerException", "(", "ex", ")", ";", "}", "}" ]
Index an object and all of its payloads @param oid : The identifier of the object @throws IndexerException if there were errors during indexing
[ "Index", "an", "object", "and", "all", "of", "its", "payloads" ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L601-L618
154,087
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.indexByGroovyScript
private String indexByGroovyScript(DigitalObject object, Payload payload, String confOid, String rulesOid, Properties props) throws RuleException { try { if (engine == null) { SimpleBindings bindings = new SimpleBindings(); ScriptEngineManager manager = new ScriptEngineManager(); engine = manager.getEngineByName("groovy"); // the engine is stateful, and multiple queues means that // different queues will clash // still won't affect different messages coming through the same // queue as AMQ will deal with sycnhronization // will affect how config is read in the messaging scripts, // needs to access it as `configMap[<queue name>]` // configMap = new HashMap<String, HashMap<String, Object>>(); // engine.put("configMap", configMap); } JsonSimpleConfig jsonConfig = getConfigFile(confOid); // Get our data ready SimpleBindings bindings = new SimpleBindings(); Map<String, List<String>> fields = new HashMap<String, List<String>>(); bindings.put("fields", fields); bindings.put("jsonConfig", jsonConfig); bindings.put("indexer", this); bindings.put("object", object); bindings.put("payload", payload); bindings.put("params", props); bindings.put("log", log); // Run the data through our script Reader script = getGroovyObject(rulesOid); engine.setBindings(bindings, ScriptContext.ENGINE_SCOPE); SolrInputDocument document = (SolrInputDocument) engine.eval(script); StringWriter documentString = new StringWriter(); ClientUtils.writeXML(document, documentString); return documentString.toString(); } catch (Exception e) { throw new RuleException(e); } }
java
private String indexByGroovyScript(DigitalObject object, Payload payload, String confOid, String rulesOid, Properties props) throws RuleException { try { if (engine == null) { SimpleBindings bindings = new SimpleBindings(); ScriptEngineManager manager = new ScriptEngineManager(); engine = manager.getEngineByName("groovy"); // the engine is stateful, and multiple queues means that // different queues will clash // still won't affect different messages coming through the same // queue as AMQ will deal with sycnhronization // will affect how config is read in the messaging scripts, // needs to access it as `configMap[<queue name>]` // configMap = new HashMap<String, HashMap<String, Object>>(); // engine.put("configMap", configMap); } JsonSimpleConfig jsonConfig = getConfigFile(confOid); // Get our data ready SimpleBindings bindings = new SimpleBindings(); Map<String, List<String>> fields = new HashMap<String, List<String>>(); bindings.put("fields", fields); bindings.put("jsonConfig", jsonConfig); bindings.put("indexer", this); bindings.put("object", object); bindings.put("payload", payload); bindings.put("params", props); bindings.put("log", log); // Run the data through our script Reader script = getGroovyObject(rulesOid); engine.setBindings(bindings, ScriptContext.ENGINE_SCOPE); SolrInputDocument document = (SolrInputDocument) engine.eval(script); StringWriter documentString = new StringWriter(); ClientUtils.writeXML(document, documentString); return documentString.toString(); } catch (Exception e) { throw new RuleException(e); } }
[ "private", "String", "indexByGroovyScript", "(", "DigitalObject", "object", ",", "Payload", "payload", ",", "String", "confOid", ",", "String", "rulesOid", ",", "Properties", "props", ")", "throws", "RuleException", "{", "try", "{", "if", "(", "engine", "==", "null", ")", "{", "SimpleBindings", "bindings", "=", "new", "SimpleBindings", "(", ")", ";", "ScriptEngineManager", "manager", "=", "new", "ScriptEngineManager", "(", ")", ";", "engine", "=", "manager", ".", "getEngineByName", "(", "\"groovy\"", ")", ";", "// the engine is stateful, and multiple queues means that", "// different queues will clash", "// still won't affect different messages coming through the same", "// queue as AMQ will deal with sycnhronization", "// will affect how config is read in the messaging scripts,", "// needs to access it as `configMap[<queue name>]`", "// configMap = new HashMap<String, HashMap<String, Object>>();", "// engine.put(\"configMap\", configMap);", "}", "JsonSimpleConfig", "jsonConfig", "=", "getConfigFile", "(", "confOid", ")", ";", "// Get our data ready", "SimpleBindings", "bindings", "=", "new", "SimpleBindings", "(", ")", ";", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "fields", "=", "new", "HashMap", "<", "String", ",", "List", "<", "String", ">", ">", "(", ")", ";", "bindings", ".", "put", "(", "\"fields\"", ",", "fields", ")", ";", "bindings", ".", "put", "(", "\"jsonConfig\"", ",", "jsonConfig", ")", ";", "bindings", ".", "put", "(", "\"indexer\"", ",", "this", ")", ";", "bindings", ".", "put", "(", "\"object\"", ",", "object", ")", ";", "bindings", ".", "put", "(", "\"payload\"", ",", "payload", ")", ";", "bindings", ".", "put", "(", "\"params\"", ",", "props", ")", ";", "bindings", ".", "put", "(", "\"log\"", ",", "log", ")", ";", "// Run the data through our script", "Reader", "script", "=", "getGroovyObject", "(", "rulesOid", ")", ";", "engine", ".", "setBindings", "(", "bindings", ",", "ScriptContext", ".", "ENGINE_SCOPE", ")", ";", "SolrInputDocument", "document", "=", "(", "SolrInputDocument", ")", "engine", ".", "eval", "(", "script", ")", ";", "StringWriter", "documentString", "=", "new", "StringWriter", "(", ")", ";", "ClientUtils", ".", "writeXML", "(", "document", ",", "documentString", ")", ";", "return", "documentString", ".", "toString", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuleException", "(", "e", ")", ";", "}", "}" ]
Index a payload using the provided data using a groovy script @param object : The DigitalObject to index @param payload : The Payload to index @param in : Reader containing the new empty document @param inConf : An InputStream holding the config file @param rulesOid : The oid of the rules file to use @param props : Properties object containing the object's metadata @return File : Temporary file containing the output to index @throws IOException if there were errors accessing files @throws RuleException if there were errors during indexing
[ "Index", "a", "payload", "using", "the", "provided", "data", "using", "a", "groovy", "script" ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L723-L766
154,088
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.sendIndexToBuffer
public void sendIndexToBuffer(String index, Map<String, List<String>> fields) { String doc = pyUtils.solrDocument(fields); addToBuffer(index, doc); }
java
public void sendIndexToBuffer(String index, Map<String, List<String>> fields) { String doc = pyUtils.solrDocument(fields); addToBuffer(index, doc); }
[ "public", "void", "sendIndexToBuffer", "(", "String", "index", ",", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "fields", ")", "{", "String", "doc", "=", "pyUtils", ".", "solrDocument", "(", "fields", ")", ";", "addToBuffer", "(", "index", ",", "doc", ")", ";", "}" ]
Send the document to buffer directly @param index @param fields
[ "Send", "the", "document", "to", "buffer", "directly" ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L829-L832
154,089
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.sendToIndex
private void sendToIndex(String message) { try { getMessaging().queueMessage(SolrWrapperQueueConsumer.QUEUE_ID, message); } catch (MessagingException ex) { log.error("Unable to send message: ", ex); } }
java
private void sendToIndex(String message) { try { getMessaging().queueMessage(SolrWrapperQueueConsumer.QUEUE_ID, message); } catch (MessagingException ex) { log.error("Unable to send message: ", ex); } }
[ "private", "void", "sendToIndex", "(", "String", "message", ")", "{", "try", "{", "getMessaging", "(", ")", ".", "queueMessage", "(", "SolrWrapperQueueConsumer", ".", "QUEUE_ID", ",", "message", ")", ";", "}", "catch", "(", "MessagingException", "ex", ")", "{", "log", ".", "error", "(", "\"Unable to send message: \"", ",", "ex", ")", ";", "}", "}" ]
To put events to subscriber queue @param oid Object id @param eventType type of events happened @param context where the event happened @param jsonFile Configuration file
[ "To", "put", "events", "to", "subscriber", "queue" ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L846-L852
154,090
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.annotate
private void annotate(DigitalObject object, Payload payload) throws IndexerException { String pid = payload.getId(); if (propertiesId.equals(pid)) { return; } try { Properties props = new Properties(); props.setProperty("metaPid", pid); String doc = indexByPythonScript(object, payload, null, ANOTAR_RULES_OID, props); if (doc != null) { doc = "<add>" + doc + "</add>"; anotar.request(new DirectXmlRequest("/update", doc)); if (anotarAutoCommit) { anotar.commit(); } } } catch (Exception e) { log.error("Indexing failed!\n-----\n", e); } }
java
private void annotate(DigitalObject object, Payload payload) throws IndexerException { String pid = payload.getId(); if (propertiesId.equals(pid)) { return; } try { Properties props = new Properties(); props.setProperty("metaPid", pid); String doc = indexByPythonScript(object, payload, null, ANOTAR_RULES_OID, props); if (doc != null) { doc = "<add>" + doc + "</add>"; anotar.request(new DirectXmlRequest("/update", doc)); if (anotarAutoCommit) { anotar.commit(); } } } catch (Exception e) { log.error("Indexing failed!\n-----\n", e); } }
[ "private", "void", "annotate", "(", "DigitalObject", "object", ",", "Payload", "payload", ")", "throws", "IndexerException", "{", "String", "pid", "=", "payload", ".", "getId", "(", ")", ";", "if", "(", "propertiesId", ".", "equals", "(", "pid", ")", ")", "{", "return", ";", "}", "try", "{", "Properties", "props", "=", "new", "Properties", "(", ")", ";", "props", ".", "setProperty", "(", "\"metaPid\"", ",", "pid", ")", ";", "String", "doc", "=", "indexByPythonScript", "(", "object", ",", "payload", ",", "null", ",", "ANOTAR_RULES_OID", ",", "props", ")", ";", "if", "(", "doc", "!=", "null", ")", "{", "doc", "=", "\"<add>\"", "+", "doc", "+", "\"</add>\"", ";", "anotar", ".", "request", "(", "new", "DirectXmlRequest", "(", "\"/update\"", ",", "doc", ")", ")", ";", "if", "(", "anotarAutoCommit", ")", "{", "anotar", ".", "commit", "(", ")", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"Indexing failed!\\n-----\\n\"", ",", "e", ")", ";", "}", "}" ]
Index a specific annotation @param object : The annotation's object @param pid : The annotation payload @throws IndexerException if there were errors during indexing
[ "Index", "a", "specific", "annotation" ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L887-L908
154,091
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.indexByPythonScript
private String indexByPythonScript(DigitalObject object, Payload payload, String confOid, String rulesOid, Properties props) throws IOException, RuleException { try { JsonSimpleConfig jsonConfig = getConfigFile(confOid); // Get our data ready Map<String, Object> bindings = new HashMap<String, Object>(); Map<String, List<String>> fields = new HashMap<String, List<String>>(); bindings.put("fields", fields); bindings.put("jsonConfig", jsonConfig); bindings.put("indexer", this); bindings.put("object", object); bindings.put("payload", payload); bindings.put("params", props); bindings.put("pyUtils", getPyUtils()); bindings.put("log", log); // Run the data through our script PyObject script = getPythonObject(rulesOid); if (script.__findattr__(SCRIPT_ACTIVATE_METHOD) != null) { script.invoke(SCRIPT_ACTIVATE_METHOD, Py.java2py(bindings)); object.close(); } else { log.warn("Activation method not found!"); } return getPyUtils().solrDocument(fields); } catch (Exception e) { throw new RuleException(e); } }
java
private String indexByPythonScript(DigitalObject object, Payload payload, String confOid, String rulesOid, Properties props) throws IOException, RuleException { try { JsonSimpleConfig jsonConfig = getConfigFile(confOid); // Get our data ready Map<String, Object> bindings = new HashMap<String, Object>(); Map<String, List<String>> fields = new HashMap<String, List<String>>(); bindings.put("fields", fields); bindings.put("jsonConfig", jsonConfig); bindings.put("indexer", this); bindings.put("object", object); bindings.put("payload", payload); bindings.put("params", props); bindings.put("pyUtils", getPyUtils()); bindings.put("log", log); // Run the data through our script PyObject script = getPythonObject(rulesOid); if (script.__findattr__(SCRIPT_ACTIVATE_METHOD) != null) { script.invoke(SCRIPT_ACTIVATE_METHOD, Py.java2py(bindings)); object.close(); } else { log.warn("Activation method not found!"); } return getPyUtils().solrDocument(fields); } catch (Exception e) { throw new RuleException(e); } }
[ "private", "String", "indexByPythonScript", "(", "DigitalObject", "object", ",", "Payload", "payload", ",", "String", "confOid", ",", "String", "rulesOid", ",", "Properties", "props", ")", "throws", "IOException", ",", "RuleException", "{", "try", "{", "JsonSimpleConfig", "jsonConfig", "=", "getConfigFile", "(", "confOid", ")", ";", "// Get our data ready", "Map", "<", "String", ",", "Object", ">", "bindings", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "fields", "=", "new", "HashMap", "<", "String", ",", "List", "<", "String", ">", ">", "(", ")", ";", "bindings", ".", "put", "(", "\"fields\"", ",", "fields", ")", ";", "bindings", ".", "put", "(", "\"jsonConfig\"", ",", "jsonConfig", ")", ";", "bindings", ".", "put", "(", "\"indexer\"", ",", "this", ")", ";", "bindings", ".", "put", "(", "\"object\"", ",", "object", ")", ";", "bindings", ".", "put", "(", "\"payload\"", ",", "payload", ")", ";", "bindings", ".", "put", "(", "\"params\"", ",", "props", ")", ";", "bindings", ".", "put", "(", "\"pyUtils\"", ",", "getPyUtils", "(", ")", ")", ";", "bindings", ".", "put", "(", "\"log\"", ",", "log", ")", ";", "// Run the data through our script", "PyObject", "script", "=", "getPythonObject", "(", "rulesOid", ")", ";", "if", "(", "script", ".", "__findattr__", "(", "SCRIPT_ACTIVATE_METHOD", ")", "!=", "null", ")", "{", "script", ".", "invoke", "(", "SCRIPT_ACTIVATE_METHOD", ",", "Py", ".", "java2py", "(", "bindings", ")", ")", ";", "object", ".", "close", "(", ")", ";", "}", "else", "{", "log", ".", "warn", "(", "\"Activation method not found!\"", ")", ";", "}", "return", "getPyUtils", "(", ")", ".", "solrDocument", "(", "fields", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuleException", "(", "e", ")", ";", "}", "}" ]
Index a payload using the provided data using a python script @param object : The DigitalObject to index @param payload : The Payload to index @param in : Reader containing the new empty document @param inConf : An InputStream holding the config file @param rulesOid : The oid of the rules file to use @param props : Properties object containing the object's metadata @return File : Temporary file containing the output to index @throws IOException if there were errors accessing files @throws RuleException if there were errors during indexing
[ "Index", "a", "payload", "using", "the", "provided", "data", "using", "a", "python", "script" ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L992-L1022
154,092
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.getPythonObject
private PyObject getPythonObject(String oid) { // Try the cache first PyObject rulesObject = deCachePythonObject(oid); if (rulesObject != null) { return rulesObject; } // We need to evaluate then InputStream inStream; if (oid.equals(ANOTAR_RULES_OID)) { // Anotar rules inStream = getClass().getResourceAsStream("/anotar.py"); log.debug("First time parsing rules script: 'ANOTAR'"); rulesObject = evalScript(inStream, "anotar.py"); cachePythonObject(oid, rulesObject); return rulesObject; } else { // A standard rules file DigitalObject object; Payload payload; try { object = storage.getObject(oid); String scriptName = object.getSourceId(); payload = object.getPayload(scriptName); inStream = payload.open(); log.debug("First time parsing rules script: '{}'", oid); rulesObject = evalScript(inStream, scriptName); payload.close(); cachePythonObject(oid, rulesObject); return rulesObject; } catch (StorageException ex) { log.error("Rules file could not be retrieved! '{}'", oid, ex); return null; } } }
java
private PyObject getPythonObject(String oid) { // Try the cache first PyObject rulesObject = deCachePythonObject(oid); if (rulesObject != null) { return rulesObject; } // We need to evaluate then InputStream inStream; if (oid.equals(ANOTAR_RULES_OID)) { // Anotar rules inStream = getClass().getResourceAsStream("/anotar.py"); log.debug("First time parsing rules script: 'ANOTAR'"); rulesObject = evalScript(inStream, "anotar.py"); cachePythonObject(oid, rulesObject); return rulesObject; } else { // A standard rules file DigitalObject object; Payload payload; try { object = storage.getObject(oid); String scriptName = object.getSourceId(); payload = object.getPayload(scriptName); inStream = payload.open(); log.debug("First time parsing rules script: '{}'", oid); rulesObject = evalScript(inStream, scriptName); payload.close(); cachePythonObject(oid, rulesObject); return rulesObject; } catch (StorageException ex) { log.error("Rules file could not be retrieved! '{}'", oid, ex); return null; } } }
[ "private", "PyObject", "getPythonObject", "(", "String", "oid", ")", "{", "// Try the cache first", "PyObject", "rulesObject", "=", "deCachePythonObject", "(", "oid", ")", ";", "if", "(", "rulesObject", "!=", "null", ")", "{", "return", "rulesObject", ";", "}", "// We need to evaluate then", "InputStream", "inStream", ";", "if", "(", "oid", ".", "equals", "(", "ANOTAR_RULES_OID", ")", ")", "{", "// Anotar rules", "inStream", "=", "getClass", "(", ")", ".", "getResourceAsStream", "(", "\"/anotar.py\"", ")", ";", "log", ".", "debug", "(", "\"First time parsing rules script: 'ANOTAR'\"", ")", ";", "rulesObject", "=", "evalScript", "(", "inStream", ",", "\"anotar.py\"", ")", ";", "cachePythonObject", "(", "oid", ",", "rulesObject", ")", ";", "return", "rulesObject", ";", "}", "else", "{", "// A standard rules file", "DigitalObject", "object", ";", "Payload", "payload", ";", "try", "{", "object", "=", "storage", ".", "getObject", "(", "oid", ")", ";", "String", "scriptName", "=", "object", ".", "getSourceId", "(", ")", ";", "payload", "=", "object", ".", "getPayload", "(", "scriptName", ")", ";", "inStream", "=", "payload", ".", "open", "(", ")", ";", "log", ".", "debug", "(", "\"First time parsing rules script: '{}'\"", ",", "oid", ")", ";", "rulesObject", "=", "evalScript", "(", "inStream", ",", "scriptName", ")", ";", "payload", ".", "close", "(", ")", ";", "cachePythonObject", "(", "oid", ",", "rulesObject", ")", ";", "return", "rulesObject", ";", "}", "catch", "(", "StorageException", "ex", ")", "{", "log", ".", "error", "(", "\"Rules file could not be retrieved! '{}'\"", ",", "oid", ",", "ex", ")", ";", "return", "null", ";", "}", "}", "}" ]
Evaluate the rules file stored under the provided object ID. If caching is configured the compiled python object will be cached to speed up subsequent access. @param oid : The rules OID to retrieve if cached @return PyObject : The cached object, null if not found
[ "Evaluate", "the", "rules", "file", "stored", "under", "the", "provided", "object", "ID", ".", "If", "caching", "is", "configured", "the", "compiled", "python", "object", "will", "be", "cached", "to", "speed", "up", "subsequent", "access", "." ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L1033-L1068
154,093
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.getConfigFile
private JsonSimpleConfig getConfigFile(String oid) { if (oid == null) { return null; } // Try the cache first JsonSimpleConfig configFile = deCacheConfig(oid); if (configFile != null) { return configFile; } // Or evaluate afresh try { DigitalObject object = storage.getObject(oid); Payload payload = object.getPayload(object.getSourceId()); log.debug("First time parsing config file: '{}'", oid); configFile = new JsonSimpleConfig(payload.open()); payload.close(); cacheConfig(oid, configFile); return configFile; } catch (IOException ex) { log.error("Rules file could not be parsed! '{}'", oid, ex); return null; } catch (StorageException ex) { log.error("Rules file could not be retrieved! '{}'", oid, ex); return null; } }
java
private JsonSimpleConfig getConfigFile(String oid) { if (oid == null) { return null; } // Try the cache first JsonSimpleConfig configFile = deCacheConfig(oid); if (configFile != null) { return configFile; } // Or evaluate afresh try { DigitalObject object = storage.getObject(oid); Payload payload = object.getPayload(object.getSourceId()); log.debug("First time parsing config file: '{}'", oid); configFile = new JsonSimpleConfig(payload.open()); payload.close(); cacheConfig(oid, configFile); return configFile; } catch (IOException ex) { log.error("Rules file could not be parsed! '{}'", oid, ex); return null; } catch (StorageException ex) { log.error("Rules file could not be retrieved! '{}'", oid, ex); return null; } }
[ "private", "JsonSimpleConfig", "getConfigFile", "(", "String", "oid", ")", "{", "if", "(", "oid", "==", "null", ")", "{", "return", "null", ";", "}", "// Try the cache first", "JsonSimpleConfig", "configFile", "=", "deCacheConfig", "(", "oid", ")", ";", "if", "(", "configFile", "!=", "null", ")", "{", "return", "configFile", ";", "}", "// Or evaluate afresh", "try", "{", "DigitalObject", "object", "=", "storage", ".", "getObject", "(", "oid", ")", ";", "Payload", "payload", "=", "object", ".", "getPayload", "(", "object", ".", "getSourceId", "(", ")", ")", ";", "log", ".", "debug", "(", "\"First time parsing config file: '{}'\"", ",", "oid", ")", ";", "configFile", "=", "new", "JsonSimpleConfig", "(", "payload", ".", "open", "(", ")", ")", ";", "payload", ".", "close", "(", ")", ";", "cacheConfig", "(", "oid", ",", "configFile", ")", ";", "return", "configFile", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "error", "(", "\"Rules file could not be parsed! '{}'\"", ",", "oid", ",", "ex", ")", ";", "return", "null", ";", "}", "catch", "(", "StorageException", "ex", ")", "{", "log", ".", "error", "(", "\"Rules file could not be retrieved! '{}'\"", ",", "oid", ",", "ex", ")", ";", "return", "null", ";", "}", "}" ]
Retrieve and parse the config file stored under the provided object ID. If caching is configured the instantiated config object will be cached to speed up subsequent access. @param oid : The config OID to retrieve from storage or cache @return JsonSimple : The parsed or cached JSON object
[ "Retrieve", "and", "parse", "the", "config", "file", "stored", "under", "the", "provided", "object", "ID", ".", "If", "caching", "is", "configured", "the", "instantiated", "config", "object", "will", "be", "cached", "to", "speed", "up", "subsequent", "access", "." ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L1079-L1105
154,094
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.evalScript
private PyObject evalScript(InputStream inStream, String scriptName) { // Execute the script PythonInterpreter python = new PythonInterpreter(); python.execfile(inStream, scriptName); // Get the result and cleanup PyObject scriptClass = python.get(SCRIPT_CLASS_NAME); python.cleanup(); // Instantiate and return the result return scriptClass.__call__(); }
java
private PyObject evalScript(InputStream inStream, String scriptName) { // Execute the script PythonInterpreter python = new PythonInterpreter(); python.execfile(inStream, scriptName); // Get the result and cleanup PyObject scriptClass = python.get(SCRIPT_CLASS_NAME); python.cleanup(); // Instantiate and return the result return scriptClass.__call__(); }
[ "private", "PyObject", "evalScript", "(", "InputStream", "inStream", ",", "String", "scriptName", ")", "{", "// Execute the script", "PythonInterpreter", "python", "=", "new", "PythonInterpreter", "(", ")", ";", "python", ".", "execfile", "(", "inStream", ",", "scriptName", ")", ";", "// Get the result and cleanup", "PyObject", "scriptClass", "=", "python", ".", "get", "(", "SCRIPT_CLASS_NAME", ")", ";", "python", ".", "cleanup", "(", ")", ";", "// Instantiate and return the result", "return", "scriptClass", ".", "__call__", "(", ")", ";", "}" ]
Evaluate and return a Python script. @param inStream : InputStream containing the script to evaluate @param scriptName : filename of the script (mainly for debugging) @return PyObject : Compiled result
[ "Evaluate", "and", "return", "a", "Python", "script", "." ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L1116-L1125
154,095
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.cachePythonObject
private void cachePythonObject(String oid, PyObject pyObject) { if (useCache && pyObject != null) { scriptCache.put(oid, pyObject); } }
java
private void cachePythonObject(String oid, PyObject pyObject) { if (useCache && pyObject != null) { scriptCache.put(oid, pyObject); } }
[ "private", "void", "cachePythonObject", "(", "String", "oid", ",", "PyObject", "pyObject", ")", "{", "if", "(", "useCache", "&&", "pyObject", "!=", "null", ")", "{", "scriptCache", ".", "put", "(", "oid", ",", "pyObject", ")", ";", "}", "}" ]
Add a python object to the cache if caching if configured @param oid : The rules OID to use as an index @param pyObject : The compiled PyObject to cache
[ "Add", "a", "python", "object", "to", "the", "cache", "if", "caching", "if", "configured" ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L1135-L1139
154,096
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.deCachePythonObject
private PyObject deCachePythonObject(String oid) { if (useCache && scriptCache.containsKey(oid)) { return scriptCache.get(oid); } return null; }
java
private PyObject deCachePythonObject(String oid) { if (useCache && scriptCache.containsKey(oid)) { return scriptCache.get(oid); } return null; }
[ "private", "PyObject", "deCachePythonObject", "(", "String", "oid", ")", "{", "if", "(", "useCache", "&&", "scriptCache", ".", "containsKey", "(", "oid", ")", ")", "{", "return", "scriptCache", ".", "get", "(", "oid", ")", ";", "}", "return", "null", ";", "}" ]
Return a python object from the cache if configured @param oid : The rules OID to retrieve if cached @return PyObject : The cached object, null if not found
[ "Return", "a", "python", "object", "from", "the", "cache", "if", "configured" ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L1148-L1153
154,097
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.cacheConfig
private void cacheConfig(String oid, JsonSimpleConfig config) { if (useCache && config != null) { configCache.put(oid, config); } }
java
private void cacheConfig(String oid, JsonSimpleConfig config) { if (useCache && config != null) { configCache.put(oid, config); } }
[ "private", "void", "cacheConfig", "(", "String", "oid", ",", "JsonSimpleConfig", "config", ")", "{", "if", "(", "useCache", "&&", "config", "!=", "null", ")", "{", "configCache", ".", "put", "(", "oid", ",", "config", ")", ";", "}", "}" ]
Add a config class to the cache if caching if configured @param oid : The config OID to use as an index @param config : The instantiated JsonConfigHelper to cache
[ "Add", "a", "config", "class", "to", "the", "cache", "if", "caching", "if", "configured" ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L1163-L1167
154,098
the-fascinator/plugin-indexer-solr
src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java
SolrIndexer.deCacheConfig
private JsonSimpleConfig deCacheConfig(String oid) { if (useCache && configCache.containsKey(oid)) { return configCache.get(oid); } return null; }
java
private JsonSimpleConfig deCacheConfig(String oid) { if (useCache && configCache.containsKey(oid)) { return configCache.get(oid); } return null; }
[ "private", "JsonSimpleConfig", "deCacheConfig", "(", "String", "oid", ")", "{", "if", "(", "useCache", "&&", "configCache", ".", "containsKey", "(", "oid", ")", ")", "{", "return", "configCache", ".", "get", "(", "oid", ")", ";", "}", "return", "null", ";", "}" ]
Return a config class from the cache if configured @param oid : The config OID to retrieve if cached @return JsonConfigHelper : The cached config, null if not found
[ "Return", "a", "config", "class", "from", "the", "cache", "if", "configured" ]
001159b18b78a87daa5d8b2a17ced28694bae156
https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L1176-L1181
154,099
watchrabbit/rabbit-commons
src/main/java/com/watchrabbit/commons/clock/Stopwatch.java
Stopwatch.create
public static Stopwatch create(VoidCallable callable) { Stopwatch stopwatch = new Stopwatch(); stopwatch.callable = callable; return stopwatch; }
java
public static Stopwatch create(VoidCallable callable) { Stopwatch stopwatch = new Stopwatch(); stopwatch.callable = callable; return stopwatch; }
[ "public", "static", "Stopwatch", "create", "(", "VoidCallable", "callable", ")", "{", "Stopwatch", "stopwatch", "=", "new", "Stopwatch", "(", ")", ";", "stopwatch", ".", "callable", "=", "callable", ";", "return", "stopwatch", ";", "}" ]
Creates Stopwatch around passed callable. @param callable with invocation time would be measured @return
[ "Creates", "Stopwatch", "around", "passed", "callable", "." ]
b11c9f804b5ab70b9264635c34a02f5029bd2a5d
https://github.com/watchrabbit/rabbit-commons/blob/b11c9f804b5ab70b9264635c34a02f5029bd2a5d/src/main/java/com/watchrabbit/commons/clock/Stopwatch.java#L42-L46