repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
samskivert/samskivert
src/main/java/com/samskivert/jdbc/jora/Table.java
Table.select
public final Cursor<T> select (Connection conn, String condition) { String query = "select " + listOfFields + " from " + name + " " + condition; return new Cursor<T>(this, conn, query); }
java
public final Cursor<T> select (Connection conn, String condition) { String query = "select " + listOfFields + " from " + name + " " + condition; return new Cursor<T>(this, conn, query); }
[ "public", "final", "Cursor", "<", "T", ">", "select", "(", "Connection", "conn", ",", "String", "condition", ")", "{", "String", "query", "=", "\"select \"", "+", "listOfFields", "+", "\" from \"", "+", "name", "+", "\" \"", "+", "condition", ";", "return"...
Select records from database table according to search condition @param condition valid SQL condition expression started with WHERE or empty string if all records should be fetched.
[ "Select", "records", "from", "database", "table", "according", "to", "search", "condition" ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/jora/Table.java#L99-L104
train
samskivert/samskivert
src/main/java/com/samskivert/jdbc/jora/Table.java
Table.insert
public synchronized void insert (Connection conn, T obj) throws SQLException { StringBuilder sql = new StringBuilder( "insert into " + name + " (" + listOfFields + ") values (?"); for (int i = 1; i < nColumns; i++) { sql.append(",?"); } sql.append(")"); PreparedStatement insertStmt = conn.prepareStatement(sql.toString()); bindUpdateVariables(insertStmt, obj, null); insertStmt.executeUpdate(); insertStmt.close(); }
java
public synchronized void insert (Connection conn, T obj) throws SQLException { StringBuilder sql = new StringBuilder( "insert into " + name + " (" + listOfFields + ") values (?"); for (int i = 1; i < nColumns; i++) { sql.append(",?"); } sql.append(")"); PreparedStatement insertStmt = conn.prepareStatement(sql.toString()); bindUpdateVariables(insertStmt, obj, null); insertStmt.executeUpdate(); insertStmt.close(); }
[ "public", "synchronized", "void", "insert", "(", "Connection", "conn", ",", "T", "obj", ")", "throws", "SQLException", "{", "StringBuilder", "sql", "=", "new", "StringBuilder", "(", "\"insert into \"", "+", "name", "+", "\" (\"", "+", "listOfFields", "+", "\")...
Insert new record in the table. Values of inserted record fields are taken from specified object. @param obj object specifying values of inserted record fields
[ "Insert", "new", "record", "in", "the", "table", ".", "Values", "of", "inserted", "record", "fields", "are", "taken", "from", "specified", "object", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/jora/Table.java#L206-L219
train
samskivert/samskivert
src/main/java/com/samskivert/jdbc/jora/Table.java
Table.insert
public synchronized void insert (Connection conn, T[] objects) throws SQLException { StringBuilder sql = new StringBuilder( "insert into " + name + " (" + listOfFields + ") values (?"); for (int i = 1; i < nColumns; i++) { sql.append(",?"); } sql.append(")"); PreparedStatement insertStmt = conn.prepareStatement(sql.toString()); for (int i = 0; i < objects.length; i++) { bindUpdateVariables(insertStmt, objects[i], null); insertStmt.addBatch(); } insertStmt.executeBatch(); insertStmt.close(); }
java
public synchronized void insert (Connection conn, T[] objects) throws SQLException { StringBuilder sql = new StringBuilder( "insert into " + name + " (" + listOfFields + ") values (?"); for (int i = 1; i < nColumns; i++) { sql.append(",?"); } sql.append(")"); PreparedStatement insertStmt = conn.prepareStatement(sql.toString()); for (int i = 0; i < objects.length; i++) { bindUpdateVariables(insertStmt, objects[i], null); insertStmt.addBatch(); } insertStmt.executeBatch(); insertStmt.close(); }
[ "public", "synchronized", "void", "insert", "(", "Connection", "conn", ",", "T", "[", "]", "objects", ")", "throws", "SQLException", "{", "StringBuilder", "sql", "=", "new", "StringBuilder", "(", "\"insert into \"", "+", "name", "+", "\" (\"", "+", "listOfFiel...
Insert several new records in the table. Values of inserted records fields are taken from objects of specified array. @param objects array with objects specifying values of inserted record fields
[ "Insert", "several", "new", "records", "in", "the", "table", ".", "Values", "of", "inserted", "records", "fields", "are", "taken", "from", "objects", "of", "specified", "array", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/jora/Table.java#L228-L244
train
samskivert/samskivert
src/main/java/com/samskivert/jdbc/jora/Table.java
Table.delete
public synchronized int delete (Connection conn, T obj) throws SQLException { if (primaryKeys == null) { throw new IllegalStateException( "No primary key for table " + name + "."); } int nDeleted = 0; StringBuilder sql = new StringBuilder( "delete from " + name + " where " + primaryKeys[0] + " = ?"); for (int i = 1; i < primaryKeys.length; i++) { sql.append(" and ").append(primaryKeys[i]).append(" = ?"); } PreparedStatement deleteStmt = conn.prepareStatement(sql.toString()); for (int i = 0; i < primaryKeys.length; i++) { fields[primaryKeyIndices[i]].bindVariable(deleteStmt, obj,i+1); } nDeleted = deleteStmt.executeUpdate(); deleteStmt.close(); return nDeleted; }
java
public synchronized int delete (Connection conn, T obj) throws SQLException { if (primaryKeys == null) { throw new IllegalStateException( "No primary key for table " + name + "."); } int nDeleted = 0; StringBuilder sql = new StringBuilder( "delete from " + name + " where " + primaryKeys[0] + " = ?"); for (int i = 1; i < primaryKeys.length; i++) { sql.append(" and ").append(primaryKeys[i]).append(" = ?"); } PreparedStatement deleteStmt = conn.prepareStatement(sql.toString()); for (int i = 0; i < primaryKeys.length; i++) { fields[primaryKeyIndices[i]].bindVariable(deleteStmt, obj,i+1); } nDeleted = deleteStmt.executeUpdate(); deleteStmt.close(); return nDeleted; }
[ "public", "synchronized", "int", "delete", "(", "Connection", "conn", ",", "T", "obj", ")", "throws", "SQLException", "{", "if", "(", "primaryKeys", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"No primary key for table \"", "+", "name...
Delete record with specified value of primary key from the table. @param obj object containing value of primary key.
[ "Delete", "record", "with", "specified", "value", "of", "primary", "key", "from", "the", "table", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/jora/Table.java#L346-L366
train
samskivert/samskivert
src/main/java/com/samskivert/jdbc/jora/Table.java
Table.delete
public synchronized int delete (Connection conn, T[] objects) throws SQLException { if (primaryKeys == null) { throw new IllegalStateException( "No primary key for table " + name + "."); } int nDeleted = 0; StringBuilder sql = new StringBuilder( "delete from " + name + " where " + primaryKeys[0] + " = ?"); for (int i = 1; i < primaryKeys.length; i++) { sql.append(" and ").append(primaryKeys[i]).append(" = ?"); } PreparedStatement deleteStmt = conn.prepareStatement(sql.toString()); for (int i = 0; i < objects.length; i++) { for (int j = 0; j < primaryKeys.length; j++) { fields[primaryKeyIndices[j]].bindVariable( deleteStmt, objects[i], j+1); } deleteStmt.addBatch(); } int rc[] = deleteStmt.executeBatch(); for (int k = 0; k < rc.length; k++) { nDeleted += rc[k]; } deleteStmt.close(); return nDeleted; }
java
public synchronized int delete (Connection conn, T[] objects) throws SQLException { if (primaryKeys == null) { throw new IllegalStateException( "No primary key for table " + name + "."); } int nDeleted = 0; StringBuilder sql = new StringBuilder( "delete from " + name + " where " + primaryKeys[0] + " = ?"); for (int i = 1; i < primaryKeys.length; i++) { sql.append(" and ").append(primaryKeys[i]).append(" = ?"); } PreparedStatement deleteStmt = conn.prepareStatement(sql.toString()); for (int i = 0; i < objects.length; i++) { for (int j = 0; j < primaryKeys.length; j++) { fields[primaryKeyIndices[j]].bindVariable( deleteStmt, objects[i], j+1); } deleteStmt.addBatch(); } int rc[] = deleteStmt.executeBatch(); for (int k = 0; k < rc.length; k++) { nDeleted += rc[k]; } deleteStmt.close(); return nDeleted; }
[ "public", "synchronized", "int", "delete", "(", "Connection", "conn", ",", "T", "[", "]", "objects", ")", "throws", "SQLException", "{", "if", "(", "primaryKeys", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"No primary key for table \...
Delete records with specified primary keys from the table. @param objects array of objects containing values of primary key. @return number of objects actually deleted
[ "Delete", "records", "with", "specified", "primary", "keys", "from", "the", "table", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/jora/Table.java#L375-L402
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/QueryUtil.java
QueryUtil.restrictQueryExecution
public static boolean restrictQueryExecution(String sql) { String[] restrictions = { "delete", "truncate", "update", "drop", "alter" }; if (sql != null) { sql = sql.toLowerCase(); for (String restriction : restrictions) { if (sql.startsWith(restriction)) { return true; } String regex = "\\s+" + restriction + "\\s+"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(sql); if (matcher.find()) { return true; } } } return false; }
java
public static boolean restrictQueryExecution(String sql) { String[] restrictions = { "delete", "truncate", "update", "drop", "alter" }; if (sql != null) { sql = sql.toLowerCase(); for (String restriction : restrictions) { if (sql.startsWith(restriction)) { return true; } String regex = "\\s+" + restriction + "\\s+"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(sql); if (matcher.find()) { return true; } } } return false; }
[ "public", "static", "boolean", "restrictQueryExecution", "(", "String", "sql", ")", "{", "String", "[", "]", "restrictions", "=", "{", "\"delete\"", ",", "\"truncate\"", ",", "\"update\"", ",", "\"drop\"", ",", "\"alter\"", "}", ";", "if", "(", "sql", "!=", ...
Restrict a query execution. Do not allow for database modifications. @param sql sql to execute @return true if query is restricted
[ "Restrict", "a", "query", "execution", ".", "Do", "not", "allow", "for", "database", "modifications", "." ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/QueryUtil.java#L343-L360
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/QueryUtil.java
QueryUtil.isValidProcedureCall
public static boolean isValidProcedureCall(String sql, Dialect dialect) { if (sql == null) { return false; } if (dialect instanceof OracleDialect) { return sql.split("\\?").length == 2; } else { return true; } }
java
public static boolean isValidProcedureCall(String sql, Dialect dialect) { if (sql == null) { return false; } if (dialect instanceof OracleDialect) { return sql.split("\\?").length == 2; } else { return true; } }
[ "public", "static", "boolean", "isValidProcedureCall", "(", "String", "sql", ",", "Dialect", "dialect", ")", "{", "if", "(", "sql", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "dialect", "instanceof", "OracleDialect", ")", "{", "return"...
See if the sql contains only one '?' character @param sql sql to execute @param dialect dialect @return true if the sql contains only one '?' character, false otherwise
[ "See", "if", "the", "sql", "contains", "only", "one", "?", "character" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/QueryUtil.java#L385-L394
train
brutusin/json
src/main/java/org/brutusin/json/spi/Expression.java
Expression.compile
public static Expression compile(String exp) { if (Miscellaneous.isEmpty(exp) || exp.equals(".")) { exp = "$"; } Queue<String> queue = new LinkedList<String>(); List<String> tokens = parseTokens(exp); boolean isInBracket = false; int numInBracket = 0; StringBuilder sb = new StringBuilder(); for (int i = 0; i < tokens.size(); i++) { String token = tokens.get(i); if (token.equals("[")) { if (isInBracket) { throw new IllegalArgumentException("Error parsing expression '" + exp + "': Nested [ found"); } isInBracket = true; numInBracket = 0; sb.append(token); } else if (token.equals("]")) { if (!isInBracket) { throw new IllegalArgumentException("Error parsing expression '" + exp + "': Unbalanced ] found"); } isInBracket = false; sb.append(token); queue.add(sb.toString()); sb = new StringBuilder(); } else { if (isInBracket) { if (numInBracket > 0) { throw new IllegalArgumentException("Error parsing expression '" + exp + "': Multiple tokens found inside a bracket"); } sb.append(token); numInBracket++; } else { queue.add(token); } } if (i == tokens.size() - 1) { if (isInBracket) { throw new IllegalArgumentException("Error parsing expression '" + exp + "': Unbalanced [ found"); } } } return new Expression(queue, exp); }
java
public static Expression compile(String exp) { if (Miscellaneous.isEmpty(exp) || exp.equals(".")) { exp = "$"; } Queue<String> queue = new LinkedList<String>(); List<String> tokens = parseTokens(exp); boolean isInBracket = false; int numInBracket = 0; StringBuilder sb = new StringBuilder(); for (int i = 0; i < tokens.size(); i++) { String token = tokens.get(i); if (token.equals("[")) { if (isInBracket) { throw new IllegalArgumentException("Error parsing expression '" + exp + "': Nested [ found"); } isInBracket = true; numInBracket = 0; sb.append(token); } else if (token.equals("]")) { if (!isInBracket) { throw new IllegalArgumentException("Error parsing expression '" + exp + "': Unbalanced ] found"); } isInBracket = false; sb.append(token); queue.add(sb.toString()); sb = new StringBuilder(); } else { if (isInBracket) { if (numInBracket > 0) { throw new IllegalArgumentException("Error parsing expression '" + exp + "': Multiple tokens found inside a bracket"); } sb.append(token); numInBracket++; } else { queue.add(token); } } if (i == tokens.size() - 1) { if (isInBracket) { throw new IllegalArgumentException("Error parsing expression '" + exp + "': Unbalanced [ found"); } } } return new Expression(queue, exp); }
[ "public", "static", "Expression", "compile", "(", "String", "exp", ")", "{", "if", "(", "Miscellaneous", ".", "isEmpty", "(", "exp", ")", "||", "exp", ".", "equals", "(", "\".\"", ")", ")", "{", "exp", "=", "\"$\"", ";", "}", "Queue", "<", "String", ...
Compiles the expression. @param exp @return
[ "Compiles", "the", "expression", "." ]
2827a871aea2b56302ecb79a765d75eacb53dfca
https://github.com/brutusin/json/blob/2827a871aea2b56302ecb79a765d75eacb53dfca/src/main/java/org/brutusin/json/spi/Expression.java#L71-L115
train
samskivert/samskivert
src/main/java/com/samskivert/swing/dnd/DnDManager.java
DnDManager.addDragSource
public static void addDragSource ( DragSource source, JComponent comp, boolean autoremove) { singleton.addSource(source, comp, autoremove); }
java
public static void addDragSource ( DragSource source, JComponent comp, boolean autoremove) { singleton.addSource(source, comp, autoremove); }
[ "public", "static", "void", "addDragSource", "(", "DragSource", "source", ",", "JComponent", "comp", ",", "boolean", "autoremove", ")", "{", "singleton", ".", "addSource", "(", "source", ",", "comp", ",", "autoremove", ")", ";", "}" ]
Add the specified component as a source of drags, with the DragSource controller. @param autoremove if true, the source will automatically be removed from the DnD system when it is removed from the component hierarchy.
[ "Add", "the", "specified", "component", "as", "a", "source", "of", "drags", "with", "the", "DragSource", "controller", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/dnd/DnDManager.java#L58-L62
train
samskivert/samskivert
src/main/java/com/samskivert/swing/dnd/DnDManager.java
DnDManager.addDropTarget
public static void addDropTarget ( DropTarget target, JComponent comp, boolean autoremove) { singleton.addTarget(target, comp, autoremove); }
java
public static void addDropTarget ( DropTarget target, JComponent comp, boolean autoremove) { singleton.addTarget(target, comp, autoremove); }
[ "public", "static", "void", "addDropTarget", "(", "DropTarget", "target", ",", "JComponent", "comp", ",", "boolean", "autoremove", ")", "{", "singleton", ".", "addTarget", "(", "target", ",", "comp", ",", "autoremove", ")", ";", "}" ]
Add the specified component as a drop target. @param autoremove if true, the source will automatically be removed from the DnD system when it is removed from the component hierarchy.
[ "Add", "the", "specified", "component", "as", "a", "drop", "target", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/dnd/DnDManager.java#L79-L83
train
samskivert/samskivert
src/main/java/com/samskivert/swing/dnd/DnDManager.java
DnDManager.addSource
protected void addSource ( DragSource source, JComponent comp, boolean autoremove) { _draggers.put(comp, source); comp.addMouseListener(_sourceListener); comp.addMouseMotionListener(_sourceListener); if (autoremove) { comp.addAncestorListener(_remover); } }
java
protected void addSource ( DragSource source, JComponent comp, boolean autoremove) { _draggers.put(comp, source); comp.addMouseListener(_sourceListener); comp.addMouseMotionListener(_sourceListener); if (autoremove) { comp.addAncestorListener(_remover); } }
[ "protected", "void", "addSource", "(", "DragSource", "source", ",", "JComponent", "comp", ",", "boolean", "autoremove", ")", "{", "_draggers", ".", "put", "(", "comp", ",", "source", ")", ";", "comp", ".", "addMouseListener", "(", "_sourceListener", ")", ";"...
Add a dragsource.
[ "Add", "a", "dragsource", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/dnd/DnDManager.java#L111-L120
train
samskivert/samskivert
src/main/java/com/samskivert/swing/dnd/DnDManager.java
DnDManager.removeSource
protected void removeSource (JComponent comp) { if (_sourceComp == comp) { // reset cursors clearComponentCursor(); _topComp.setCursor(_topCursor); reset(); } _draggers.remove(comp); comp.removeMouseListener(_sourceListener); comp.removeMouseMotionListener(_sourceListener); }
java
protected void removeSource (JComponent comp) { if (_sourceComp == comp) { // reset cursors clearComponentCursor(); _topComp.setCursor(_topCursor); reset(); } _draggers.remove(comp); comp.removeMouseListener(_sourceListener); comp.removeMouseMotionListener(_sourceListener); }
[ "protected", "void", "removeSource", "(", "JComponent", "comp", ")", "{", "if", "(", "_sourceComp", "==", "comp", ")", "{", "// reset cursors", "clearComponentCursor", "(", ")", ";", "_topComp", ".", "setCursor", "(", "_topCursor", ")", ";", "reset", "(", ")...
Remove a dragsource.
[ "Remove", "a", "dragsource", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/dnd/DnDManager.java#L125-L136
train
samskivert/samskivert
src/main/java/com/samskivert/swing/dnd/DnDManager.java
DnDManager.addTarget
protected void addTarget ( DropTarget target, JComponent comp, boolean autoremove) { _droppers.put(comp, target); addTargetListeners(comp); if (autoremove) { comp.addAncestorListener(_remover); } }
java
protected void addTarget ( DropTarget target, JComponent comp, boolean autoremove) { _droppers.put(comp, target); addTargetListeners(comp); if (autoremove) { comp.addAncestorListener(_remover); } }
[ "protected", "void", "addTarget", "(", "DropTarget", "target", ",", "JComponent", "comp", ",", "boolean", "autoremove", ")", "{", "_droppers", ".", "put", "(", "comp", ",", "target", ")", ";", "addTargetListeners", "(", "comp", ")", ";", "if", "(", "autore...
Add a droptarget.
[ "Add", "a", "droptarget", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/dnd/DnDManager.java#L141-L149
train
samskivert/samskivert
src/main/java/com/samskivert/swing/dnd/DnDManager.java
DnDManager.addTargetListeners
protected void addTargetListeners (Component comp) { comp.addMouseListener(_targetListener); comp.addMouseMotionListener(_targetListener); if (comp instanceof Container) { // hm, always true for JComp.. Container cont = (Container) comp; cont.addContainerListener(_childListener); for (int ii=0, nn=cont.getComponentCount(); ii < nn; ii++) { addTargetListeners(cont.getComponent(ii)); } } }
java
protected void addTargetListeners (Component comp) { comp.addMouseListener(_targetListener); comp.addMouseMotionListener(_targetListener); if (comp instanceof Container) { // hm, always true for JComp.. Container cont = (Container) comp; cont.addContainerListener(_childListener); for (int ii=0, nn=cont.getComponentCount(); ii < nn; ii++) { addTargetListeners(cont.getComponent(ii)); } } }
[ "protected", "void", "addTargetListeners", "(", "Component", "comp", ")", "{", "comp", ".", "addMouseListener", "(", "_targetListener", ")", ";", "comp", ".", "addMouseMotionListener", "(", "_targetListener", ")", ";", "if", "(", "comp", "instanceof", "Container",...
Add the appropriate target listeners to this component and all its children.
[ "Add", "the", "appropriate", "target", "listeners", "to", "this", "component", "and", "all", "its", "children", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/dnd/DnDManager.java#L164-L175
train
samskivert/samskivert
src/main/java/com/samskivert/swing/dnd/DnDManager.java
DnDManager.removeTargetListeners
protected void removeTargetListeners (Component comp) { comp.removeMouseListener(_targetListener); comp.removeMouseMotionListener(_targetListener); if (comp instanceof Container) { // again, always true for JComp... Container cont = (Container) comp; cont.removeContainerListener(_childListener); for (int ii=0, nn=cont.getComponentCount(); ii < nn; ii++) { removeTargetListeners(cont.getComponent(ii)); } } }
java
protected void removeTargetListeners (Component comp) { comp.removeMouseListener(_targetListener); comp.removeMouseMotionListener(_targetListener); if (comp instanceof Container) { // again, always true for JComp... Container cont = (Container) comp; cont.removeContainerListener(_childListener); for (int ii=0, nn=cont.getComponentCount(); ii < nn; ii++) { removeTargetListeners(cont.getComponent(ii)); } } }
[ "protected", "void", "removeTargetListeners", "(", "Component", "comp", ")", "{", "comp", ".", "removeMouseListener", "(", "_targetListener", ")", ";", "comp", ".", "removeMouseMotionListener", "(", "_targetListener", ")", ";", "if", "(", "comp", "instanceof", "Co...
Remove the appropriate target listeners to this component and all its children.
[ "Remove", "the", "appropriate", "target", "listeners", "to", "this", "component", "and", "all", "its", "children", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/dnd/DnDManager.java#L181-L192
train
samskivert/samskivert
src/main/java/com/samskivert/swing/dnd/DnDManager.java
DnDManager.setComponentCursor
protected void setComponentCursor (Component comp) { Cursor c = comp.getCursor(); if (c != _curCursor) { assertComponentCursorCleared(); _lastComp = comp; _oldCursor = comp.isCursorSet() ? c : null; comp.setCursor(_curCursor); } }
java
protected void setComponentCursor (Component comp) { Cursor c = comp.getCursor(); if (c != _curCursor) { assertComponentCursorCleared(); _lastComp = comp; _oldCursor = comp.isCursorSet() ? c : null; comp.setCursor(_curCursor); } }
[ "protected", "void", "setComponentCursor", "(", "Component", "comp", ")", "{", "Cursor", "c", "=", "comp", ".", "getCursor", "(", ")", ";", "if", "(", "c", "!=", "_curCursor", ")", "{", "assertComponentCursorCleared", "(", ")", ";", "_lastComp", "=", "comp...
Check to see if we need to do component-level cursor setting and take care of it if needed.
[ "Check", "to", "see", "if", "we", "need", "to", "do", "component", "-", "level", "cursor", "setting", "and", "take", "care", "of", "it", "if", "needed", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/dnd/DnDManager.java#L198-L207
train
samskivert/samskivert
src/main/java/com/samskivert/swing/dnd/DnDManager.java
DnDManager.findAppropriateTarget
protected DropTarget findAppropriateTarget (Component comp) { DropTarget target; while (comp != null) { // here we sneakily prevent dropping on the source target = (comp == _sourceComp) ? null : _droppers.get(comp); if ((target != null) && comp.isEnabled() && _source.checkDrop(target) && target.checkDrop(_source, _data[0])) { return target; } comp = comp.getParent(); } return null; }
java
protected DropTarget findAppropriateTarget (Component comp) { DropTarget target; while (comp != null) { // here we sneakily prevent dropping on the source target = (comp == _sourceComp) ? null : _droppers.get(comp); if ((target != null) && comp.isEnabled() && _source.checkDrop(target) && target.checkDrop(_source, _data[0])) { return target; } comp = comp.getParent(); } return null; }
[ "protected", "DropTarget", "findAppropriateTarget", "(", "Component", "comp", ")", "{", "DropTarget", "target", ";", "while", "(", "comp", "!=", "null", ")", "{", "// here we sneakily prevent dropping on the source", "target", "=", "(", "comp", "==", "_sourceComp", ...
Find the lowest accepting parental target to this component.
[ "Find", "the", "lowest", "accepting", "parental", "target", "to", "this", "component", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/dnd/DnDManager.java#L260-L274
train
samskivert/samskivert
src/main/java/com/samskivert/swing/dnd/DnDManager.java
DnDManager.checkAutoscroll
protected void checkAutoscroll (MouseEvent exitEvent) { Component comp = exitEvent.getComponent(); Point p = exitEvent.getPoint(); try { Point scr = comp.getLocationOnScreen(); p.translate(scr.x, scr.y); } catch (IllegalComponentStateException icse) { // the component is no longer on screen. Deal. return; } Component parent; DropTarget target; while (true) { target = _droppers.get(comp); if (target instanceof AutoscrollingDropTarget) { AutoscrollingDropTarget adt = (AutoscrollingDropTarget) target; JComponent jc = (JComponent) comp; Rectangle r = getRectOnScreen(jc); // make sure we're actually out of the autoscrolling component if (!r.contains(p)) { // start autoscrolling. _scrollComp = jc; _scrollDim = adt.getAutoscrollBorders(); _scrollPoint = p; _scrollTimer.start(); return; } } parent = comp.getParent(); if (parent == null) { return; } comp = parent; } }
java
protected void checkAutoscroll (MouseEvent exitEvent) { Component comp = exitEvent.getComponent(); Point p = exitEvent.getPoint(); try { Point scr = comp.getLocationOnScreen(); p.translate(scr.x, scr.y); } catch (IllegalComponentStateException icse) { // the component is no longer on screen. Deal. return; } Component parent; DropTarget target; while (true) { target = _droppers.get(comp); if (target instanceof AutoscrollingDropTarget) { AutoscrollingDropTarget adt = (AutoscrollingDropTarget) target; JComponent jc = (JComponent) comp; Rectangle r = getRectOnScreen(jc); // make sure we're actually out of the autoscrolling component if (!r.contains(p)) { // start autoscrolling. _scrollComp = jc; _scrollDim = adt.getAutoscrollBorders(); _scrollPoint = p; _scrollTimer.start(); return; } } parent = comp.getParent(); if (parent == null) { return; } comp = parent; } }
[ "protected", "void", "checkAutoscroll", "(", "MouseEvent", "exitEvent", ")", "{", "Component", "comp", "=", "exitEvent", ".", "getComponent", "(", ")", ";", "Point", "p", "=", "exitEvent", ".", "getPoint", "(", ")", ";", "try", "{", "Point", "scr", "=", ...
Check to see if we want to enter autoscrolling mode.
[ "Check", "to", "see", "if", "we", "want", "to", "enter", "autoscrolling", "mode", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/dnd/DnDManager.java#L279-L317
train
samskivert/samskivert
src/main/java/com/samskivert/swing/dnd/DnDManager.java
DnDManager.getRectOnScreen
protected Rectangle getRectOnScreen (JComponent comp) { Rectangle r = comp.getVisibleRect(); Point p = comp.getLocationOnScreen(); r.translate(p.x, p.y); return r; }
java
protected Rectangle getRectOnScreen (JComponent comp) { Rectangle r = comp.getVisibleRect(); Point p = comp.getLocationOnScreen(); r.translate(p.x, p.y); return r; }
[ "protected", "Rectangle", "getRectOnScreen", "(", "JComponent", "comp", ")", "{", "Rectangle", "r", "=", "comp", ".", "getVisibleRect", "(", ")", ";", "Point", "p", "=", "comp", ".", "getLocationOnScreen", "(", ")", ";", "r", ".", "translate", "(", "p", ...
Find the rectangular area that is visible in screen coordinates for the given component.
[ "Find", "the", "rectangular", "area", "that", "is", "visible", "in", "screen", "coordinates", "for", "the", "given", "component", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/dnd/DnDManager.java#L323-L329
train
samskivert/samskivert
src/main/java/com/samskivert/swing/dnd/DnDManager.java
DnDManager.reset
protected void reset () { _scrollTimer.stop(); _source = null; _sourceComp = null; _lastComp = null; _lastTarget = null; _data[0] = null; _cursors[0] = null; _cursors[1] = null; _topComp = null; _topCursor = null; _curCursor = null; _scrollComp = null; _scrollDim = null; _scrollPoint = null; }
java
protected void reset () { _scrollTimer.stop(); _source = null; _sourceComp = null; _lastComp = null; _lastTarget = null; _data[0] = null; _cursors[0] = null; _cursors[1] = null; _topComp = null; _topCursor = null; _curCursor = null; _scrollComp = null; _scrollDim = null; _scrollPoint = null; }
[ "protected", "void", "reset", "(", ")", "{", "_scrollTimer", ".", "stop", "(", ")", ";", "_source", "=", "null", ";", "_sourceComp", "=", "null", ";", "_lastComp", "=", "null", ";", "_lastTarget", "=", "null", ";", "_data", "[", "0", "]", "=", "null"...
Reset dnd to a starting state.
[ "Reset", "dnd", "to", "a", "starting", "state", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/dnd/DnDManager.java#L334-L352
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.loadConvertedReport
public static Report loadConvertedReport(InputStream is) { XStream xstream = XStreamFactory.createXStream(); InputStreamReader reader = null; try { reader = new InputStreamReader(is, "UTF-8"); return (Report) xstream.fromXML(reader); } catch (Exception e) { LOG.error(e.getMessage(), e); e.printStackTrace(); return null; } }
java
public static Report loadConvertedReport(InputStream is) { XStream xstream = XStreamFactory.createXStream(); InputStreamReader reader = null; try { reader = new InputStreamReader(is, "UTF-8"); return (Report) xstream.fromXML(reader); } catch (Exception e) { LOG.error(e.getMessage(), e); e.printStackTrace(); return null; } }
[ "public", "static", "Report", "loadConvertedReport", "(", "InputStream", "is", ")", "{", "XStream", "xstream", "=", "XStreamFactory", ".", "createXStream", "(", ")", ";", "InputStreamReader", "reader", "=", "null", ";", "try", "{", "reader", "=", "new", "Input...
Create a report object from an input stream Use this method if you know your report version does not need any conversion from older versions, otherwise see {@link #loadReport(InputStream)} @param is input stream @return the report object created from the input stream or null if cannot be read
[ "Create", "a", "report", "object", "from", "an", "input", "stream" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L109-L120
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.loadConvertedReport
public static Report loadConvertedReport(String xml) { XStream xstream = XStreamFactory.createXStream(); try { return (Report) xstream.fromXML(xml); } catch (Exception e) { LOG.error(e.getMessage(), e); e.printStackTrace(); return null; } }
java
public static Report loadConvertedReport(String xml) { XStream xstream = XStreamFactory.createXStream(); try { return (Report) xstream.fromXML(xml); } catch (Exception e) { LOG.error(e.getMessage(), e); e.printStackTrace(); return null; } }
[ "public", "static", "Report", "loadConvertedReport", "(", "String", "xml", ")", "{", "XStream", "xstream", "=", "XStreamFactory", ".", "createXStream", "(", ")", ";", "try", "{", "return", "(", "Report", ")", "xstream", ".", "fromXML", "(", "xml", ")", ";"...
Create a report object from xml Use this method if you know your report version does not need any conversion from older versions, otherwise see {@link #loadReport(String)} @param xml xml text @return the report object created from xml or null if cannot be read
[ "Create", "a", "report", "object", "from", "xml" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L132-L141
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.loadReport
public static Report loadReport(String xml) throws LoadReportException { try { String convertedXml = ConverterChain.applyFromXml(xml); XStream xstream = XStreamFactory.createXStream(); return (Report) xstream.fromXML(convertedXml); } catch (ConverterException ex) { LOG.error(ex.getMessage(), ex); throw new LoadReportException(ex.getMessage(), ex); } }
java
public static Report loadReport(String xml) throws LoadReportException { try { String convertedXml = ConverterChain.applyFromXml(xml); XStream xstream = XStreamFactory.createXStream(); return (Report) xstream.fromXML(convertedXml); } catch (ConverterException ex) { LOG.error(ex.getMessage(), ex); throw new LoadReportException(ex.getMessage(), ex); } }
[ "public", "static", "Report", "loadReport", "(", "String", "xml", ")", "throws", "LoadReportException", "{", "try", "{", "String", "convertedXml", "=", "ConverterChain", ".", "applyFromXml", "(", "xml", ")", ";", "XStream", "xstream", "=", "XStreamFactory", ".",...
Create a report object from xml Do a conversion if it is needed @since 5.2 @param xml xml text @return the report object created from xml or null if cannot be read @throws LoadReportException if report object cannot be created
[ "Create", "a", "report", "object", "from", "xml", "Do", "a", "conversion", "if", "it", "is", "needed" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L154-L163
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.loadReport
public static Report loadReport(InputStream is) throws LoadReportException { try { String xml = readAsString(is); String convertedXml = ConverterChain.applyFromXml(xml); XStream xstream = XStreamFactory.createXStream(); return (Report) xstream.fromXML(convertedXml); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); throw new LoadReportException(ex.getMessage(), ex); } }
java
public static Report loadReport(InputStream is) throws LoadReportException { try { String xml = readAsString(is); String convertedXml = ConverterChain.applyFromXml(xml); XStream xstream = XStreamFactory.createXStream(); return (Report) xstream.fromXML(convertedXml); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); throw new LoadReportException(ex.getMessage(), ex); } }
[ "public", "static", "Report", "loadReport", "(", "InputStream", "is", ")", "throws", "LoadReportException", "{", "try", "{", "String", "xml", "=", "readAsString", "(", "is", ")", ";", "String", "convertedXml", "=", "ConverterChain", ".", "applyFromXml", "(", "...
Create a report object from an input stream Do a conversion if it is needed @since 5.2 @param is input stream @return the report object created from the input stream or null if cannot be read @throws LoadReportException if report object cannot be created
[ "Create", "a", "report", "object", "from", "an", "input", "stream", "Do", "a", "conversion", "if", "it", "is", "needed" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L178-L188
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.saveReport
public static void saveReport(Report report, OutputStream out) { XStream xstream = XStreamFactory.createXStream(); xstream.toXML(report, out); }
java
public static void saveReport(Report report, OutputStream out) { XStream xstream = XStreamFactory.createXStream(); xstream.toXML(report, out); }
[ "public", "static", "void", "saveReport", "(", "Report", "report", ",", "OutputStream", "out", ")", "{", "XStream", "xstream", "=", "XStreamFactory", ".", "createXStream", "(", ")", ";", "xstream", ".", "toXML", "(", "report", ",", "out", ")", ";", "}" ]
Write a report object to an output stream @param report report object @param out output stream
[ "Write", "a", "report", "object", "to", "an", "output", "stream" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L198-L201
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.saveReport
public static void saveReport(Report report, String path) { FileOutputStream fos = null; try { fos = new FileOutputStream(path); saveReport(report, fos); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); ex.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } } }
java
public static void saveReport(Report report, String path) { FileOutputStream fos = null; try { fos = new FileOutputStream(path); saveReport(report, fos); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); ex.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } } }
[ "public", "static", "void", "saveReport", "(", "Report", "report", ",", "String", "path", ")", "{", "FileOutputStream", "fos", "=", "null", ";", "try", "{", "fos", "=", "new", "FileOutputStream", "(", "path", ")", ";", "saveReport", "(", "report", ",", "...
Write a report object to a file at specified path @param report report object @param path file path
[ "Write", "a", "report", "object", "to", "a", "file", "at", "specified", "path" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L211-L228
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.saveReport
public static void saveReport(String xml, String path) { FileOutputStream fos = null; try { fos = new FileOutputStream(path); fos.write(xml.getBytes("UTF-8")); fos.flush(); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); ex.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } } }
java
public static void saveReport(String xml, String path) { FileOutputStream fos = null; try { fos = new FileOutputStream(path); fos.write(xml.getBytes("UTF-8")); fos.flush(); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); ex.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } } }
[ "public", "static", "void", "saveReport", "(", "String", "xml", ",", "String", "path", ")", "{", "FileOutputStream", "fos", "=", "null", ";", "try", "{", "fos", "=", "new", "FileOutputStream", "(", "path", ")", ";", "fos", ".", "write", "(", "xml", "."...
Write a xml text to a file at specified path @param xml xml text @param path file path
[ "Write", "a", "xml", "text", "to", "a", "file", "at", "specified", "path" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L238-L256
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.reportToXml
public static String reportToXml(Report report) { XStream xstream = XStreamFactory.createXStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); xstream.toXML(report, bos); return bos.toString(); }
java
public static String reportToXml(Report report) { XStream xstream = XStreamFactory.createXStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); xstream.toXML(report, bos); return bos.toString(); }
[ "public", "static", "String", "reportToXml", "(", "Report", "report", ")", "{", "XStream", "xstream", "=", "XStreamFactory", ".", "createXStream", "(", ")", ";", "ByteArrayOutputStream", "bos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "xstream", ".", ...
Convert a report object to xml text @param report report object @return xml text
[ "Convert", "a", "report", "object", "to", "xml", "text" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L265-L270
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.isValid
public static byte isValid(String reportVersion) { if (isOlderUnsupportedVersion(reportVersion)) { return REPORT_INVALID_OLDER; } else if (isNewerUnsupportedVersion(reportVersion)) { return REPORT_INVALID_NEWER; } else { return REPORT_VALID; } }
java
public static byte isValid(String reportVersion) { if (isOlderUnsupportedVersion(reportVersion)) { return REPORT_INVALID_OLDER; } else if (isNewerUnsupportedVersion(reportVersion)) { return REPORT_INVALID_NEWER; } else { return REPORT_VALID; } }
[ "public", "static", "byte", "isValid", "(", "String", "reportVersion", ")", "{", "if", "(", "isOlderUnsupportedVersion", "(", "reportVersion", ")", ")", "{", "return", "REPORT_INVALID_OLDER", ";", "}", "else", "if", "(", "isNewerUnsupportedVersion", "(", "reportVe...
Test if string version given as parameter is valid, meaning is over 2.0 and no greater than current engine version @param reportVersion version @return one of REPORT_VALID, REPORT_INVALID_OLDER, REPORT_INVALID_NEWER
[ "Test", "if", "string", "version", "given", "as", "parameter", "is", "valid", "meaning", "is", "over", "2", ".", "0", "and", "no", "greater", "than", "current", "engine", "version" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L319-L327
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.isOlderUnsupportedVersion
public static boolean isOlderUnsupportedVersion(String version) { return ((version == null) || "".equals(version) || version.startsWith("0") || version.startsWith("1")); }
java
public static boolean isOlderUnsupportedVersion(String version) { return ((version == null) || "".equals(version) || version.startsWith("0") || version.startsWith("1")); }
[ "public", "static", "boolean", "isOlderUnsupportedVersion", "(", "String", "version", ")", "{", "return", "(", "(", "version", "==", "null", ")", "||", "\"\"", ".", "equals", "(", "version", ")", "||", "version", ".", "startsWith", "(", "\"0\"", ")", "||",...
Return true if version string is less than 2.0 @param version version string @return true if version string is less than 2.0
[ "Return", "true", "if", "version", "string", "is", "less", "than", "2", ".", "0" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L336-L338
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.isNewerUnsupportedVersion
public static boolean isNewerUnsupportedVersion(String version) { if ((version == null) || "".equals(version)) { return true; } String engineVersion = ReleaseInfoAdapter.getVersionNumber(); String[] ev = engineVersion.split("\\."); String[] rv = version.split("\\."); return ((Integer.parseInt(ev[0]) < Integer.parseInt(rv[0])) || ((Integer.parseInt(ev[0]) == Integer.parseInt(rv[0])) && (Integer .parseInt(ev[1]) < Integer.parseInt(rv[1])))); }
java
public static boolean isNewerUnsupportedVersion(String version) { if ((version == null) || "".equals(version)) { return true; } String engineVersion = ReleaseInfoAdapter.getVersionNumber(); String[] ev = engineVersion.split("\\."); String[] rv = version.split("\\."); return ((Integer.parseInt(ev[0]) < Integer.parseInt(rv[0])) || ((Integer.parseInt(ev[0]) == Integer.parseInt(rv[0])) && (Integer .parseInt(ev[1]) < Integer.parseInt(rv[1])))); }
[ "public", "static", "boolean", "isNewerUnsupportedVersion", "(", "String", "version", ")", "{", "if", "(", "(", "version", "==", "null", ")", "||", "\"\"", ".", "equals", "(", "version", ")", ")", "{", "return", "true", ";", "}", "String", "engineVersion",...
Return true if version string is newer than version of the report engine @param version version string @return true if version string is newer than version of the report engine
[ "Return", "true", "if", "version", "string", "is", "newer", "than", "version", "of", "the", "report", "engine" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L347-L356
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.compareVersions
public static int compareVersions(String v1, String v2) { String[] v1a = v1.split("\\."); String[] v2a = v2.split("\\."); Integer v1M = Integer.parseInt(v1a[0]); Integer v2M = Integer.parseInt(v2a[0]); if (v1M < v2M) { return -1; } else if (v1M > v2M) { return 1; } else { Integer v1min = Integer.parseInt(v1a[1]); Integer v2min = Integer.parseInt(v2a[1]); if (v1min < v2min) { return -1; } else if (v1min > v2min) { return 1; } else { return 0; } } }
java
public static int compareVersions(String v1, String v2) { String[] v1a = v1.split("\\."); String[] v2a = v2.split("\\."); Integer v1M = Integer.parseInt(v1a[0]); Integer v2M = Integer.parseInt(v2a[0]); if (v1M < v2M) { return -1; } else if (v1M > v2M) { return 1; } else { Integer v1min = Integer.parseInt(v1a[1]); Integer v2min = Integer.parseInt(v2a[1]); if (v1min < v2min) { return -1; } else if (v1min > v2min) { return 1; } else { return 0; } } }
[ "public", "static", "int", "compareVersions", "(", "String", "v1", ",", "String", "v2", ")", "{", "String", "[", "]", "v1a", "=", "v1", ".", "split", "(", "\"\\\\.\"", ")", ";", "String", "[", "]", "v2a", "=", "v2", ".", "split", "(", "\"\\\\.\"", ...
Compare two report versions strings @param v1 first version string @param v2 second version string @return -1 if v1 less than v2, 0 if v1 equals v2, 1 if v1 greater than v2
[ "Compare", "two", "report", "versions", "strings" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L367-L387
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.getVersion
public static String getVersion(String reportFile) { try { String text = readAsString(reportFile); return getVersionFromText(text); } catch (IOException e) { LOG.error(e.getMessage(), e); return null; } }
java
public static String getVersion(String reportFile) { try { String text = readAsString(reportFile); return getVersionFromText(text); } catch (IOException e) { LOG.error(e.getMessage(), e); return null; } }
[ "public", "static", "String", "getVersion", "(", "String", "reportFile", ")", "{", "try", "{", "String", "text", "=", "readAsString", "(", "reportFile", ")", ";", "return", "getVersionFromText", "(", "text", ")", ";", "}", "catch", "(", "IOException", "e", ...
Get report version from report file @param reportFile report file @return report version
[ "Get", "report", "version", "from", "report", "file" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L396-L404
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.getVersion
public static String getVersion(InputStream is) { try { String text = readAsString(is); return getVersionFromText(text); } catch (IOException e) { LOG.error(e.getMessage(), e); return null; } }
java
public static String getVersion(InputStream is) { try { String text = readAsString(is); return getVersionFromText(text); } catch (IOException e) { LOG.error(e.getMessage(), e); return null; } }
[ "public", "static", "String", "getVersion", "(", "InputStream", "is", ")", "{", "try", "{", "String", "text", "=", "readAsString", "(", "is", ")", ";", "return", "getVersionFromText", "(", "text", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{"...
Get report version from input stream to read report file @param is input stream @return report version
[ "Get", "report", "version", "from", "input", "stream", "to", "read", "report", "file" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L413-L421
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.readAsString
public static String readAsString(String reportPath) throws IOException { StringBuffer fileData = new StringBuffer(1000); BufferedReader reader = new BufferedReader(new FileReader(reportPath)); char[] buf = new char[1024]; int numRead = 0; while ((numRead = reader.read(buf)) != -1) { fileData.append(buf, 0, numRead); } reader.close(); return fileData.toString(); }
java
public static String readAsString(String reportPath) throws IOException { StringBuffer fileData = new StringBuffer(1000); BufferedReader reader = new BufferedReader(new FileReader(reportPath)); char[] buf = new char[1024]; int numRead = 0; while ((numRead = reader.read(buf)) != -1) { fileData.append(buf, 0, numRead); } reader.close(); return fileData.toString(); }
[ "public", "static", "String", "readAsString", "(", "String", "reportPath", ")", "throws", "IOException", "{", "StringBuffer", "fileData", "=", "new", "StringBuffer", "(", "1000", ")", ";", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "Fi...
Read a report file as string @param reportPath file path @return string file content @throws IOException if file cannot be read
[ "Read", "a", "report", "file", "as", "string" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L466-L476
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.readAsString
public static String readAsString(InputStream is) throws IOException { try { // Scanner iterates over tokens in the stream, and in this case // we separate tokens using "beginning of the input boundary" (\A) // thus giving us only one token for the entire contents of the // stream return new Scanner(is, "UTF-8").useDelimiter("\\A").next(); } catch (java.util.NoSuchElementException e) { return ""; } }
java
public static String readAsString(InputStream is) throws IOException { try { // Scanner iterates over tokens in the stream, and in this case // we separate tokens using "beginning of the input boundary" (\A) // thus giving us only one token for the entire contents of the // stream return new Scanner(is, "UTF-8").useDelimiter("\\A").next(); } catch (java.util.NoSuchElementException e) { return ""; } }
[ "public", "static", "String", "readAsString", "(", "InputStream", "is", ")", "throws", "IOException", "{", "try", "{", "// Scanner iterates over tokens in the stream, and in this case", "// we separate tokens using \"beginning of the input boundary\" (\\A)", "// thus giving us only one...
Read data from input stream @param is input stream @return string content read from input stream @throws IOException if cannot read from input stream
[ "Read", "data", "from", "input", "stream" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L487-L497
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.getFileName
public static String getFileName(String filePath) { if (filePath == null) { return filePath; } int index = filePath.lastIndexOf(File.separator); if (index == -1) { return filePath; } return filePath.substring(index + 1); }
java
public static String getFileName(String filePath) { if (filePath == null) { return filePath; } int index = filePath.lastIndexOf(File.separator); if (index == -1) { return filePath; } return filePath.substring(index + 1); }
[ "public", "static", "String", "getFileName", "(", "String", "filePath", ")", "{", "if", "(", "filePath", "==", "null", ")", "{", "return", "filePath", ";", "}", "int", "index", "=", "filePath", ".", "lastIndexOf", "(", "File", ".", "separator", ")", ";",...
Get file name from a file path @param filePath file path @return file name
[ "Get", "file", "name", "from", "a", "file", "path" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L506-L515
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.getStaticImages
public static List<String> getStaticImages(Report report) { List<String> images = new ArrayList<String>(); ReportLayout layout = report.getLayout(); List<Band> bands = layout.getBands(); for (Band band : bands) { for (int i = 0, rows = band.getRowCount(); i < rows; i++) { List<BandElement> list = band.getRow(i); for (BandElement be : list) { if ((be instanceof ImageBandElement) && !(be instanceof ChartBandElement) && !(be instanceof BarcodeBandElement)) { images.add(((ImageBandElement) be).getImage()); } } } } if (layout.getBackgroundImage() != null) { images.add(layout.getBackgroundImage()); } return images; }
java
public static List<String> getStaticImages(Report report) { List<String> images = new ArrayList<String>(); ReportLayout layout = report.getLayout(); List<Band> bands = layout.getBands(); for (Band band : bands) { for (int i = 0, rows = band.getRowCount(); i < rows; i++) { List<BandElement> list = band.getRow(i); for (BandElement be : list) { if ((be instanceof ImageBandElement) && !(be instanceof ChartBandElement) && !(be instanceof BarcodeBandElement)) { images.add(((ImageBandElement) be).getImage()); } } } } if (layout.getBackgroundImage() != null) { images.add(layout.getBackgroundImage()); } return images; }
[ "public", "static", "List", "<", "String", ">", "getStaticImages", "(", "Report", "report", ")", "{", "List", "<", "String", ">", "images", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "ReportLayout", "layout", "=", "report", ".", "getLayo...
Get static images used by report @param report report @return a list of static images used by report
[ "Get", "static", "images", "used", "by", "report" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L524-L543
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.getSql
public static String getSql(Report report) { String sql; if (report.getSql() != null) { sql = report.getSql(); } else { sql = report.getQuery().toString(); } return sql; }
java
public static String getSql(Report report) { String sql; if (report.getSql() != null) { sql = report.getSql(); } else { sql = report.getQuery().toString(); } return sql; }
[ "public", "static", "String", "getSql", "(", "Report", "report", ")", "{", "String", "sql", ";", "if", "(", "report", ".", "getSql", "(", ")", "!=", "null", ")", "{", "sql", "=", "report", ".", "getSql", "(", ")", ";", "}", "else", "{", "sql", "=...
Get sql string from report object @param report report @return sql string from report object
[ "Get", "sql", "string", "from", "report", "object" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L552-L560
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.getExpressions
public static List<ExpressionBean> getExpressions(ReportLayout layout) { List<ExpressionBean> expressions = new LinkedList<ExpressionBean>(); for (Band band : layout.getBands()) { for (int i = 0, rows = band.getRowCount(); i < rows; i++) { List<BandElement> list = band.getRow(i); for (BandElement be : list) { if (be instanceof ExpressionBandElement) { if (!expressions.contains((ExpressionBandElement) be)) { expressions.add(new ExpressionBean((ExpressionBandElement) be, band.getName())); } } } } } return expressions; }
java
public static List<ExpressionBean> getExpressions(ReportLayout layout) { List<ExpressionBean> expressions = new LinkedList<ExpressionBean>(); for (Band band : layout.getBands()) { for (int i = 0, rows = band.getRowCount(); i < rows; i++) { List<BandElement> list = band.getRow(i); for (BandElement be : list) { if (be instanceof ExpressionBandElement) { if (!expressions.contains((ExpressionBandElement) be)) { expressions.add(new ExpressionBean((ExpressionBandElement) be, band.getName())); } } } } } return expressions; }
[ "public", "static", "List", "<", "ExpressionBean", ">", "getExpressions", "(", "ReportLayout", "layout", ")", "{", "List", "<", "ExpressionBean", ">", "expressions", "=", "new", "LinkedList", "<", "ExpressionBean", ">", "(", ")", ";", "for", "(", "Band", "ba...
Get expression elements from report layout @param layout report layout @return list of expression elements from report layout
[ "Get", "expression", "elements", "from", "report", "layout" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L647-L662
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.getExpressionsNames
public static List<String> getExpressionsNames(ReportLayout layout) { List<String> expressions = new LinkedList<String>(); for (Band band : layout.getBands()) { for (int i = 0, rows = band.getRowCount(); i < rows; i++) { List<BandElement> list = band.getRow(i); for (BandElement be : list) { if (be instanceof ExpressionBandElement) { String expName = ((ExpressionBandElement) be).getExpressionName(); if (!expressions.contains(expName)) { expressions.add(expName); } } } } } return expressions; }
java
public static List<String> getExpressionsNames(ReportLayout layout) { List<String> expressions = new LinkedList<String>(); for (Band band : layout.getBands()) { for (int i = 0, rows = band.getRowCount(); i < rows; i++) { List<BandElement> list = band.getRow(i); for (BandElement be : list) { if (be instanceof ExpressionBandElement) { String expName = ((ExpressionBandElement) be).getExpressionName(); if (!expressions.contains(expName)) { expressions.add(expName); } } } } } return expressions; }
[ "public", "static", "List", "<", "String", ">", "getExpressionsNames", "(", "ReportLayout", "layout", ")", "{", "List", "<", "String", ">", "expressions", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "for", "(", "Band", "band", ":", "layo...
Get expression names from report layout @param layout report layout @return list of expression names from report layout
[ "Get", "expression", "names", "from", "report", "layout" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L700-L716
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.isValidSqlWithMessage
public static String isValidSqlWithMessage(Connection con, String sql, List<QueryParameter> parameters) { try { QueryUtil qu = new QueryUtil(con, DialectUtil.getDialect(con)); Map<String, QueryParameter> params = new HashMap<String, QueryParameter>(); for (QueryParameter qp : parameters) { params.put(qp.getName(), qp); } qu.getColumnNames(sql, params); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); return ex.getMessage(); } return null; }
java
public static String isValidSqlWithMessage(Connection con, String sql, List<QueryParameter> parameters) { try { QueryUtil qu = new QueryUtil(con, DialectUtil.getDialect(con)); Map<String, QueryParameter> params = new HashMap<String, QueryParameter>(); for (QueryParameter qp : parameters) { params.put(qp.getName(), qp); } qu.getColumnNames(sql, params); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); return ex.getMessage(); } return null; }
[ "public", "static", "String", "isValidSqlWithMessage", "(", "Connection", "con", ",", "String", "sql", ",", "List", "<", "QueryParameter", ">", "parameters", ")", "{", "try", "{", "QueryUtil", "qu", "=", "new", "QueryUtil", "(", "con", ",", "DialectUtil", "....
Test if sql with parameters is valid @param con database connection @param sql sql @return return message error if sql is not valid, null otherwise
[ "Test", "if", "sql", "with", "parameters", "is", "valid" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L761-L774
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.getSubreports
public static List<Report> getSubreports(Report report) { List<Report> subreports = new ArrayList<Report>(); List<Band> bands = report.getLayout().getDocumentBands(); for (Band band : bands) { for (int i = 0, rows = band.getRowCount(); i < rows; i++) { List<BandElement> list = band.getRow(i); for (int j = 0, size = list.size(); j < size; j++) { BandElement be = list.get(j); if (be instanceof ReportBandElement) { subreports.add(((ReportBandElement)be).getReport()); } } } } return subreports; }
java
public static List<Report> getSubreports(Report report) { List<Report> subreports = new ArrayList<Report>(); List<Band> bands = report.getLayout().getDocumentBands(); for (Band band : bands) { for (int i = 0, rows = band.getRowCount(); i < rows; i++) { List<BandElement> list = band.getRow(i); for (int j = 0, size = list.size(); j < size; j++) { BandElement be = list.get(j); if (be instanceof ReportBandElement) { subreports.add(((ReportBandElement)be).getReport()); } } } } return subreports; }
[ "public", "static", "List", "<", "Report", ">", "getSubreports", "(", "Report", "report", ")", "{", "List", "<", "Report", ">", "subreports", "=", "new", "ArrayList", "<", "Report", ">", "(", ")", ";", "List", "<", "Band", ">", "bands", "=", "report", ...
Get subreports for a report @param report current report @return list of subreports
[ "Get", "subreports", "for", "a", "report" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L781-L797
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.getDetailSubreports
public static List<Report> getDetailSubreports(ReportLayout reportLayout) { List<Report> subreports = new ArrayList<Report>(); Band band = reportLayout.getDetailBand(); for (int i = 0, rows = band.getRowCount(); i < rows; i++) { List<BandElement> list = band.getRow(i); for (int j = 0, size = list.size(); j < size; j++) { BandElement be = list.get(j); if (be instanceof ReportBandElement) { subreports.add(((ReportBandElement) be).getReport()); } } } return subreports; }
java
public static List<Report> getDetailSubreports(ReportLayout reportLayout) { List<Report> subreports = new ArrayList<Report>(); Band band = reportLayout.getDetailBand(); for (int i = 0, rows = band.getRowCount(); i < rows; i++) { List<BandElement> list = band.getRow(i); for (int j = 0, size = list.size(); j < size; j++) { BandElement be = list.get(j); if (be instanceof ReportBandElement) { subreports.add(((ReportBandElement) be).getReport()); } } } return subreports; }
[ "public", "static", "List", "<", "Report", ">", "getDetailSubreports", "(", "ReportLayout", "reportLayout", ")", "{", "List", "<", "Report", ">", "subreports", "=", "new", "ArrayList", "<", "Report", ">", "(", ")", ";", "Band", "band", "=", "reportLayout", ...
Get detail band subreports for a report layout @param reportLayout current report layout @return list of subreports from detail band
[ "Get", "detail", "band", "subreports", "for", "a", "report", "layout" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L804-L818
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.getDetailCharts
public static List<Chart> getDetailCharts(ReportLayout reportLayout) { List<Chart> charts = new ArrayList<Chart>(); Band band = reportLayout.getDetailBand(); for (int i = 0, rows = band.getRowCount(); i < rows; i++) { List<BandElement> list = band.getRow(i); for (int j = 0, size = list.size(); j < size; j++) { BandElement be = list.get(j); if (be instanceof ChartBandElement) { charts.add(((ChartBandElement) be).getChart()); } } } return charts; }
java
public static List<Chart> getDetailCharts(ReportLayout reportLayout) { List<Chart> charts = new ArrayList<Chart>(); Band band = reportLayout.getDetailBand(); for (int i = 0, rows = band.getRowCount(); i < rows; i++) { List<BandElement> list = band.getRow(i); for (int j = 0, size = list.size(); j < size; j++) { BandElement be = list.get(j); if (be instanceof ChartBandElement) { charts.add(((ChartBandElement) be).getChart()); } } } return charts; }
[ "public", "static", "List", "<", "Chart", ">", "getDetailCharts", "(", "ReportLayout", "reportLayout", ")", "{", "List", "<", "Chart", ">", "charts", "=", "new", "ArrayList", "<", "Chart", ">", "(", ")", ";", "Band", "band", "=", "reportLayout", ".", "ge...
Get detail band charts for a report layout @param reportLayout current report layout @return list of charts from detail band
[ "Get", "detail", "band", "charts", "for", "a", "report", "layout" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L825-L839
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.getForReportLayout
private static ReportLayout getForReportLayout(Connection con, ReportLayout layout, ParametersBean pBean) throws Exception { ReportLayout convertedLayout = ObjectCloner.silenceDeepCopy(layout); List<Band> bands = convertedLayout.getDocumentBands(); for (Band band : bands) { for (int i = 0, rows = band.getRowCount(); i < rows; i++) { List<BandElement> list = band.getRow(i); for (int j = 0, size = list.size(); j < size; j++) { BandElement be = list.get(j); if (be instanceof ForReportBandElement) { String sql = ((ForReportBandElement) be).getSql(); Report report = ((ForReportBandElement) be).getReport(); if ((sql == null) || sql.isEmpty()) { return convertedLayout; } else { QueryUtil qu = new QueryUtil(con, DialectUtil.getDialect(con)); // column name is the same with parameter name String columnName = qu.getColumnNames(sql, pBean.getParams()).get(0); List<IdName> values = qu.getValues(sql, pBean.getParams(), pBean.getParamValues()); int pos = j; for (int k = 0; k < values.size(); k++) { IdName in = values.get(k); if (k > 0) { band.insertColumn(pos); } Report newReport = ObjectCloner.silenceDeepCopy(report); ReportLayout subReportLayout = ReportUtil.getReportLayoutForHeaderFunctions(newReport.getLayout()); newReport.setLayout(subReportLayout); newReport.setName(report.getBaseName() + "_" + (k + 1) + ".report"); newReport.getGeneratedParamValues().put(columnName, in.getId()); band.setElementAt(new ReportBandElement(newReport), i, pos); pos++; } List<Integer> oldColumnsWidth = layout.getColumnsWidth(); List<Integer> newColumnWidth = new ArrayList<Integer>(); for (int m = 0; m < j; m++) { newColumnWidth.add(oldColumnsWidth.get(m)); } for (int m = 0; m < values.size(); m++) { newColumnWidth.add(oldColumnsWidth.get(j)); } for (int m = j + 1; m < size; m++) { newColumnWidth.add(oldColumnsWidth.get(m)); } convertedLayout.setColumnsWidth(newColumnWidth); // we look just for first appearance return convertedLayout; } } } } } return convertedLayout; }
java
private static ReportLayout getForReportLayout(Connection con, ReportLayout layout, ParametersBean pBean) throws Exception { ReportLayout convertedLayout = ObjectCloner.silenceDeepCopy(layout); List<Band> bands = convertedLayout.getDocumentBands(); for (Band band : bands) { for (int i = 0, rows = band.getRowCount(); i < rows; i++) { List<BandElement> list = band.getRow(i); for (int j = 0, size = list.size(); j < size; j++) { BandElement be = list.get(j); if (be instanceof ForReportBandElement) { String sql = ((ForReportBandElement) be).getSql(); Report report = ((ForReportBandElement) be).getReport(); if ((sql == null) || sql.isEmpty()) { return convertedLayout; } else { QueryUtil qu = new QueryUtil(con, DialectUtil.getDialect(con)); // column name is the same with parameter name String columnName = qu.getColumnNames(sql, pBean.getParams()).get(0); List<IdName> values = qu.getValues(sql, pBean.getParams(), pBean.getParamValues()); int pos = j; for (int k = 0; k < values.size(); k++) { IdName in = values.get(k); if (k > 0) { band.insertColumn(pos); } Report newReport = ObjectCloner.silenceDeepCopy(report); ReportLayout subReportLayout = ReportUtil.getReportLayoutForHeaderFunctions(newReport.getLayout()); newReport.setLayout(subReportLayout); newReport.setName(report.getBaseName() + "_" + (k + 1) + ".report"); newReport.getGeneratedParamValues().put(columnName, in.getId()); band.setElementAt(new ReportBandElement(newReport), i, pos); pos++; } List<Integer> oldColumnsWidth = layout.getColumnsWidth(); List<Integer> newColumnWidth = new ArrayList<Integer>(); for (int m = 0; m < j; m++) { newColumnWidth.add(oldColumnsWidth.get(m)); } for (int m = 0; m < values.size(); m++) { newColumnWidth.add(oldColumnsWidth.get(j)); } for (int m = j + 1; m < size; m++) { newColumnWidth.add(oldColumnsWidth.get(m)); } convertedLayout.setColumnsWidth(newColumnWidth); // we look just for first appearance return convertedLayout; } } } } } return convertedLayout; }
[ "private", "static", "ReportLayout", "getForReportLayout", "(", "Connection", "con", ",", "ReportLayout", "layout", ",", "ParametersBean", "pBean", ")", "throws", "Exception", "{", "ReportLayout", "convertedLayout", "=", "ObjectCloner", ".", "silenceDeepCopy", "(", "l...
If a report layout contains a ForReportBandElement we must replace this element with more ReportBandElements This means inserting n-1 new columns, where n is the number of values return by sql inside ForReportBandElement A ForReportBandElement is interpreted only at first appearance Column name from sql inside ForReportBandElement must be the same with a parameter name from subreport. Every value from sql will be considered the value for that parameter from subreport. @param con connection @param layout report layout @param pBean parameters bean @return a new report layout with ReportBandElement elements instead a ForReportBandElement @throws Exception if query fails
[ "If", "a", "report", "layout", "contains", "a", "ForReportBandElement", "we", "must", "replace", "this", "element", "with", "more", "ReportBandElements", "This", "means", "inserting", "n", "-", "1", "new", "columns", "where", "n", "is", "the", "number", "of", ...
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L885-L939
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.foundFunctionInGroupHeader
public static boolean foundFunctionInGroupHeader(ReportLayout layout, String groupName) { List<Band> groupHeaderBands = layout.getGroupHeaderBands(); for (Band band : groupHeaderBands) { if (band.getName().equals(ReportLayout.GROUP_HEADER_BAND_NAME_PREFIX + groupName)) { return foundFunctionInBand(band); } } return false; }
java
public static boolean foundFunctionInGroupHeader(ReportLayout layout, String groupName) { List<Band> groupHeaderBands = layout.getGroupHeaderBands(); for (Band band : groupHeaderBands) { if (band.getName().equals(ReportLayout.GROUP_HEADER_BAND_NAME_PREFIX + groupName)) { return foundFunctionInBand(band); } } return false; }
[ "public", "static", "boolean", "foundFunctionInGroupHeader", "(", "ReportLayout", "layout", ",", "String", "groupName", ")", "{", "List", "<", "Band", ">", "groupHeaderBands", "=", "layout", ".", "getGroupHeaderBands", "(", ")", ";", "for", "(", "Band", "band", ...
Test to see if a function is found in group header band @param layout report layout @param groupName group name @return true if a function is found in group header band, false otherwise
[ "Test", "to", "see", "if", "a", "function", "is", "found", "in", "group", "header", "band" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L1006-L1014
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/ReportUtil.java
ReportUtil.foundFunctionInAnyGroupHeader
public static boolean foundFunctionInAnyGroupHeader(ReportLayout layout) { List<Band> groupHeaderBands = layout.getGroupHeaderBands(); for (Band band : groupHeaderBands) { boolean found = foundFunctionInBand(band); if (found) { return true; } } return false; }
java
public static boolean foundFunctionInAnyGroupHeader(ReportLayout layout) { List<Band> groupHeaderBands = layout.getGroupHeaderBands(); for (Band band : groupHeaderBands) { boolean found = foundFunctionInBand(band); if (found) { return true; } } return false; }
[ "public", "static", "boolean", "foundFunctionInAnyGroupHeader", "(", "ReportLayout", "layout", ")", "{", "List", "<", "Band", ">", "groupHeaderBands", "=", "layout", ".", "getGroupHeaderBands", "(", ")", ";", "for", "(", "Band", "band", ":", "groupHeaderBands", ...
Test to see if a function is found in any group header band @param layout report layout @return true if a function is found in any group header band, false otherwise
[ "Test", "to", "see", "if", "a", "function", "is", "found", "in", "any", "group", "header", "band" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ReportUtil.java#L1022-L1031
train
samskivert/samskivert
src/main/java/com/samskivert/xml/SetPropertyFieldsRule.java
SetPropertyFieldsRule.addFieldParser
public void addFieldParser (String property, FieldParser parser) { if (_parsers == null) { _parsers = new HashMap<String,FieldParser>(); } _parsers.put(property, parser); }
java
public void addFieldParser (String property, FieldParser parser) { if (_parsers == null) { _parsers = new HashMap<String,FieldParser>(); } _parsers.put(property, parser); }
[ "public", "void", "addFieldParser", "(", "String", "property", ",", "FieldParser", "parser", ")", "{", "if", "(", "_parsers", "==", "null", ")", "{", "_parsers", "=", "new", "HashMap", "<", "String", ",", "FieldParser", ">", "(", ")", ";", "}", "_parsers...
Adds a custom parser for the specified named field.
[ "Adds", "a", "custom", "parser", "for", "the", "specified", "named", "field", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/xml/SetPropertyFieldsRule.java#L52-L58
train
samskivert/samskivert
src/main/java/com/samskivert/util/ClassUtil.java
ClassUtil.getFields
public static Field[] getFields (Class<?> clazz) { ArrayList<Field> list = new ArrayList<Field>(); getFields(clazz, list); return list.toArray(new Field[list.size()]); }
java
public static Field[] getFields (Class<?> clazz) { ArrayList<Field> list = new ArrayList<Field>(); getFields(clazz, list); return list.toArray(new Field[list.size()]); }
[ "public", "static", "Field", "[", "]", "getFields", "(", "Class", "<", "?", ">", "clazz", ")", "{", "ArrayList", "<", "Field", ">", "list", "=", "new", "ArrayList", "<", "Field", ">", "(", ")", ";", "getFields", "(", "clazz", ",", "list", ")", ";",...
Get the fields contained in the class and its superclasses.
[ "Get", "the", "fields", "contained", "in", "the", "class", "and", "its", "superclasses", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ClassUtil.java#L37-L42
train
samskivert/samskivert
src/main/java/com/samskivert/util/ClassUtil.java
ClassUtil.compatibleClasses
public static boolean compatibleClasses (Class<?>[] lhs, Class<?>[] rhs) { if (lhs.length != rhs.length) { return false; } for (int i = 0; i < lhs.length; ++i) { if (rhs[i] == null || rhs[i].equals(Void.TYPE)) { if (lhs[i].isPrimitive()) { return false; } else { continue; } } if (!lhs[i].isAssignableFrom(rhs[i])) { Class<?> lhsPrimEquiv = primitiveEquivalentOf(lhs[i]); Class<?> rhsPrimEquiv = primitiveEquivalentOf(rhs[i]); if (!primitiveIsAssignableFrom(lhsPrimEquiv, rhsPrimEquiv)) { return false; } } } return true; }
java
public static boolean compatibleClasses (Class<?>[] lhs, Class<?>[] rhs) { if (lhs.length != rhs.length) { return false; } for (int i = 0; i < lhs.length; ++i) { if (rhs[i] == null || rhs[i].equals(Void.TYPE)) { if (lhs[i].isPrimitive()) { return false; } else { continue; } } if (!lhs[i].isAssignableFrom(rhs[i])) { Class<?> lhsPrimEquiv = primitiveEquivalentOf(lhs[i]); Class<?> rhsPrimEquiv = primitiveEquivalentOf(rhs[i]); if (!primitiveIsAssignableFrom(lhsPrimEquiv, rhsPrimEquiv)) { return false; } } } return true; }
[ "public", "static", "boolean", "compatibleClasses", "(", "Class", "<", "?", ">", "[", "]", "lhs", ",", "Class", "<", "?", ">", "[", "]", "rhs", ")", "{", "if", "(", "lhs", ".", "length", "!=", "rhs", ".", "length", ")", "{", "return", "false", ";...
Tells whether instances of the classes in the 'rhs' array could be used as parameters to a reflective method invocation whose parameter list has types denoted by the 'lhs' array. @param lhs Class array representing the types of the formal parameters of a method. @param rhs Class array representing the types of the actual parameters of a method. A null value or Void.TYPE is considered to match a corresponding Object or array class in lhs, but not a primitive. @return true if compatible, false otherwise.
[ "Tells", "whether", "instances", "of", "the", "classes", "in", "the", "rhs", "array", "could", "be", "used", "as", "parameters", "to", "a", "reflective", "method", "invocation", "whose", "parameter", "list", "has", "types", "denoted", "by", "the", "lhs", "ar...
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ClassUtil.java#L113-L138
train
samskivert/samskivert
src/main/java/com/samskivert/util/ClassUtil.java
ClassUtil.getAccessibleMethodFrom
public static Method getAccessibleMethodFrom ( Class<?> clazz, String methodName, Class<?>[] parameterTypes) { // Look for overridden method in the superclass. Class<?> superclass = clazz.getSuperclass(); Method overriddenMethod = null; if (superclass != null && classIsAccessible(superclass)) { try { overriddenMethod = superclass.getMethod(methodName, parameterTypes); } catch (NoSuchMethodException nsme) { // no problem } if (overriddenMethod != null) { return overriddenMethod; } } // If here, then clazz represents Object, or an interface, or the superclass did not have // an override. Check implemented interfaces. Class<?>[] interfaces = clazz.getInterfaces(); for (int i = 0; i < interfaces.length; ++i) { if (classIsAccessible(interfaces[i])) { try { overriddenMethod = interfaces[i].getMethod(methodName, parameterTypes); } catch (NoSuchMethodException nsme) { // no problem } if (overriddenMethod != null) { return overriddenMethod; } } } // Try superclass's superclass and implemented interfaces. if (superclass != null) { overriddenMethod = getAccessibleMethodFrom(superclass, methodName, parameterTypes); if (overriddenMethod != null) { return overriddenMethod; } } // Try implemented interfaces' extended interfaces... for (int i = 0; i < interfaces.length; ++i) { overriddenMethod = getAccessibleMethodFrom(interfaces[i], methodName, parameterTypes); if (overriddenMethod != null) { return overriddenMethod; } } // Give up. return null; }
java
public static Method getAccessibleMethodFrom ( Class<?> clazz, String methodName, Class<?>[] parameterTypes) { // Look for overridden method in the superclass. Class<?> superclass = clazz.getSuperclass(); Method overriddenMethod = null; if (superclass != null && classIsAccessible(superclass)) { try { overriddenMethod = superclass.getMethod(methodName, parameterTypes); } catch (NoSuchMethodException nsme) { // no problem } if (overriddenMethod != null) { return overriddenMethod; } } // If here, then clazz represents Object, or an interface, or the superclass did not have // an override. Check implemented interfaces. Class<?>[] interfaces = clazz.getInterfaces(); for (int i = 0; i < interfaces.length; ++i) { if (classIsAccessible(interfaces[i])) { try { overriddenMethod = interfaces[i].getMethod(methodName, parameterTypes); } catch (NoSuchMethodException nsme) { // no problem } if (overriddenMethod != null) { return overriddenMethod; } } } // Try superclass's superclass and implemented interfaces. if (superclass != null) { overriddenMethod = getAccessibleMethodFrom(superclass, methodName, parameterTypes); if (overriddenMethod != null) { return overriddenMethod; } } // Try implemented interfaces' extended interfaces... for (int i = 0; i < interfaces.length; ++i) { overriddenMethod = getAccessibleMethodFrom(interfaces[i], methodName, parameterTypes); if (overriddenMethod != null) { return overriddenMethod; } } // Give up. return null; }
[ "public", "static", "Method", "getAccessibleMethodFrom", "(", "Class", "<", "?", ">", "clazz", ",", "String", "methodName", ",", "Class", "<", "?", ">", "[", "]", "parameterTypes", ")", "{", "// Look for overridden method in the superclass.", "Class", "<", "?", ...
Searches for the method with the given name and formal parameter types that is in the nearest accessible class in the class hierarchy, starting with clazz's superclass. The superclass and implemented interfaces of clazz are searched, then their superclasses, etc. until a method is found. Returns null if there is no such method. @param clazz a class. @param methodName name of a method. @param parameterTypes Class array representing the types of a method's formal parameters. @return the nearest method located, or null if there is no such method.
[ "Searches", "for", "the", "method", "with", "the", "given", "name", "and", "formal", "parameter", "types", "that", "is", "in", "the", "nearest", "accessible", "class", "in", "the", "class", "hierarchy", "starting", "with", "clazz", "s", "superclass", ".", "T...
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ClassUtil.java#L152-L205
train
samskivert/samskivert
src/main/java/com/samskivert/util/ClassUtil.java
ClassUtil.primitiveIsAssignableFrom
public static boolean primitiveIsAssignableFrom (Class<?> lhs, Class<?> rhs) { if (lhs == null || rhs == null) { return false; } if (!(lhs.isPrimitive() && rhs.isPrimitive())) { return false; } if (lhs.equals(rhs)) { return true; } Set<Class<?>> wideningSet = _primitiveWideningsMap.get(rhs); if (wideningSet == null) { return false; } return wideningSet.contains(lhs); }
java
public static boolean primitiveIsAssignableFrom (Class<?> lhs, Class<?> rhs) { if (lhs == null || rhs == null) { return false; } if (!(lhs.isPrimitive() && rhs.isPrimitive())) { return false; } if (lhs.equals(rhs)) { return true; } Set<Class<?>> wideningSet = _primitiveWideningsMap.get(rhs); if (wideningSet == null) { return false; } return wideningSet.contains(lhs); }
[ "public", "static", "boolean", "primitiveIsAssignableFrom", "(", "Class", "<", "?", ">", "lhs", ",", "Class", "<", "?", ">", "rhs", ")", "{", "if", "(", "lhs", "==", "null", "||", "rhs", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(...
Tells whether an instance of the primitive class represented by 'rhs' can be assigned to an instance of the primitive class represented by 'lhs'. @param lhs assignee class. @param rhs assigned class. @return true if compatible, false otherwise. If either argument is <code>null</code>, or one of the parameters does not represent a primitive (e.g. Byte.TYPE), returns false.
[ "Tells", "whether", "an", "instance", "of", "the", "primitive", "class", "represented", "by", "rhs", "can", "be", "assigned", "to", "an", "instance", "of", "the", "primitive", "class", "represented", "by", "lhs", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ClassUtil.java#L236-L252
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/chart/Star.java
Star.createStar
private void createStar() { Point2D.Float point = start; p = new GeneralPath(GeneralPath.WIND_NON_ZERO); p.moveTo(point.x, point.y); p.lineTo(point.x + 3.0f, point.y - 1.5f); // Line from start to A point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x + 1.5f, point.y - 3.0f); // Line from A to B point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x + 1.5f, point.y + 3.0f); // Line from B to C point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x + 3.0f, point.y + 1.5f); // Line from C to D point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x - 3.0f, point.y + 1.5f); // Line from D to E point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x - 1.5f, point.y + 3.0f); // Line from E to F point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x - 1.5f, point.y - 3.0f); // Line from F to g p.closePath(); // Line from G to start }
java
private void createStar() { Point2D.Float point = start; p = new GeneralPath(GeneralPath.WIND_NON_ZERO); p.moveTo(point.x, point.y); p.lineTo(point.x + 3.0f, point.y - 1.5f); // Line from start to A point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x + 1.5f, point.y - 3.0f); // Line from A to B point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x + 1.5f, point.y + 3.0f); // Line from B to C point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x + 3.0f, point.y + 1.5f); // Line from C to D point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x - 3.0f, point.y + 1.5f); // Line from D to E point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x - 1.5f, point.y + 3.0f); // Line from E to F point = (Point2D.Float) p.getCurrentPoint(); p.lineTo(point.x - 1.5f, point.y - 3.0f); // Line from F to g p.closePath(); // Line from G to start }
[ "private", "void", "createStar", "(", ")", "{", "Point2D", ".", "Float", "point", "=", "start", ";", "p", "=", "new", "GeneralPath", "(", "GeneralPath", ".", "WIND_NON_ZERO", ")", ";", "p", ".", "moveTo", "(", "point", ".", "x", ",", "point", ".", "y...
Create the path from start
[ "Create", "the", "path", "from", "start" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/chart/Star.java#L30-L48
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/chart/Star.java
Star.atLocation
Shape atLocation(float x, float y) { start.setLocation(x, y); // Store new start p.reset(); // Erase current path createStar(); // create new path return p; // Return the path }
java
Shape atLocation(float x, float y) { start.setLocation(x, y); // Store new start p.reset(); // Erase current path createStar(); // create new path return p; // Return the path }
[ "Shape", "atLocation", "(", "float", "x", ",", "float", "y", ")", "{", "start", ".", "setLocation", "(", "x", ",", "y", ")", ";", "// Store new start", "p", ".", "reset", "(", ")", ";", "// Erase current path", "createStar", "(", ")", ";", "// create new...
Modify the location of this star
[ "Modify", "the", "location", "of", "this", "star" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/chart/Star.java#L51-L56
train
samskivert/samskivert
src/main/java/com/samskivert/util/IntListUtil.java
IntListUtil.add
public static int[] add (int[] list, int startIdx, int value) { // make sure we've got a list to work with if (list == null) { list = new int[DEFAULT_LIST_SIZE]; } // search for a spot to insert yon value; assuming we'll insert // it at the end of the list if we don't find one int llength = list.length; int index = llength; for (int i = startIdx; i < llength; i++) { if (list[i] == 0) { index = i; break; } } // expand the list if necessary if (index >= list.length) { list = accomodate(list, index); } // stick the value on in list[index] = value; return list; }
java
public static int[] add (int[] list, int startIdx, int value) { // make sure we've got a list to work with if (list == null) { list = new int[DEFAULT_LIST_SIZE]; } // search for a spot to insert yon value; assuming we'll insert // it at the end of the list if we don't find one int llength = list.length; int index = llength; for (int i = startIdx; i < llength; i++) { if (list[i] == 0) { index = i; break; } } // expand the list if necessary if (index >= list.length) { list = accomodate(list, index); } // stick the value on in list[index] = value; return list; }
[ "public", "static", "int", "[", "]", "add", "(", "int", "[", "]", "list", ",", "int", "startIdx", ",", "int", "value", ")", "{", "// make sure we've got a list to work with", "if", "(", "list", "==", "null", ")", "{", "list", "=", "new", "int", "[", "D...
Adds the specified value to the next empty slot in the specified list. Begins searching for empty slots at the specified index. This can be used to quickly add values to a list that preserves consecutivity by calling it with the size of the list as the first index to check. @param list the list to which to add the value. Can be null. @param startIdx the index at which to start looking for a spot. @param value the value to add. @return a reference to the list with the value added (might not be the list you passed in due to expansion, or allocation).
[ "Adds", "the", "specified", "value", "to", "the", "next", "empty", "slot", "in", "the", "specified", "list", ".", "Begins", "searching", "for", "empty", "slots", "at", "the", "specified", "index", ".", "This", "can", "be", "used", "to", "quickly", "add", ...
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/IntListUtil.java#L79-L106
train
samskivert/samskivert
src/main/java/com/samskivert/util/IntListUtil.java
IntListUtil.remove
public static int remove (int[] list, int value) { // nothing to remove from an empty list if (list == null) { return 0; } int llength = list.length; // no optimizing bastards for (int i = 0; i < llength; i++) { int val = list[i]; if (val == value) { System.arraycopy(list, i+1, list, i, llength-(i+1)); list[llength-1] = 0; return val; } } return 0; }
java
public static int remove (int[] list, int value) { // nothing to remove from an empty list if (list == null) { return 0; } int llength = list.length; // no optimizing bastards for (int i = 0; i < llength; i++) { int val = list[i]; if (val == value) { System.arraycopy(list, i+1, list, i, llength-(i+1)); list[llength-1] = 0; return val; } } return 0; }
[ "public", "static", "int", "remove", "(", "int", "[", "]", "list", ",", "int", "value", ")", "{", "// nothing to remove from an empty list", "if", "(", "list", "==", "null", ")", "{", "return", "0", ";", "}", "int", "llength", "=", "list", ".", "length",...
Removes the first value that is equal to the supplied value. The values after the removed value will be slid down the array one spot to fill the place of the removed value. @return the value that was removed from the array or zero if no matching object was found.
[ "Removes", "the", "first", "value", "that", "is", "equal", "to", "the", "supplied", "value", ".", "The", "values", "after", "the", "removed", "value", "will", "be", "slid", "down", "the", "array", "one", "spot", "to", "fill", "the", "place", "of", "the",...
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/IntListUtil.java#L218-L235
train
samskivert/samskivert
src/main/java/com/samskivert/util/IntListUtil.java
IntListUtil.removeAt
public static int removeAt (int[] list, int index) { int llength = list.length; if (llength <= index) { return 0; } int val = list[index]; System.arraycopy(list, index+1, list, index, llength-(index+1)); list[llength-1] = 0; return val; }
java
public static int removeAt (int[] list, int index) { int llength = list.length; if (llength <= index) { return 0; } int val = list[index]; System.arraycopy(list, index+1, list, index, llength-(index+1)); list[llength-1] = 0; return val; }
[ "public", "static", "int", "removeAt", "(", "int", "[", "]", "list", ",", "int", "index", ")", "{", "int", "llength", "=", "list", ".", "length", ";", "if", "(", "llength", "<=", "index", ")", "{", "return", "0", ";", "}", "int", "val", "=", "lis...
Removes the value at the specified index. The values after the removed value will be slid down the array one spot to fill the place of the removed value. If a null array is supplied or one that is not large enough to accomodate this index, zero is returned. @return the value that was removed from the array or zero if no value existed at that location.
[ "Removes", "the", "value", "at", "the", "specified", "index", ".", "The", "values", "after", "the", "removed", "value", "will", "be", "slid", "down", "the", "array", "one", "spot", "to", "fill", "the", "place", "of", "the", "removed", "value", ".", "If",...
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/IntListUtil.java#L246-L257
train
samskivert/samskivert
src/main/java/com/samskivert/util/IntListUtil.java
IntListUtil.sum
public static int sum (int[] list) { int total = 0, lsize = list.length; for (int ii = 0; ii < lsize; ii++) { total += list[ii]; } return total; }
java
public static int sum (int[] list) { int total = 0, lsize = list.length; for (int ii = 0; ii < lsize; ii++) { total += list[ii]; } return total; }
[ "public", "static", "int", "sum", "(", "int", "[", "]", "list", ")", "{", "int", "total", "=", "0", ",", "lsize", "=", "list", ".", "length", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "lsize", ";", "ii", "++", ")", "{", "total",...
Returns the total of all of the values in the list.
[ "Returns", "the", "total", "of", "all", "of", "the", "values", "in", "the", "list", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/IntListUtil.java#L288-L295
train
samskivert/samskivert
src/main/java/com/samskivert/util/IntListUtil.java
IntListUtil.accomodate
protected static int[] accomodate (int[] list, int index) { int size = list.length; // expand size by powers of two until we're big enough while (size <= index) { size = Math.max(size * 2, DEFAULT_LIST_SIZE); } // create a new list and copy the contents int[] newlist = new int[size]; System.arraycopy(list, 0, newlist, 0, list.length); return newlist; }
java
protected static int[] accomodate (int[] list, int index) { int size = list.length; // expand size by powers of two until we're big enough while (size <= index) { size = Math.max(size * 2, DEFAULT_LIST_SIZE); } // create a new list and copy the contents int[] newlist = new int[size]; System.arraycopy(list, 0, newlist, 0, list.length); return newlist; }
[ "protected", "static", "int", "[", "]", "accomodate", "(", "int", "[", "]", "list", ",", "int", "index", ")", "{", "int", "size", "=", "list", ".", "length", ";", "// expand size by powers of two until we're big enough", "while", "(", "size", "<=", "index", ...
Creates a new list that will accomodate the specified index and copies the contents of the old list to the first.
[ "Creates", "a", "new", "list", "that", "will", "accomodate", "the", "specified", "index", "and", "copies", "the", "contents", "of", "the", "old", "list", "to", "the", "first", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/IntListUtil.java#L465-L477
train
samskivert/samskivert
src/main/java/com/samskivert/util/IntListUtil.java
IntListUtil.box
public static Integer[] box (int[] list) { if (list == null) { return null; } Integer[] boxed = new Integer[list.length]; for (int ii = 0; ii < list.length; ii++) { boxed[ii] = list[ii]; } return boxed; }
java
public static Integer[] box (int[] list) { if (list == null) { return null; } Integer[] boxed = new Integer[list.length]; for (int ii = 0; ii < list.length; ii++) { boxed[ii] = list[ii]; } return boxed; }
[ "public", "static", "Integer", "[", "]", "box", "(", "int", "[", "]", "list", ")", "{", "if", "(", "list", "==", "null", ")", "{", "return", "null", ";", "}", "Integer", "[", "]", "boxed", "=", "new", "Integer", "[", "list", ".", "length", "]", ...
Covnerts an array of primitives to an array of objects.
[ "Covnerts", "an", "array", "of", "primitives", "to", "an", "array", "of", "objects", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/IntListUtil.java#L482-L492
train
samskivert/samskivert
src/main/java/com/samskivert/util/IntListUtil.java
IntListUtil.asList
public static List<Integer> asList (int[] list) { if (list == null) { return null; } List<Integer> ilist = new ArrayList<Integer>(list.length); for (int ii = 0; ii < list.length; ii++) { ilist.add(list[ii]); } return ilist; }
java
public static List<Integer> asList (int[] list) { if (list == null) { return null; } List<Integer> ilist = new ArrayList<Integer>(list.length); for (int ii = 0; ii < list.length; ii++) { ilist.add(list[ii]); } return ilist; }
[ "public", "static", "List", "<", "Integer", ">", "asList", "(", "int", "[", "]", "list", ")", "{", "if", "(", "list", "==", "null", ")", "{", "return", "null", ";", "}", "List", "<", "Integer", ">", "ilist", "=", "new", "ArrayList", "<", "Integer",...
Converts an array of primitives to a list of Integers.
[ "Converts", "an", "array", "of", "primitives", "to", "a", "list", "of", "Integers", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/IntListUtil.java#L497-L507
train
samskivert/samskivert
src/main/java/com/samskivert/net/AttachableURLFactory.java
AttachableURLFactory.attachHandler
public static void attachHandler ( String protocol, Class<? extends URLStreamHandler> handlerClass) { // set up the factory. if (_handlers == null) { _handlers = new HashMap<String,Class<? extends URLStreamHandler>>(); // There are two ways to do this. // Method 1, which is the only one that seems to work under // Java Web Start, is to register a factory. This can throw an // Error if another factory is already registered. We let that // error bubble on back. URL.setURLStreamHandlerFactory(new AttachableURLFactory()); // Method 2 seems like a better idea but doesn't work under // Java Web Start. We add on a property that registers this // very class as the handler for the resource property. It // would be instantiated with Class.forName(). // (And I did check, it's not dasho that is preventing this // from working under JWS, it's something else.) /* // dug up from java.net.URL String HANDLER_PROP = "java.protocol.handler.pkgs"; String prop = System.getProperty(HANDLER_PROP, ""); if (!"".equals(prop)) { prop += "|"; } prop += "com.threerings"; System.setProperty(HANDLER_PROP, prop); */ } _handlers.put(protocol.toLowerCase(), handlerClass); }
java
public static void attachHandler ( String protocol, Class<? extends URLStreamHandler> handlerClass) { // set up the factory. if (_handlers == null) { _handlers = new HashMap<String,Class<? extends URLStreamHandler>>(); // There are two ways to do this. // Method 1, which is the only one that seems to work under // Java Web Start, is to register a factory. This can throw an // Error if another factory is already registered. We let that // error bubble on back. URL.setURLStreamHandlerFactory(new AttachableURLFactory()); // Method 2 seems like a better idea but doesn't work under // Java Web Start. We add on a property that registers this // very class as the handler for the resource property. It // would be instantiated with Class.forName(). // (And I did check, it's not dasho that is preventing this // from working under JWS, it's something else.) /* // dug up from java.net.URL String HANDLER_PROP = "java.protocol.handler.pkgs"; String prop = System.getProperty(HANDLER_PROP, ""); if (!"".equals(prop)) { prop += "|"; } prop += "com.threerings"; System.setProperty(HANDLER_PROP, prop); */ } _handlers.put(protocol.toLowerCase(), handlerClass); }
[ "public", "static", "void", "attachHandler", "(", "String", "protocol", ",", "Class", "<", "?", "extends", "URLStreamHandler", ">", "handlerClass", ")", "{", "// set up the factory.", "if", "(", "_handlers", "==", "null", ")", "{", "_handlers", "=", "new", "Ha...
Register a URL handler. @param protocol the protocol to register. @param handlerClass a Class of type java.net.URLStreamHandler
[ "Register", "a", "URL", "handler", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/net/AttachableURLFactory.java#L28-L63
train
samskivert/samskivert
src/main/java/com/samskivert/net/AttachableURLFactory.java
AttachableURLFactory.createURLStreamHandler
public URLStreamHandler createURLStreamHandler (String protocol) { Class<? extends URLStreamHandler> handler = _handlers.get(protocol.toLowerCase()); if (handler != null) { try { return handler.newInstance(); } catch (Exception e) { log.warning("Unable to instantiate URLStreamHandler", "protocol", protocol, "cause", e); } } return null; }
java
public URLStreamHandler createURLStreamHandler (String protocol) { Class<? extends URLStreamHandler> handler = _handlers.get(protocol.toLowerCase()); if (handler != null) { try { return handler.newInstance(); } catch (Exception e) { log.warning("Unable to instantiate URLStreamHandler", "protocol", protocol, "cause", e); } } return null; }
[ "public", "URLStreamHandler", "createURLStreamHandler", "(", "String", "protocol", ")", "{", "Class", "<", "?", "extends", "URLStreamHandler", ">", "handler", "=", "_handlers", ".", "get", "(", "protocol", ".", "toLowerCase", "(", ")", ")", ";", "if", "(", "...
documentation inherited from interface URLStreamHandlerFactory
[ "documentation", "inherited", "from", "interface", "URLStreamHandlerFactory" ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/net/AttachableURLFactory.java#L73-L85
train
samskivert/samskivert
src/main/java/com/samskivert/util/ByteEnumUtil.java
ByteEnumUtil.fromByte
public static <E extends Enum<E> & ByteEnum> E fromByte (Class<E> eclass, byte code) { for (E value : eclass.getEnumConstants()) { if (value.toByte() == code) { return value; } } throw new IllegalArgumentException(eclass + " has no value with code " + code); }
java
public static <E extends Enum<E> & ByteEnum> E fromByte (Class<E> eclass, byte code) { for (E value : eclass.getEnumConstants()) { if (value.toByte() == code) { return value; } } throw new IllegalArgumentException(eclass + " has no value with code " + code); }
[ "public", "static", "<", "E", "extends", "Enum", "<", "E", ">", "&", "ByteEnum", ">", "E", "fromByte", "(", "Class", "<", "E", ">", "eclass", ",", "byte", "code", ")", "{", "for", "(", "E", "value", ":", "eclass", ".", "getEnumConstants", "(", ")",...
Returns the enum value with the specified code in the supplied enum class. @exception IllegalArgumentException thrown if the enum lacks a value that maps to the supplied code.
[ "Returns", "the", "enum", "value", "with", "the", "specified", "code", "in", "the", "supplied", "enum", "class", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ByteEnumUtil.java#L22-L30
train
samskivert/samskivert
src/main/java/com/samskivert/util/ByteEnumUtil.java
ByteEnumUtil.setToInt
public static <E extends Enum<E> & ByteEnum> int setToInt (Set<E> set) { int flags = 0; for (E value : set) { flags |= toIntFlag(value); } return flags; }
java
public static <E extends Enum<E> & ByteEnum> int setToInt (Set<E> set) { int flags = 0; for (E value : set) { flags |= toIntFlag(value); } return flags; }
[ "public", "static", "<", "E", "extends", "Enum", "<", "E", ">", "&", "ByteEnum", ">", "int", "setToInt", "(", "Set", "<", "E", ">", "set", ")", "{", "int", "flags", "=", "0", ";", "for", "(", "E", "value", ":", "set", ")", "{", "flags", "|=", ...
Convert a Set of ByteEnums into an integer compactly representing the elements that are included.
[ "Convert", "a", "Set", "of", "ByteEnums", "into", "an", "integer", "compactly", "representing", "the", "elements", "that", "are", "included", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ByteEnumUtil.java#L36-L43
train
samskivert/samskivert
src/main/java/com/samskivert/util/ByteEnumUtil.java
ByteEnumUtil.intToSet
public static <E extends Enum<E> & ByteEnum> EnumSet<E> intToSet (Class<E> eclass, int flags) { EnumSet<E> set = EnumSet.noneOf(eclass); for (E value : eclass.getEnumConstants()) { if ((flags & toIntFlag(value)) != 0) { set.add(value); } } return set; }
java
public static <E extends Enum<E> & ByteEnum> EnumSet<E> intToSet (Class<E> eclass, int flags) { EnumSet<E> set = EnumSet.noneOf(eclass); for (E value : eclass.getEnumConstants()) { if ((flags & toIntFlag(value)) != 0) { set.add(value); } } return set; }
[ "public", "static", "<", "E", "extends", "Enum", "<", "E", ">", "&", "ByteEnum", ">", "EnumSet", "<", "E", ">", "intToSet", "(", "Class", "<", "E", ">", "eclass", ",", "int", "flags", ")", "{", "EnumSet", "<", "E", ">", "set", "=", "EnumSet", "."...
Convert an int representation of ByteEnum flags into an EnumSet.
[ "Convert", "an", "int", "representation", "of", "ByteEnum", "flags", "into", "an", "EnumSet", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ByteEnumUtil.java#L48-L57
train
samskivert/samskivert
src/main/java/com/samskivert/util/Logger.java
Logger.initLogger
protected static void initLogger () { // if a custom class was specified as a system property, use that Factory factory = createConfiguredFactory(); // create and a log4j logger if the log4j configuration system property is set try { if (factory == null && System.getProperty("log4j.configuration") != null) { factory = (Factory)Class.forName("com.samskivert.util.Log4JLogger").newInstance(); } } catch (SecurityException se) { // in a sandbox, no biggie } catch (Throwable t) { System.err.println("Unable to instantiate Log4JLogger: " + t); } // create and a log4j2 logger if the log4j2 configuration system property is set try { if (factory == null && System.getProperty("log4j.configurationFile") != null) { factory = (Factory)Class.forName("com.samskivert.util.Log4J2Logger").newInstance(); } } catch (SecurityException se) { // in a sandbox, no biggie } catch (Throwable t) { System.err.println("Unable to instantiate Log4J2Logger: " + t); } // lastly, fall back to the Java logging system if (factory == null) { factory = new JDK14Logger(); } // and finally configure our factory setFactory(factory); }
java
protected static void initLogger () { // if a custom class was specified as a system property, use that Factory factory = createConfiguredFactory(); // create and a log4j logger if the log4j configuration system property is set try { if (factory == null && System.getProperty("log4j.configuration") != null) { factory = (Factory)Class.forName("com.samskivert.util.Log4JLogger").newInstance(); } } catch (SecurityException se) { // in a sandbox, no biggie } catch (Throwable t) { System.err.println("Unable to instantiate Log4JLogger: " + t); } // create and a log4j2 logger if the log4j2 configuration system property is set try { if (factory == null && System.getProperty("log4j.configurationFile") != null) { factory = (Factory)Class.forName("com.samskivert.util.Log4J2Logger").newInstance(); } } catch (SecurityException se) { // in a sandbox, no biggie } catch (Throwable t) { System.err.println("Unable to instantiate Log4J2Logger: " + t); } // lastly, fall back to the Java logging system if (factory == null) { factory = new JDK14Logger(); } // and finally configure our factory setFactory(factory); }
[ "protected", "static", "void", "initLogger", "(", ")", "{", "// if a custom class was specified as a system property, use that", "Factory", "factory", "=", "createConfiguredFactory", "(", ")", ";", "// create and a log4j logger if the log4j configuration system property is set", "try...
Called at static initialization time. Selects and initializes our logging backend.
[ "Called", "at", "static", "initialization", "time", ".", "Selects", "and", "initializes", "our", "logging", "backend", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Logger.java#L165-L199
train
samskivert/samskivert
src/main/java/com/samskivert/swing/GroupLayout.java
GroupLayout.getConstraints
protected Constraints getConstraints (Component child) { if (_constraints != null) { Constraints c = _constraints.get(child); if (c != null) { return c; } } return DEFAULT_CONSTRAINTS; }
java
protected Constraints getConstraints (Component child) { if (_constraints != null) { Constraints c = _constraints.get(child); if (c != null) { return c; } } return DEFAULT_CONSTRAINTS; }
[ "protected", "Constraints", "getConstraints", "(", "Component", "child", ")", "{", "if", "(", "_constraints", "!=", "null", ")", "{", "Constraints", "c", "=", "_constraints", ".", "get", "(", "child", ")", ";", "if", "(", "c", "!=", "null", ")", "{", "...
Get the Constraints for the specified child component. @return a Constraints object, never null.
[ "Get", "the", "Constraints", "for", "the", "specified", "child", "component", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/GroupLayout.java#L229-L239
train
samskivert/samskivert
src/main/java/com/samskivert/swing/GroupLayout.java
GroupLayout.computeDimens
protected DimenInfo computeDimens (Container parent, int type) { int count = parent.getComponentCount(); DimenInfo info = new DimenInfo(); info.dimens = new Dimension[count]; for (int i = 0; i < count; i++) { Component child = parent.getComponent(i); if (!child.isVisible()) { continue; } Dimension csize; switch (type) { case MINIMUM: csize = child.getMinimumSize(); break; case MAXIMUM: csize = child.getMaximumSize(); break; default: csize = child.getPreferredSize(); break; } info.count++; info.totwid += csize.width; info.tothei += csize.height; if (csize.width > info.maxwid) { info.maxwid = csize.width; } if (csize.height > info.maxhei) { info.maxhei = csize.height; } Constraints c = getConstraints(child); if (c.isFixed()) { info.fixwid += csize.width; info.fixhei += csize.height; info.numfix++; } else { info.totweight += c.getWeight(); if (csize.width > info.maxfreewid) { info.maxfreewid = csize.width; } if (csize.height > info.maxfreehei) { info.maxfreehei = csize.height; } } info.dimens[i] = csize; } return info; }
java
protected DimenInfo computeDimens (Container parent, int type) { int count = parent.getComponentCount(); DimenInfo info = new DimenInfo(); info.dimens = new Dimension[count]; for (int i = 0; i < count; i++) { Component child = parent.getComponent(i); if (!child.isVisible()) { continue; } Dimension csize; switch (type) { case MINIMUM: csize = child.getMinimumSize(); break; case MAXIMUM: csize = child.getMaximumSize(); break; default: csize = child.getPreferredSize(); break; } info.count++; info.totwid += csize.width; info.tothei += csize.height; if (csize.width > info.maxwid) { info.maxwid = csize.width; } if (csize.height > info.maxhei) { info.maxhei = csize.height; } Constraints c = getConstraints(child); if (c.isFixed()) { info.fixwid += csize.width; info.fixhei += csize.height; info.numfix++; } else { info.totweight += c.getWeight(); if (csize.width > info.maxfreewid) { info.maxfreewid = csize.width; } if (csize.height > info.maxfreehei) { info.maxfreehei = csize.height; } } info.dimens[i] = csize; } return info; }
[ "protected", "DimenInfo", "computeDimens", "(", "Container", "parent", ",", "int", "type", ")", "{", "int", "count", "=", "parent", ".", "getComponentCount", "(", ")", ";", "DimenInfo", "info", "=", "new", "DimenInfo", "(", ")", ";", "info", ".", "dimens",...
Computes dimensions of the children widgets that are useful for the group layout managers.
[ "Computes", "dimensions", "of", "the", "children", "widgets", "that", "are", "useful", "for", "the", "group", "layout", "managers", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/GroupLayout.java#L245-L303
train
samskivert/samskivert
src/main/java/com/samskivert/swing/LazyComponent.java
LazyComponent.checkCreate
protected void checkCreate () { if (_creator != null && isShowing()) { // ideally, we would replace ourselves in our parent, but that // doesn't seem to work in JTabbedPane setLayout(new BorderLayout()); add(_creator.createContent(), BorderLayout.CENTER); _creator = null; } }
java
protected void checkCreate () { if (_creator != null && isShowing()) { // ideally, we would replace ourselves in our parent, but that // doesn't seem to work in JTabbedPane setLayout(new BorderLayout()); add(_creator.createContent(), BorderLayout.CENTER); _creator = null; } }
[ "protected", "void", "checkCreate", "(", ")", "{", "if", "(", "_creator", "!=", "null", "&&", "isShowing", "(", ")", ")", "{", "// ideally, we would replace ourselves in our parent, but that", "// doesn't seem to work in JTabbedPane", "setLayout", "(", "new", "BorderLayou...
Check to see if we should now create the content.
[ "Check", "to", "see", "if", "we", "should", "now", "create", "the", "content", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/LazyComponent.java#L59-L68
train
samskivert/samskivert
src/main/java/com/samskivert/swing/util/RetryableTask.java
RetryableTask.invokeTask
public void invokeTask (Component parent, String retryMessage) throws Exception { while (true) { try { invoke(); return; } catch (Exception e) { Object[] options = new Object[] { "Retry operation", "Abort operation" }; int rv = JOptionPane.showOptionDialog( parent, retryMessage + "\n\n" + e.getMessage(), "Operation failure", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[1]); if (rv == 1) { throw e; } } } }
java
public void invokeTask (Component parent, String retryMessage) throws Exception { while (true) { try { invoke(); return; } catch (Exception e) { Object[] options = new Object[] { "Retry operation", "Abort operation" }; int rv = JOptionPane.showOptionDialog( parent, retryMessage + "\n\n" + e.getMessage(), "Operation failure", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[1]); if (rv == 1) { throw e; } } } }
[ "public", "void", "invokeTask", "(", "Component", "parent", ",", "String", "retryMessage", ")", "throws", "Exception", "{", "while", "(", "true", ")", "{", "try", "{", "invoke", "(", ")", ";", "return", ";", "}", "catch", "(", "Exception", "e", ")", "{...
Invokes the supplied task and catches any thrown exceptions. In the event of an exception, the provided message is displayed to the user and the are allowed to retry the task or allow it to fail.
[ "Invokes", "the", "supplied", "task", "and", "catches", "any", "thrown", "exceptions", ".", "In", "the", "event", "of", "an", "exception", "the", "provided", "message", "is", "displayed", "to", "the", "user", "and", "the", "are", "allowed", "to", "retry", ...
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/util/RetryableTask.java#L33-L53
train
samskivert/samskivert
src/main/java/com/samskivert/util/SystemInfo.java
SystemInfo.update
public void update () { // grab the various system properties osName = System.getProperty("os.name"); osVersion = System.getProperty("os.version"); osArch = System.getProperty("os.arch"); javaVersion = System.getProperty("java.version"); javaVendor = System.getProperty("java.vendor"); // determine memory usage Runtime rtime = Runtime.getRuntime(); freeMemory = rtime.freeMemory() / 1024; totalMemory = rtime.totalMemory() / 1024; usedMemory = totalMemory - freeMemory; maxMemory = rtime.maxMemory() / 1024; // determine video display information isHeadless = GraphicsEnvironment.isHeadless(); if (!isHeadless) { try { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = env.getDefaultScreenDevice(); DisplayMode mode = gd.getDisplayMode(); bitDepth = mode.getBitDepth(); refreshRate = mode.getRefreshRate() / 1024; isFullScreen = (gd.getFullScreenWindow() != null); displayWidth = mode.getWidth(); displayHeight = mode.getHeight(); } catch (Throwable t) { isHeadless = true; } } }
java
public void update () { // grab the various system properties osName = System.getProperty("os.name"); osVersion = System.getProperty("os.version"); osArch = System.getProperty("os.arch"); javaVersion = System.getProperty("java.version"); javaVendor = System.getProperty("java.vendor"); // determine memory usage Runtime rtime = Runtime.getRuntime(); freeMemory = rtime.freeMemory() / 1024; totalMemory = rtime.totalMemory() / 1024; usedMemory = totalMemory - freeMemory; maxMemory = rtime.maxMemory() / 1024; // determine video display information isHeadless = GraphicsEnvironment.isHeadless(); if (!isHeadless) { try { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = env.getDefaultScreenDevice(); DisplayMode mode = gd.getDisplayMode(); bitDepth = mode.getBitDepth(); refreshRate = mode.getRefreshRate() / 1024; isFullScreen = (gd.getFullScreenWindow() != null); displayWidth = mode.getWidth(); displayHeight = mode.getHeight(); } catch (Throwable t) { isHeadless = true; } } }
[ "public", "void", "update", "(", ")", "{", "// grab the various system properties", "osName", "=", "System", ".", "getProperty", "(", "\"os.name\"", ")", ";", "osVersion", "=", "System", ".", "getProperty", "(", "\"os.version\"", ")", ";", "osArch", "=", "System...
Updates the system info record's statistics to reflect the current state of the JVM.
[ "Updates", "the", "system", "info", "record", "s", "statistics", "to", "reflect", "the", "current", "state", "of", "the", "JVM", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/SystemInfo.java#L79-L113
train
samskivert/samskivert
src/main/java/com/samskivert/util/DependencyGraph.java
DependencyGraph.add
public void add (T element) { DependencyNode<T> node = new DependencyNode<T>(element); _nodes.put(element, node); _orphans.add(element); }
java
public void add (T element) { DependencyNode<T> node = new DependencyNode<T>(element); _nodes.put(element, node); _orphans.add(element); }
[ "public", "void", "add", "(", "T", "element", ")", "{", "DependencyNode", "<", "T", ">", "node", "=", "new", "DependencyNode", "<", "T", ">", "(", "element", ")", ";", "_nodes", ".", "put", "(", "element", ",", "node", ")", ";", "_orphans", ".", "a...
Adds an element with no initial dependencies from the graph.
[ "Adds", "an", "element", "with", "no", "initial", "dependencies", "from", "the", "graph", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/DependencyGraph.java#L26-L31
train
samskivert/samskivert
src/main/java/com/samskivert/util/DependencyGraph.java
DependencyGraph.remove
public void remove (T element) { DependencyNode<T> node = _nodes.remove(element); _orphans.remove(element); // Remove ourselves as a child of our parents. for (DependencyNode<T> parent : node.parents) { parent.children.remove(node); } // Remove ourselves as a parent of our children, possibly orphaning them. for (DependencyNode<T> child : node.children) { child.parents.remove(node); if (child.parents.isEmpty()) { _orphans.add(child.content); } } }
java
public void remove (T element) { DependencyNode<T> node = _nodes.remove(element); _orphans.remove(element); // Remove ourselves as a child of our parents. for (DependencyNode<T> parent : node.parents) { parent.children.remove(node); } // Remove ourselves as a parent of our children, possibly orphaning them. for (DependencyNode<T> child : node.children) { child.parents.remove(node); if (child.parents.isEmpty()) { _orphans.add(child.content); } } }
[ "public", "void", "remove", "(", "T", "element", ")", "{", "DependencyNode", "<", "T", ">", "node", "=", "_nodes", ".", "remove", "(", "element", ")", ";", "_orphans", ".", "remove", "(", "element", ")", ";", "// Remove ourselves as a child of our parents.", ...
Removes an element and its dependencies from the graph.
[ "Removes", "an", "element", "and", "its", "dependencies", "from", "the", "graph", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/DependencyGraph.java#L36-L53
train
samskivert/samskivert
src/main/java/com/samskivert/util/DependencyGraph.java
DependencyGraph.addDependency
public void addDependency (T dependant, T dependee) { _orphans.remove(dependant); DependencyNode<T> dependantNode = _nodes.get(dependant); if (dependantNode == null) { throw new IllegalArgumentException("Unknown dependant? " + dependant); } DependencyNode<T> dependeeNode = _nodes.get(dependee); if (dependeeNode == null) { throw new IllegalArgumentException("Unknown dependee? " + dependee); } if (dependee == dependant || dependsOn(dependee, dependant)) { throw new IllegalArgumentException("Refusing to create circular dependency."); } dependantNode.parents.add(dependeeNode); dependeeNode.children.add(dependantNode); }
java
public void addDependency (T dependant, T dependee) { _orphans.remove(dependant); DependencyNode<T> dependantNode = _nodes.get(dependant); if (dependantNode == null) { throw new IllegalArgumentException("Unknown dependant? " + dependant); } DependencyNode<T> dependeeNode = _nodes.get(dependee); if (dependeeNode == null) { throw new IllegalArgumentException("Unknown dependee? " + dependee); } if (dependee == dependant || dependsOn(dependee, dependant)) { throw new IllegalArgumentException("Refusing to create circular dependency."); } dependantNode.parents.add(dependeeNode); dependeeNode.children.add(dependantNode); }
[ "public", "void", "addDependency", "(", "T", "dependant", ",", "T", "dependee", ")", "{", "_orphans", ".", "remove", "(", "dependant", ")", ";", "DependencyNode", "<", "T", ">", "dependantNode", "=", "_nodes", ".", "get", "(", "dependant", ")", ";", "if"...
Records a new dependency of the dependant upon the dependee.
[ "Records", "a", "new", "dependency", "of", "the", "dependant", "upon", "the", "dependee", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/DependencyGraph.java#L85-L101
train
samskivert/samskivert
src/main/java/com/samskivert/util/DependencyGraph.java
DependencyGraph.dependsOn
public boolean dependsOn (T elem1, T elem2) { DependencyNode<T> node1 = _nodes.get(elem1); DependencyNode<T> node2 = _nodes.get(elem2); List<DependencyNode<T>> nodesToCheck = new ArrayList<DependencyNode<T>>(); List<DependencyNode<T>> nodesAlreadyChecked = new ArrayList<DependencyNode<T>>(); nodesToCheck.addAll(node1.parents); // We prevent circular dependencies when we add dependencies. Otherwise, this'd be // potentially non-terminating. while (!nodesToCheck.isEmpty()) { // We take it off the end since we don't care about order and this is faster. DependencyNode<T> checkNode = nodesToCheck.remove(nodesToCheck.size() - 1); if (nodesAlreadyChecked.contains(checkNode)) { // We've seen him before, no need to check again. continue; } else if (checkNode == node2) { // We've found our dependency return true; } else { nodesAlreadyChecked.add(checkNode); nodesToCheck.addAll(checkNode.parents); } } return false; }
java
public boolean dependsOn (T elem1, T elem2) { DependencyNode<T> node1 = _nodes.get(elem1); DependencyNode<T> node2 = _nodes.get(elem2); List<DependencyNode<T>> nodesToCheck = new ArrayList<DependencyNode<T>>(); List<DependencyNode<T>> nodesAlreadyChecked = new ArrayList<DependencyNode<T>>(); nodesToCheck.addAll(node1.parents); // We prevent circular dependencies when we add dependencies. Otherwise, this'd be // potentially non-terminating. while (!nodesToCheck.isEmpty()) { // We take it off the end since we don't care about order and this is faster. DependencyNode<T> checkNode = nodesToCheck.remove(nodesToCheck.size() - 1); if (nodesAlreadyChecked.contains(checkNode)) { // We've seen him before, no need to check again. continue; } else if (checkNode == node2) { // We've found our dependency return true; } else { nodesAlreadyChecked.add(checkNode); nodesToCheck.addAll(checkNode.parents); } } return false; }
[ "public", "boolean", "dependsOn", "(", "T", "elem1", ",", "T", "elem2", ")", "{", "DependencyNode", "<", "T", ">", "node1", "=", "_nodes", ".", "get", "(", "elem1", ")", ";", "DependencyNode", "<", "T", ">", "node2", "=", "_nodes", ".", "get", "(", ...
Returns whether elem1 is designated to depend on elem2.
[ "Returns", "whether", "elem1", "is", "designated", "to", "depend", "on", "elem2", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/DependencyGraph.java#L106-L136
train
samskivert/samskivert
src/main/java/com/samskivert/util/DependencyGraph.java
DependencyGraph.toObserverList
public ObserverList<T> toObserverList () { ObserverList<T> list = ObserverList.newSafeInOrder(); while (!isEmpty()) { list.add(removeAvailableElement()); } return list; }
java
public ObserverList<T> toObserverList () { ObserverList<T> list = ObserverList.newSafeInOrder(); while (!isEmpty()) { list.add(removeAvailableElement()); } return list; }
[ "public", "ObserverList", "<", "T", ">", "toObserverList", "(", ")", "{", "ObserverList", "<", "T", ">", "list", "=", "ObserverList", ".", "newSafeInOrder", "(", ")", ";", "while", "(", "!", "isEmpty", "(", ")", ")", "{", "list", ".", "add", "(", "re...
Flattens this graph into an observer list in dependencys order. Empties the graph in the process.
[ "Flattens", "this", "graph", "into", "an", "observer", "list", "in", "dependencys", "order", ".", "Empties", "the", "graph", "in", "the", "process", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/DependencyGraph.java#L142-L149
train
samskivert/samskivert
src/main/java/com/samskivert/util/PrefsConfig.java
PrefsConfig.remove
public void remove (String name) { // we treat the old value as a String, I hope that's ok! String oldValue = getValue(name, (String) null); _prefs.remove(name); _propsup.firePropertyChange(name, oldValue, null); }
java
public void remove (String name) { // we treat the old value as a String, I hope that's ok! String oldValue = getValue(name, (String) null); _prefs.remove(name); _propsup.firePropertyChange(name, oldValue, null); }
[ "public", "void", "remove", "(", "String", "name", ")", "{", "// we treat the old value as a String, I hope that's ok!", "String", "oldValue", "=", "getValue", "(", "name", ",", "(", "String", ")", "null", ")", ";", "_prefs", ".", "remove", "(", "name", ")", "...
Remove any set value for the specified preference.
[ "Remove", "any", "set", "value", "for", "the", "specified", "preference", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/PrefsConfig.java#L183-L189
train
samskivert/samskivert
src/main/java/com/samskivert/servlet/util/HTMLUtil.java
HTMLUtil.restrictHTML
public static String restrictHTML (String src, boolean allowFormatting, boolean allowImages, boolean allowLinks) { // TODO: these regexes should probably be checked to make // sure that javascript can't live inside a link ArrayList<String> allow = new ArrayList<String>(); if (allowFormatting) { allow.add("<b>"); allow.add("</b>"); allow.add("<i>"); allow.add("</i>"); allow.add("<u>"); allow.add("</u>"); allow.add("<font [^\"<>!-]*(\"[^\"<>!-]*\"[^\"<>!-]*)*>"); allow.add("</font>"); allow.add("<br>"); allow.add("</br>"); allow.add("<br/>"); allow.add("<p>"); allow.add("</p>"); allow.add("<hr>"); allow.add("</hr>"); allow.add("<hr/>"); } if (allowImages) { // Until I find a way to disallow "---", no - can be in a url allow.add("<img [^\"<>!-]*(\"[^\"<>!-]*\"[^\"<>!-]*)*>"); allow.add("</img>"); } if (allowLinks) { allow.add("<a href=[^\"<>!-]*(\"[^\"<>!-]*\"[^\"<>!-]*)*>"); allow.add("</a>"); } return restrictHTML(src, allow.toArray(new String[allow.size()])); }
java
public static String restrictHTML (String src, boolean allowFormatting, boolean allowImages, boolean allowLinks) { // TODO: these regexes should probably be checked to make // sure that javascript can't live inside a link ArrayList<String> allow = new ArrayList<String>(); if (allowFormatting) { allow.add("<b>"); allow.add("</b>"); allow.add("<i>"); allow.add("</i>"); allow.add("<u>"); allow.add("</u>"); allow.add("<font [^\"<>!-]*(\"[^\"<>!-]*\"[^\"<>!-]*)*>"); allow.add("</font>"); allow.add("<br>"); allow.add("</br>"); allow.add("<br/>"); allow.add("<p>"); allow.add("</p>"); allow.add("<hr>"); allow.add("</hr>"); allow.add("<hr/>"); } if (allowImages) { // Until I find a way to disallow "---", no - can be in a url allow.add("<img [^\"<>!-]*(\"[^\"<>!-]*\"[^\"<>!-]*)*>"); allow.add("</img>"); } if (allowLinks) { allow.add("<a href=[^\"<>!-]*(\"[^\"<>!-]*\"[^\"<>!-]*)*>"); allow.add("</a>"); } return restrictHTML(src, allow.toArray(new String[allow.size()])); }
[ "public", "static", "String", "restrictHTML", "(", "String", "src", ",", "boolean", "allowFormatting", ",", "boolean", "allowImages", ",", "boolean", "allowLinks", ")", "{", "// TODO: these regexes should probably be checked to make", "// sure that javascript can't live inside ...
Restrict HTML except for the specified tags. @param allowFormatting enables &lt;i&gt;, &lt;b&gt;, &lt;u&gt;, &lt;font&gt;, &lt;br&gt;, &lt;p&gt;, and &lt;hr&gt;. @param allowImages enabled &lt;img ...&gt;. @param allowLinks enabled &lt;a href ...&gt;.
[ "Restrict", "HTML", "except", "for", "the", "specified", "tags", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/util/HTMLUtil.java#L160-L186
train
samskivert/samskivert
src/main/java/com/samskivert/servlet/util/HTMLUtil.java
HTMLUtil.restrictHTML
public static String restrictHTML (String src, String[] regexes) { if (StringUtil.isBlank(src)) { return src; } ArrayList<String> list = new ArrayList<String>(); list.add(src); for (String regexe : regexes) { Pattern p = Pattern.compile(regexe, Pattern.CASE_INSENSITIVE); for (int jj=0; jj < list.size(); jj += 2) { String piece = list.get(jj); Matcher m = p.matcher(piece); if (m.find()) { list.set(jj, piece.substring(0, m.start())); list.add(jj + 1, piece.substring(m.start(), m.end())); list.add(jj + 2, piece.substring(m.end())); } } } // now, the even elements of list contain untrusted text, the // odd elements contain stuff that matched a regex StringBuilder buf = new StringBuilder(); for (int jj=0, nn = list.size(); jj < nn; jj++) { String s = list.get(jj); if (jj % 2 == 0) { s = s.replace("<", "&lt;"); s = s.replace(">", "&gt;"); } buf.append(s); } return buf.toString(); }
java
public static String restrictHTML (String src, String[] regexes) { if (StringUtil.isBlank(src)) { return src; } ArrayList<String> list = new ArrayList<String>(); list.add(src); for (String regexe : regexes) { Pattern p = Pattern.compile(regexe, Pattern.CASE_INSENSITIVE); for (int jj=0; jj < list.size(); jj += 2) { String piece = list.get(jj); Matcher m = p.matcher(piece); if (m.find()) { list.set(jj, piece.substring(0, m.start())); list.add(jj + 1, piece.substring(m.start(), m.end())); list.add(jj + 2, piece.substring(m.end())); } } } // now, the even elements of list contain untrusted text, the // odd elements contain stuff that matched a regex StringBuilder buf = new StringBuilder(); for (int jj=0, nn = list.size(); jj < nn; jj++) { String s = list.get(jj); if (jj % 2 == 0) { s = s.replace("<", "&lt;"); s = s.replace(">", "&gt;"); } buf.append(s); } return buf.toString(); }
[ "public", "static", "String", "restrictHTML", "(", "String", "src", ",", "String", "[", "]", "regexes", ")", "{", "if", "(", "StringUtil", ".", "isBlank", "(", "src", ")", ")", "{", "return", "src", ";", "}", "ArrayList", "<", "String", ">", "list", ...
Restrict HTML from the specified string except for the specified regular expressions.
[ "Restrict", "HTML", "from", "the", "specified", "string", "except", "for", "the", "specified", "regular", "expressions", "." ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/util/HTMLUtil.java#L192-L225
train
samskivert/samskivert
src/main/java/com/samskivert/util/ComplainingListener.java
ComplainingListener.requestFailed
public void requestFailed (Exception cause) { Object[] args = _args != null ? ArrayUtil.append(_args, cause) : new Object[] { cause }; if (_slogger != null) { _slogger.warning(_errorText, args); } else if (_jlogger != null) { _jlogger.log(Level.WARNING, Logger.format(_errorText, args), cause); } else { System.err.println(Logger.format(_errorText, args)); } }
java
public void requestFailed (Exception cause) { Object[] args = _args != null ? ArrayUtil.append(_args, cause) : new Object[] { cause }; if (_slogger != null) { _slogger.warning(_errorText, args); } else if (_jlogger != null) { _jlogger.log(Level.WARNING, Logger.format(_errorText, args), cause); } else { System.err.println(Logger.format(_errorText, args)); } }
[ "public", "void", "requestFailed", "(", "Exception", "cause", ")", "{", "Object", "[", "]", "args", "=", "_args", "!=", "null", "?", "ArrayUtil", ".", "append", "(", "_args", ",", "cause", ")", ":", "new", "Object", "[", "]", "{", "cause", "}", ";", ...
from interface ResultListener
[ "from", "interface", "ResultListener" ]
a64d9ef42b69819bdb2c66bddac6a64caef928b6
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ComplainingListener.java#L44-L54
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.compare
public static int compare(Date d1, Date d2) { Calendar c1 = Calendar.getInstance(); c1.setTime(d1); Calendar c2 = Calendar.getInstance(); c2.setTime(d2); if (c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR)) { if (c1.get(Calendar.MONTH) == c2.get(Calendar.MONTH)) { return c1.get(Calendar.DAY_OF_MONTH) - c2.get(Calendar.DAY_OF_MONTH); } return c1.get(Calendar.MONTH) - c2.get(Calendar.MONTH); } return c1.get(Calendar.YEAR) - c2.get(Calendar.YEAR); }
java
public static int compare(Date d1, Date d2) { Calendar c1 = Calendar.getInstance(); c1.setTime(d1); Calendar c2 = Calendar.getInstance(); c2.setTime(d2); if (c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR)) { if (c1.get(Calendar.MONTH) == c2.get(Calendar.MONTH)) { return c1.get(Calendar.DAY_OF_MONTH) - c2.get(Calendar.DAY_OF_MONTH); } return c1.get(Calendar.MONTH) - c2.get(Calendar.MONTH); } return c1.get(Calendar.YEAR) - c2.get(Calendar.YEAR); }
[ "public", "static", "int", "compare", "(", "Date", "d1", ",", "Date", "d2", ")", "{", "Calendar", "c1", "=", "Calendar", ".", "getInstance", "(", ")", ";", "c1", ".", "setTime", "(", "d1", ")", ";", "Calendar", "c2", "=", "Calendar", ".", "getInstanc...
Compares two dates taking into consideration only the year, month and day @param d1 the first date @param d2 the second date @return a negative integer, zero, or a positive integer as <code>d1</code> is less than, equal to, or greater than <code>d2</code> @see java.util.Comparator @see #after(Date, Date) @see #before(Date, Date)
[ "Compares", "two", "dates", "taking", "into", "consideration", "only", "the", "year", "month", "and", "day" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L93-L106
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.getYear
public static int getYear(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.YEAR); }
java
public static int getYear(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.YEAR); }
[ "public", "static", "int", "getYear", "(", "Date", "date", ")", "{", "Calendar", "c", "=", "Calendar", ".", "getInstance", "(", ")", ";", "c", ".", "setTime", "(", "date", ")", ";", "return", "c", ".", "get", "(", "Calendar", ".", "YEAR", ")", ";",...
Get the year of the date @param date date @return year of the date
[ "Get", "the", "year", "of", "the", "date" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L113-L117
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.getMonth
public static int getMonth(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.MONTH); }
java
public static int getMonth(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.MONTH); }
[ "public", "static", "int", "getMonth", "(", "Date", "date", ")", "{", "Calendar", "c", "=", "Calendar", ".", "getInstance", "(", ")", ";", "c", ".", "setTime", "(", "date", ")", ";", "return", "c", ".", "get", "(", "Calendar", ".", "MONTH", ")", ";...
Get the month of the date @param date date @return month of the date
[ "Get", "the", "month", "of", "the", "date" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L124-L128
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.getDayOfYear
public static int getDayOfYear(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.DAY_OF_YEAR); }
java
public static int getDayOfYear(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.DAY_OF_YEAR); }
[ "public", "static", "int", "getDayOfYear", "(", "Date", "date", ")", "{", "Calendar", "c", "=", "Calendar", ".", "getInstance", "(", ")", ";", "c", ".", "setTime", "(", "date", ")", ";", "return", "c", ".", "get", "(", "Calendar", ".", "DAY_OF_YEAR", ...
Get the day of year of the date @param date date @return day of year of the date
[ "Get", "the", "day", "of", "year", "of", "the", "date" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L135-L139
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.getDayOfMonth
public static int getDayOfMonth(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.DAY_OF_MONTH); }
java
public static int getDayOfMonth(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.DAY_OF_MONTH); }
[ "public", "static", "int", "getDayOfMonth", "(", "Date", "date", ")", "{", "Calendar", "c", "=", "Calendar", ".", "getInstance", "(", ")", ";", "c", ".", "setTime", "(", "date", ")", ";", "return", "c", ".", "get", "(", "Calendar", ".", "DAY_OF_MONTH",...
Get the day of month of the date @param date date @return day of month of the date
[ "Get", "the", "day", "of", "month", "of", "the", "date" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L146-L150
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.getDayOfWeek
public static int getDayOfWeek(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.DAY_OF_WEEK); }
java
public static int getDayOfWeek(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.DAY_OF_WEEK); }
[ "public", "static", "int", "getDayOfWeek", "(", "Date", "date", ")", "{", "Calendar", "c", "=", "Calendar", ".", "getInstance", "(", ")", ";", "c", ".", "setTime", "(", "date", ")", ";", "return", "c", ".", "get", "(", "Calendar", ".", "DAY_OF_WEEK", ...
Get the day of week of the date @param date date @return day of week of the date
[ "Get", "the", "day", "of", "week", "of", "the", "date" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L157-L161
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.getHour
public static int getHour(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.HOUR_OF_DAY); }
java
public static int getHour(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.HOUR_OF_DAY); }
[ "public", "static", "int", "getHour", "(", "Date", "date", ")", "{", "Calendar", "c", "=", "Calendar", ".", "getInstance", "(", ")", ";", "c", ".", "setTime", "(", "date", ")", ";", "return", "c", ".", "get", "(", "Calendar", ".", "HOUR_OF_DAY", ")",...
Get the hour of the date @param date date @return hour of the date
[ "Get", "the", "hour", "of", "the", "date" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L168-L172
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.getMinute
public static int getMinute(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.MINUTE); }
java
public static int getMinute(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.MINUTE); }
[ "public", "static", "int", "getMinute", "(", "Date", "date", ")", "{", "Calendar", "c", "=", "Calendar", ".", "getInstance", "(", ")", ";", "c", ".", "setTime", "(", "date", ")", ";", "return", "c", ".", "get", "(", "Calendar", ".", "MINUTE", ")", ...
Get the minute of the date @param date date @return minute of the date
[ "Get", "the", "minute", "of", "the", "date" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L179-L183
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.getSecond
public static int getSecond(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.SECOND); }
java
public static int getSecond(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.SECOND); }
[ "public", "static", "int", "getSecond", "(", "Date", "date", ")", "{", "Calendar", "c", "=", "Calendar", ".", "getInstance", "(", ")", ";", "c", ".", "setTime", "(", "date", ")", ";", "return", "c", ".", "get", "(", "Calendar", ".", "SECOND", ")", ...
Get the second of the date @param date date @return second of the date
[ "Get", "the", "second", "of", "the", "date" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L190-L194
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.floor
public static Date floor(Date d) { Calendar c = Calendar.getInstance(); c.setTime(d); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return c.getTime(); }
java
public static Date floor(Date d) { Calendar c = Calendar.getInstance(); c.setTime(d); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return c.getTime(); }
[ "public", "static", "Date", "floor", "(", "Date", "d", ")", "{", "Calendar", "c", "=", "Calendar", ".", "getInstance", "(", ")", ";", "c", ".", "setTime", "(", "d", ")", ";", "c", ".", "set", "(", "Calendar", ".", "HOUR_OF_DAY", ",", "0", ")", ";...
Rounds a date to hour 0, minute 0, second 0 and millisecond 0 @param d the date @return the rounded date
[ "Rounds", "a", "date", "to", "hour", "0", "minute", "0", "second", "0", "and", "millisecond", "0" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L201-L209
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.sameDay
public static boolean sameDay(Date dateOne, Date dateTwo) { if ((dateOne == null) || (dateTwo == null)) { return false; } Calendar cal = Calendar.getInstance(); cal.setTime(dateOne); int year = cal.get(Calendar.YEAR); int day = cal.get(Calendar.DAY_OF_YEAR); cal.setTime(dateTwo); int year2 = cal.get(Calendar.YEAR); int day2 = cal.get(Calendar.DAY_OF_YEAR); return ( (year == year2) && (day == day2) ); }
java
public static boolean sameDay(Date dateOne, Date dateTwo) { if ((dateOne == null) || (dateTwo == null)) { return false; } Calendar cal = Calendar.getInstance(); cal.setTime(dateOne); int year = cal.get(Calendar.YEAR); int day = cal.get(Calendar.DAY_OF_YEAR); cal.setTime(dateTwo); int year2 = cal.get(Calendar.YEAR); int day2 = cal.get(Calendar.DAY_OF_YEAR); return ( (year == year2) && (day == day2) ); }
[ "public", "static", "boolean", "sameDay", "(", "Date", "dateOne", ",", "Date", "dateTwo", ")", "{", "if", "(", "(", "dateOne", "==", "null", ")", "||", "(", "dateTwo", "==", "null", ")", ")", "{", "return", "false", ";", "}", "Calendar", "cal", "=", ...
Test to see if two dates are in the same day of year @param dateOne first date @param dateTwo second date @return true if the two dates are in the same day of year
[ "Test", "to", "see", "if", "two", "dates", "are", "in", "the", "same", "day", "of", "year" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L232-L247
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.sameWeek
public static boolean sameWeek(Date dateOne, Date dateTwo) { if ((dateOne == null) || (dateTwo == null)) { return false; } Calendar cal = Calendar.getInstance(); cal.setTime(dateOne); int year = cal.get(Calendar.YEAR); int week = cal.get(Calendar.WEEK_OF_YEAR); cal.setTime(dateTwo); int year2 = cal.get(Calendar.YEAR); int week2 = cal.get(Calendar.WEEK_OF_YEAR); return ( (year == year2) && (week == week2) ); }
java
public static boolean sameWeek(Date dateOne, Date dateTwo) { if ((dateOne == null) || (dateTwo == null)) { return false; } Calendar cal = Calendar.getInstance(); cal.setTime(dateOne); int year = cal.get(Calendar.YEAR); int week = cal.get(Calendar.WEEK_OF_YEAR); cal.setTime(dateTwo); int year2 = cal.get(Calendar.YEAR); int week2 = cal.get(Calendar.WEEK_OF_YEAR); return ( (year == year2) && (week == week2) ); }
[ "public", "static", "boolean", "sameWeek", "(", "Date", "dateOne", ",", "Date", "dateTwo", ")", "{", "if", "(", "(", "dateOne", "==", "null", ")", "||", "(", "dateTwo", "==", "null", ")", ")", "{", "return", "false", ";", "}", "Calendar", "cal", "=",...
Test to see if two dates are in the same week @param dateOne first date @param dateTwo second date @return true if the two dates are in the same week
[ "Test", "to", "see", "if", "two", "dates", "are", "in", "the", "same", "week" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L255-L270
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.sameMonth
public static boolean sameMonth(Date dateOne, Date dateTwo) { if ((dateOne == null) || (dateTwo == null)) { return false; } Calendar cal = Calendar.getInstance(); cal.setTime(dateOne); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH); cal.setTime(dateTwo); int year2 = cal.get(Calendar.YEAR); int month2 = cal.get(Calendar.MONTH); return ( (year == year2) && (month == month2) ); }
java
public static boolean sameMonth(Date dateOne, Date dateTwo) { if ((dateOne == null) || (dateTwo == null)) { return false; } Calendar cal = Calendar.getInstance(); cal.setTime(dateOne); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH); cal.setTime(dateTwo); int year2 = cal.get(Calendar.YEAR); int month2 = cal.get(Calendar.MONTH); return ( (year == year2) && (month == month2) ); }
[ "public", "static", "boolean", "sameMonth", "(", "Date", "dateOne", ",", "Date", "dateTwo", ")", "{", "if", "(", "(", "dateOne", "==", "null", ")", "||", "(", "dateTwo", "==", "null", ")", ")", "{", "return", "false", ";", "}", "Calendar", "cal", "="...
Test to see if two dates are in the same month @param dateOne first date @param dateTwo second date @return true if the two dates are in the same month
[ "Test", "to", "see", "if", "two", "dates", "are", "in", "the", "same", "month" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L278-L293
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.sameHour
public static boolean sameHour(Date dateOne, Date dateTwo) { if ((dateOne == null) || (dateTwo == null)) { return false; } Calendar cal = Calendar.getInstance(); cal.setTime(dateOne); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH); int day = cal.get(Calendar.DAY_OF_YEAR); int hour = cal.get(Calendar.HOUR_OF_DAY); cal.setTime(dateTwo); int year2 = cal.get(Calendar.YEAR); int month2 = cal.get(Calendar.MONTH); int day2 = cal.get(Calendar.DAY_OF_YEAR); int hour2 = cal.get(Calendar.HOUR_OF_DAY); return ( (year == year2) && (month == month2) && (day == day2) && (hour == hour2)); }
java
public static boolean sameHour(Date dateOne, Date dateTwo) { if ((dateOne == null) || (dateTwo == null)) { return false; } Calendar cal = Calendar.getInstance(); cal.setTime(dateOne); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH); int day = cal.get(Calendar.DAY_OF_YEAR); int hour = cal.get(Calendar.HOUR_OF_DAY); cal.setTime(dateTwo); int year2 = cal.get(Calendar.YEAR); int month2 = cal.get(Calendar.MONTH); int day2 = cal.get(Calendar.DAY_OF_YEAR); int hour2 = cal.get(Calendar.HOUR_OF_DAY); return ( (year == year2) && (month == month2) && (day == day2) && (hour == hour2)); }
[ "public", "static", "boolean", "sameHour", "(", "Date", "dateOne", ",", "Date", "dateTwo", ")", "{", "if", "(", "(", "dateOne", "==", "null", ")", "||", "(", "dateTwo", "==", "null", ")", ")", "{", "return", "false", ";", "}", "Calendar", "cal", "=",...
Test to see if two dates are in the same hour of day @param dateOne first date @param dateTwo second date @return true if the two dates are in the same hour of day
[ "Test", "to", "see", "if", "two", "dates", "are", "in", "the", "same", "hour", "of", "day" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L301-L321
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.getNumberOfDays
public static int getNumberOfDays(Date first, Date second) { Calendar c = Calendar.getInstance(); int result = 0; int compare = first.compareTo(second); if (compare > 0) return 0; if (compare == 0) return 1; c.setTime(first); int firstDay = c.get(Calendar.DAY_OF_YEAR); int firstYear = c.get(Calendar.YEAR); int firstDays = c.getActualMaximum(Calendar.DAY_OF_YEAR); c.setTime(second); int secondDay = c.get(Calendar.DAY_OF_YEAR); int secondYear = c.get(Calendar.YEAR); // if dates in the same year if (firstYear == secondYear) { result = secondDay-firstDay+1; } // different years else { // days from the first year result += firstDays - firstDay + 1; // add days from all years between the two dates years for (int i = firstYear+1; i< secondYear; i++) { c.set(i,0,0); result += c.getActualMaximum(Calendar.DAY_OF_YEAR); } // days from last year result += secondDay; } return result; }
java
public static int getNumberOfDays(Date first, Date second) { Calendar c = Calendar.getInstance(); int result = 0; int compare = first.compareTo(second); if (compare > 0) return 0; if (compare == 0) return 1; c.setTime(first); int firstDay = c.get(Calendar.DAY_OF_YEAR); int firstYear = c.get(Calendar.YEAR); int firstDays = c.getActualMaximum(Calendar.DAY_OF_YEAR); c.setTime(second); int secondDay = c.get(Calendar.DAY_OF_YEAR); int secondYear = c.get(Calendar.YEAR); // if dates in the same year if (firstYear == secondYear) { result = secondDay-firstDay+1; } // different years else { // days from the first year result += firstDays - firstDay + 1; // add days from all years between the two dates years for (int i = firstYear+1; i< secondYear; i++) { c.set(i,0,0); result += c.getActualMaximum(Calendar.DAY_OF_YEAR); } // days from last year result += secondDay; } return result; }
[ "public", "static", "int", "getNumberOfDays", "(", "Date", "first", ",", "Date", "second", ")", "{", "Calendar", "c", "=", "Calendar", ".", "getInstance", "(", ")", ";", "int", "result", "=", "0", ";", "int", "compare", "=", "first", ".", "compareTo", ...
Get number of days between two dates @param first first date @param second second date @return number of days if first date less than second date, 0 if first date is bigger than second date, 1 if dates are the same
[ "Get", "number", "of", "days", "between", "two", "dates" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L332-L373
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.getElapsedTime
public static int[] getElapsedTime(Date first, Date second) { if (first.compareTo(second) == 1 ) { return null; } int difDays = 0; int difHours = 0; int difMinutes = 0; Calendar c = Calendar.getInstance(); c.setTime(first); int h1 = c.get(Calendar.HOUR_OF_DAY); int m1 = c.get(Calendar.MINUTE); c.setTime(second); int h2 = c.get(Calendar.HOUR_OF_DAY); int m2 = c.get(Calendar.MINUTE); if (sameDay(first, second)) { difHours = h2 - h1; } else { difDays = getNumberOfDays(first, second)-1; if (h1 >= h2) { difDays--; difHours = (24 - h1) + h2; } else { difHours = h2 - h1; } } if (m1 >= m2) { difHours--; difMinutes = (60 - m1) + m2; } else { difMinutes = m2 - m1; } int[] result = new int[3]; result[0] = difDays; result[1] = difHours; result[2] = difMinutes; return result; }
java
public static int[] getElapsedTime(Date first, Date second) { if (first.compareTo(second) == 1 ) { return null; } int difDays = 0; int difHours = 0; int difMinutes = 0; Calendar c = Calendar.getInstance(); c.setTime(first); int h1 = c.get(Calendar.HOUR_OF_DAY); int m1 = c.get(Calendar.MINUTE); c.setTime(second); int h2 = c.get(Calendar.HOUR_OF_DAY); int m2 = c.get(Calendar.MINUTE); if (sameDay(first, second)) { difHours = h2 - h1; } else { difDays = getNumberOfDays(first, second)-1; if (h1 >= h2) { difDays--; difHours = (24 - h1) + h2; } else { difHours = h2 - h1; } } if (m1 >= m2) { difHours--; difMinutes = (60 - m1) + m2; } else { difMinutes = m2 - m1; } int[] result = new int[3]; result[0] = difDays; result[1] = difHours; result[2] = difMinutes; return result; }
[ "public", "static", "int", "[", "]", "getElapsedTime", "(", "Date", "first", ",", "Date", "second", ")", "{", "if", "(", "first", ".", "compareTo", "(", "second", ")", "==", "1", ")", "{", "return", "null", ";", "}", "int", "difDays", "=", "0", ";"...
Get elapsedtime between two dates @param first first date @param second second date @return null if first date is after second date an integer array of three elemets ( days, hours minutes )
[ "Get", "elapsedtime", "between", "two", "dates" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L382-L423
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.addMinutes
public static Date addMinutes(Date d, int minutes) { Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.add(Calendar.MINUTE, minutes); return cal.getTime(); }
java
public static Date addMinutes(Date d, int minutes) { Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.add(Calendar.MINUTE, minutes); return cal.getTime(); }
[ "public", "static", "Date", "addMinutes", "(", "Date", "d", ",", "int", "minutes", ")", "{", "Calendar", "cal", "=", "Calendar", ".", "getInstance", "(", ")", ";", "cal", ".", "setTime", "(", "d", ")", ";", "cal", ".", "add", "(", "Calendar", ".", ...
Add minutes to a date @param d date @param minutes minutes @return new date
[ "Add", "minutes", "to", "a", "date" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L431-L436
train
nextreports/nextreports-engine
src/ro/nextreports/engine/util/DateUtil.java
DateUtil.setMinutes
public static Date setMinutes(Date d, int minutes) { Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.set(Calendar.MINUTE, minutes); return cal.getTime(); }
java
public static Date setMinutes(Date d, int minutes) { Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.set(Calendar.MINUTE, minutes); return cal.getTime(); }
[ "public", "static", "Date", "setMinutes", "(", "Date", "d", ",", "int", "minutes", ")", "{", "Calendar", "cal", "=", "Calendar", ".", "getInstance", "(", ")", ";", "cal", ".", "setTime", "(", "d", ")", ";", "cal", ".", "set", "(", "Calendar", ".", ...
Set minutes to a date @param d date @param minutes minutes @return new date
[ "Set", "minutes", "to", "a", "date" ]
a847575a9298b5fce63b88961190c5b83ddccc44
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L444-L449
train