idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
11,500
public static void initStaticDefaultParameterValues ( QueryParameter param , Map < String , Object > parameterValues ) throws QueryException { List < Serializable > defValues ; if ( ( param . getDefaultValues ( ) != null ) && ( param . getDefaultValues ( ) . size ( ) > 0 ) ) { defValues = param . getDefaultValues ( ) ; } else { throw new QueryException ( "Invalid use of method initStaticDefaultParameterValues : no static values for parameter " + param . getName ( ) ) ; } initDefaultParameterValues ( param , defValues , parameterValues ) ; }
Init parameter values map with the static default values of a parameter
11,501
public static void initAllRuntimeParameterValues ( Connection conn , QueryParameter param , Map < String , QueryParameter > map , Map < String , Object > parameterValues ) throws QueryException { List < IdName > allValues = new ArrayList < IdName > ( ) ; if ( ( param . getSource ( ) != null ) && ( ! param . getSource ( ) . trim ( ) . equals ( "" ) ) ) { try { allValues = ParameterUtil . getRuntimeParameterValues ( conn , param , map , parameterValues ) ; } catch ( Exception e ) { throw new QueryException ( e ) ; } } initAllRuntimeParameterValues ( param , allValues , parameterValues ) ; }
Init parameter values map with all the values from select source of a parameter at runtime
11,502
public static void initStaticNotHiddenDefaultParameterValues ( Report report , Map < String , Object > parameterValues ) throws QueryException { Map < String , QueryParameter > params = getUsedParametersMap ( report ) ; for ( QueryParameter qp : params . values ( ) ) { if ( ! qp . isHidden ( ) ) { initStaticDefaultParameterValues ( qp , parameterValues ) ; } } }
Init parameter values map with the static default values for all not - hidden parameters of a report
11,503
public static Map < String , QueryParameter > toMap ( List < QueryParameter > parameters ) { Map < String , QueryParameter > map = new HashMap < String , QueryParameter > ( ) ; for ( QueryParameter qp : parameters ) { map . put ( qp . getName ( ) , qp ) ; } return map ; }
Convert a list of QueryParameter object to a map where the key is the parameter name and the value is the parameter
11,504
public static Object getParameterValueFromStringWithPattern ( String parameterClass , String value , String pattern ) throws Exception { if ( pattern == null ) { return getParameterValueFromString ( parameterClass , value ) ; } else { if ( QueryParameter . DATE_VALUE . equals ( parameterClass ) || QueryParameter . TIME_VALUE . equals ( parameterClass ) || QueryParameter . TIMESTAMP_VALUE . equals ( parameterClass ) ) { SimpleDateFormat sdf = new SimpleDateFormat ( pattern ) ; return getParameterValueFromString ( parameterClass , value , sdf ) ; } else { return getParameterValueFromString ( parameterClass , value ) ; } } }
Get parameter value from a string represenation using a pattern
11,505
public static Map < String , QueryParameter > intersectParametersMap ( List < Report > reports ) { Map < String , QueryParameter > map = new LinkedHashMap < String , QueryParameter > ( ) ; if ( ( reports == null ) || ( reports . size ( ) == 0 ) ) { return map ; } if ( reports . size ( ) == 1 ) { return getUsedParametersMap ( reports . get ( 0 ) , false , false ) ; } Map < String , QueryParameter > firstParamMap = getUsedParametersMap ( reports . get ( 0 ) , false , false ) ; Map < String , QueryParameter > secondParamMap = getUsedParametersMap ( reports . get ( 1 ) , false , false ) ; map = intersectParametersMap ( firstParamMap , secondParamMap ) ; for ( int i = 2 , n = reports . size ( ) ; i < n ; i ++ ) { Map < String , QueryParameter > paramMap = getUsedParametersMap ( reports . get ( i ) , false , false ) ; map = intersectParametersMap ( map , paramMap ) ; if ( map . size ( ) == 0 ) { break ; } } return map ; }
Get a map with all the identical parameters for a list of reports
11,506
public int addSection ( String label , ListModel model ) { add ( new JLabel ( label ) ) ; add ( new JList ( model ) ) ; return getSectionCount ( ) - 1 ; }
Adds a section to this collapsible list .
11,507
public JList getSectionList ( int index ) { @ SuppressWarnings ( "unchecked" ) JList list = ( JList ) getComponent ( index * 2 + 1 ) ; return list ; }
Returns the list object associated with the specified section .
11,508
public void toggleCollapsed ( int index ) { JList list = getSectionList ( index ) ; list . setVisible ( ! list . isVisible ( ) ) ; }
Toggles the collapsed state of the specified section .
11,509
public Constructor < ? > findConstructor ( Class < ? > [ ] parameterTypes ) throws NoSuchMethodException { maybeLoadConstructors ( ) ; if ( parameterTypes == null ) { parameterTypes = new Class < ? > [ 0 ] ; } return ( Constructor < ? > ) findMemberIn ( _ctorList , parameterTypes ) ; }
Returns the most specific public constructor in my target class that accepts the number and type of parameters in the given Class array in a reflective invocation .
11,510
public Method findMethod ( String methodName , Class < ? > [ ] parameterTypes ) throws NoSuchMethodException { maybeLoadMethods ( ) ; List < Member > methodList = _methodMap . get ( methodName ) ; if ( methodList == null ) { throw new NoSuchMethodException ( "No method named " + _clazz . getName ( ) + "." + methodName ) ; } if ( parameterTypes == null ) { parameterTypes = new Class < ? > [ 0 ] ; } return ( Method ) findMemberIn ( methodList , parameterTypes ) ; }
Returns the most specific public method in my target class that has the given name and accepts the number and type of parameters in the given Class array in a reflective invocation .
11,511
protected void maybeLoadConstructors ( ) { if ( _ctorList == null ) { _ctorList = new ArrayList < Member > ( ) ; Constructor < ? > [ ] ctors = _clazz . getConstructors ( ) ; for ( int i = 0 ; i < ctors . length ; ++ i ) { _ctorList . add ( ctors [ i ] ) ; _paramMap . put ( ctors [ i ] , ctors [ i ] . getParameterTypes ( ) ) ; } } }
Loads up the data structures for my target class s constructors .
11,512
protected void maybeLoadMethods ( ) { if ( _methodMap == null ) { _methodMap = new HashMap < String , List < Member > > ( ) ; Method [ ] methods = _clazz . getMethods ( ) ; for ( int i = 0 ; i < methods . length ; ++ i ) { Method m = methods [ i ] ; String methodName = m . getName ( ) ; Class < ? > [ ] paramTypes = m . getParameterTypes ( ) ; List < Member > list = _methodMap . get ( methodName ) ; if ( list == null ) { list = new ArrayList < Member > ( ) ; _methodMap . put ( methodName , list ) ; } if ( ! ClassUtil . classIsAccessible ( _clazz ) ) { m = ClassUtil . getAccessibleMethodFrom ( _clazz , methodName , paramTypes ) ; } if ( m != null ) { list . add ( m ) ; _paramMap . put ( m , paramTypes ) ; } } } }
Loads up the data structures for my target class s methods .
11,513
public static < A , B > B foldLeft ( F < B , A > func , B zero , Iterable < ? extends A > values ) { for ( A value : values ) { zero = func . apply ( zero , value ) ; } return zero ; }
Left folds the supplied function over the supplied values using the supplied starting value .
11,514
public static < A > A reduceLeft ( F < A , A > func , Iterable < ? extends A > values ) { Iterator < ? extends A > iter = values . iterator ( ) ; A zero = iter . next ( ) ; while ( iter . hasNext ( ) ) { zero = func . apply ( zero , iter . next ( ) ) ; } return zero ; }
Reduces the supplied values using the supplied function with a left fold .
11,515
public static int sum ( int zero , Iterable < ? extends Number > values ) { for ( Number value : values ) { zero += value . intValue ( ) ; } return zero ; }
Sums the supplied collection of numbers to an int with a left to right fold .
11,516
public static long sum ( long zero , Iterable < ? extends Number > values ) { for ( Number value : values ) { zero += value . longValue ( ) ; } return zero ; }
Sums the supplied collection of numbers to a long with a left to right fold .
11,517
public static float sum ( float zero , Iterable < ? extends Number > values ) { for ( Number value : values ) { zero += value . floatValue ( ) ; } return zero ; }
Sums the supplied collection of numbers to a float with a left to right fold .
11,518
public static double sum ( double zero , Iterable < ? extends Number > values ) { for ( Number value : values ) { zero += value . doubleValue ( ) ; } return zero ; }
Sums the supplied collection of numbers to a double with a left to right fold .
11,519
public static BigInteger sum ( BigInteger zero , Iterable < ? extends BigInteger > values ) { for ( BigInteger value : values ) { zero = zero . add ( value ) ; } return zero ; }
Sums the supplied collection of numbers to a bigint with a left to right fold .
11,520
public static String truncate ( String text , int length , String append ) { return StringUtil . truncate ( text , length , append ) ; }
Truncates the supplied text at the specified length appending the specified elipsis indicator to the text if truncated .
11,521
public static String join ( String [ ] values , String sep ) { return StringUtil . join ( values , sep ) ; }
Joins the supplied strings with the given separator .
11,522
public static String copyright ( String holder , int startYear ) { Calendar cal = Calendar . getInstance ( ) ; int year = cal . get ( Calendar . YEAR ) ; return "&copy; " + holder + " " + startYear + "-" + year ; }
Generates a copyright string for the specified copyright holder from the specified first year to the current year .
11,523
public void render ( Component host , RadialMenu menu , Graphics2D gfx , int x , int y ) { paint ( gfx , x , y , menu ) ; }
Renders this menu item at the specified location .
11,524
public void addObject ( int x , int y , Object object ) { Record record = new Record ( x , y , object ) ; if ( _size == 0 ) { _records [ _size ++ ] = record ; return ; } int ipoint = binarySearch ( x ) ; if ( _size >= _records . length ) { int nsize = _size * 2 ; Record [ ] records = new Record [ nsize ] ; System . arraycopy ( _records , 0 , records , 0 , _size ) ; _records = records ; } if ( ipoint < _size ) { System . arraycopy ( _records , ipoint , _records , ipoint + 1 , _size - ipoint ) ; } _records [ ipoint ] = record ; _size ++ ; }
Adds an object to the tracker .
11,525
public static int distance ( int x1 , int y1 , int x2 , int y2 ) { int dx = x1 - x2 , dy = y1 - y2 ; return ( int ) Math . sqrt ( dx * dx + dy * dy ) ; }
Computes the geometric distance between the supplied two points .
11,526
protected int binarySearch ( int x ) { int low = 0 ; int high = _size - 1 ; while ( low <= high ) { int mid = ( low + high ) >>> 1 ; int cmp = ( _records [ mid ] . x - x ) ; if ( cmp < 0 ) { low = mid + 1 ; } else if ( cmp > 0 ) { high = mid - 1 ; } else { return mid ; } } return low ; }
Returns the index of a record with the specified x coordinate or a value representing the index where such a record would be inserted while preserving the sort order of the array . Doesn t work if the records array contains zero elements .
11,527
public static String compose ( String key , Object ... args ) { StringBuilder buf = new StringBuilder ( ) ; buf . append ( key ) ; buf . append ( '|' ) ; for ( int i = 0 ; i < args . length ; i ++ ) { if ( i > 0 ) { buf . append ( '|' ) ; } String arg = ( args [ i ] == null ) ? "" : String . valueOf ( args [ i ] ) ; int alength = arg . length ( ) ; for ( int p = 0 ; p < alength ; p ++ ) { char ch = arg . charAt ( p ) ; if ( ch == '|' ) { buf . append ( "\\!" ) ; } else if ( ch == '\\' ) { buf . append ( "\\\\" ) ; } else { buf . append ( ch ) ; } } } return buf . toString ( ) ; }
Composes a message key with an array of arguments . The message can subsequently be decomposed and translated without prior knowledge of how many arguments were provided .
11,528
public static String unescape ( String value ) { int bsidx = value . indexOf ( '\\' ) ; if ( bsidx == - 1 ) { return value ; } StringBuilder buf = new StringBuilder ( ) ; int vlength = value . length ( ) ; for ( int ii = 0 ; ii < vlength ; ii ++ ) { char ch = value . charAt ( ii ) ; if ( ch != '\\' || ii == vlength - 1 ) { buf . append ( ch ) ; } else { ch = value . charAt ( ++ ii ) ; buf . append ( ( ch == '!' ) ? '|' : ch ) ; } } return buf . toString ( ) ; }
Unescapes characters that are escaped in a call to compose .
11,529
public static String [ ] decompose ( String compoundKey ) { String [ ] args = compoundKey . split ( "\\|" ) ; for ( int ii = 0 ; ii < args . length ; ii ++ ) { args [ ii ] = unescape ( args [ ii ] ) ; } return args ; }
Decomposes a compound key into its constituent parts . Arguments that were tainted during composition will remain tainted .
11,530
public static String qualify ( String bundle , String key ) { if ( bundle . indexOf ( QUAL_PREFIX ) != - 1 || bundle . indexOf ( QUAL_SEP ) != - 1 ) { String errmsg = "Message bundle may not contain '" + QUAL_PREFIX + "' or '" + QUAL_SEP + "' [bundle=" + bundle + ", key=" + key + "]" ; throw new IllegalArgumentException ( errmsg ) ; } return QUAL_PREFIX + bundle + QUAL_SEP + key ; }
Returns a fully qualified message key which when translated by some other bundle will know to resolve and utilize the supplied bundle to translate this particular key .
11,531
public static String getBundle ( String qualifiedKey ) { if ( ! qualifiedKey . startsWith ( QUAL_PREFIX ) ) { throw new IllegalArgumentException ( qualifiedKey + " is not a fully qualified message key." ) ; } int qsidx = qualifiedKey . indexOf ( QUAL_SEP ) ; if ( qsidx == - 1 ) { throw new IllegalArgumentException ( qualifiedKey + " is not a valid fully qualified key." ) ; } return qualifiedKey . substring ( QUAL_PREFIX . length ( ) , qsidx ) ; }
Returns the bundle name from a fully qualified message key .
11,532
public static String getUnqualifiedKey ( String qualifiedKey ) { if ( ! qualifiedKey . startsWith ( QUAL_PREFIX ) ) { throw new IllegalArgumentException ( qualifiedKey + " is not a fully qualified message key." ) ; } int qsidx = qualifiedKey . indexOf ( QUAL_SEP ) ; if ( qsidx == - 1 ) { throw new IllegalArgumentException ( qualifiedKey + " is not a valid fully qualified key." ) ; } return qualifiedKey . substring ( qsidx + 1 ) ; }
Returns the unqualified portion of the key from a fully qualified message key .
11,533
public int createUser ( Username username , Password password , String realname , String email , int siteId ) throws UserExistsException , PersistenceException { User user = new User ( ) ; user . setDirtyMask ( _utable . getFieldMask ( ) ) ; populateUser ( user , username , password , realname , email , siteId ) ; return insertUser ( user ) ; }
Requests that a new user be created in the repository .
11,534
public User loadUserBySession ( String sessionKey ) throws PersistenceException { User user = load ( _utable , "sessions" , "where authcode = '" + sessionKey + "' " + "AND sessions.userId = users.userId" ) ; if ( user != null ) { user . setDirtyMask ( _utable . getFieldMask ( ) ) ; } return user ; }
Looks up a user by a session identifier .
11,535
public HashIntMap < User > loadUsersFromId ( int [ ] userIds ) throws PersistenceException { HashIntMap < User > data = new HashIntMap < User > ( ) ; if ( userIds . length > 0 ) { String query = "where userId in (" + genIdString ( userIds ) + ")" ; for ( User user : loadAll ( _utable , query ) ) { user . setDirtyMask ( _utable . getFieldMask ( ) ) ; data . put ( user . userId , user ) ; } } return data ; }
Looks up users by userid
11,536
public ArrayList < User > lookupUsersByEmail ( String email ) throws PersistenceException { return loadAll ( _utable , "where email = " + JDBCUtil . escape ( email ) ) ; }
Lookup a user by email address something that is not efficient and should really only be done by site admins attempting to look up a user record .
11,537
public ArrayList < User > lookupUsersWhere ( final String where ) throws PersistenceException { ArrayList < User > users = loadAll ( _utable , where ) ; for ( User user : users ) { user . setDirtyMask ( _utable . getFieldMask ( ) ) ; } return users ; }
Looks up a list of users that match an arbitrary query . Care should be taken in constructing these queries as the user table is likely to be large and a query that does not make use of indices could be very slow .
11,538
public boolean updateUser ( final User user ) throws PersistenceException { if ( ! user . getDirtyMask ( ) . isModified ( ) ) { return false ; } update ( _utable , user , user . getDirtyMask ( ) ) ; return true ; }
Updates a user that was previously fetched from the repository . Only fields that have been modified since it was loaded will be written to the database and those fields will subsequently be marked clean once again .
11,539
public void deleteUser ( final User user ) throws PersistenceException { if ( user . isDeleted ( ) ) { return ; } executeUpdate ( new Operation < Object > ( ) { public Object invoke ( Connection conn , DatabaseLiaison liaison ) throws PersistenceException , SQLException { FieldMask mask = _utable . getFieldMask ( ) ; mask . setModified ( "username" ) ; mask . setModified ( "password" ) ; mask . setModified ( "email" ) ; user . password = "" ; String newEmail = user . email . replace ( '@' , '#' ) ; user . email = newEmail ; String oldName = user . username ; for ( int ii = 0 ; ii < 100 ; ii ++ ) { try { user . username = StringUtil . truncate ( ii + "=" + oldName , 24 ) ; _utable . update ( conn , user , mask ) ; return null ; } catch ( SQLException se ) { if ( ! liaison . isDuplicateRowException ( se ) ) { throw se ; } } } throw new PersistenceException ( "Failed to 'delete' the user" ) ; } } ) ; }
Delete the users account such that they can no longer access it however we do not delete the record from the db . The name is changed such that the original name has XX = FOO if the name were FOO originally . If we have to lop off any of the name to get our prefix to fit we use a minus sign instead of a equals side . The password field is set to be the empty string so that no one can log in ( since nothing hashes to the empty string . We also make sure their email address no longer works so in case we don t ignore deleted users when we do the sql to get emailaddresses for the mass mailings we still won t spam delete folk . We leave the emailaddress intact exect for the
11,540
public String registerSession ( User user , int expireDays ) throws PersistenceException { final String query = "select authcode from sessions where userId = " + user . userId ; String authcode = execute ( new Operation < String > ( ) { public String invoke ( Connection conn , DatabaseLiaison liaison ) throws PersistenceException , SQLException { Statement stmt = conn . createStatement ( ) ; try { ResultSet rs = stmt . executeQuery ( query ) ; while ( rs . next ( ) ) { return rs . getString ( 1 ) ; } return null ; } finally { JDBCUtil . close ( stmt ) ; } } } ) ; Calendar cal = Calendar . getInstance ( ) ; cal . add ( Calendar . DATE , expireDays ) ; Date expires = new Date ( cal . getTime ( ) . getTime ( ) ) ; if ( authcode != null ) { update ( "update sessions set expires = '" + expires + "' where " + "authcode = '" + authcode + "'" ) ; } else { authcode = UserUtil . genAuthCode ( user ) ; update ( "insert into sessions (authcode, userId, expires) values('" + authcode + "', " + user . userId + ", '" + expires + "')" ) ; } return authcode ; }
Creates a new session for the specified user and returns the randomly generated session identifier for that session . If a session entry already exists for the specified user it will be reused .
11,541
public boolean refreshSession ( String sessionKey , int expireDays ) throws PersistenceException { Calendar cal = Calendar . getInstance ( ) ; cal . add ( Calendar . DATE , expireDays ) ; Date expires = new Date ( cal . getTime ( ) . getTime ( ) ) ; return ( update ( "update sessions set expires = '" + expires + "' " + "where authcode = " + JDBCUtil . escape ( sessionKey ) ) == 1 ) ; }
Validates that the supplied session key is still valid and if so refreshes it for the specified number of days .
11,542
public String [ ] loadAllRealNames ( ) throws PersistenceException { final ArrayList < String > names = new ArrayList < String > ( ) ; execute ( new Operation < Object > ( ) { public Object invoke ( Connection conn , DatabaseLiaison liaison ) throws PersistenceException , SQLException { Statement stmt = conn . createStatement ( ) ; try { String query = "select realname from users" ; ResultSet rs = stmt . executeQuery ( query ) ; while ( rs . next ( ) ) { names . add ( rs . getString ( 1 ) ) ; } return null ; } finally { JDBCUtil . close ( stmt ) ; } } } ) ; return names . toArray ( new String [ names . size ( ) ] ) ; }
Returns an array with the real names of every user in the system .
11,543
protected void populateUser ( User user , Username name , Password pass , String realname , String email , int siteId ) { user . username = name . getUsername ( ) ; user . setPassword ( pass ) ; user . setRealName ( realname ) ; user . setEmail ( email ) ; user . created = new Date ( System . currentTimeMillis ( ) ) ; user . setSiteId ( siteId ) ; }
Configures the supplied user record with the provided information in preparation for inserting the record into the database for the first time .
11,544
protected int insertUser ( final User user ) throws UserExistsException , PersistenceException { executeUpdate ( new Operation < Object > ( ) { public Object invoke ( Connection conn , DatabaseLiaison liaison ) throws PersistenceException , SQLException { try { _utable . insert ( conn , user ) ; user . userId = liaison . lastInsertedId ( conn , null , _utable . getName ( ) , "userId" ) ; return null ; } catch ( SQLException sqe ) { if ( liaison . isDuplicateRowException ( sqe ) ) { throw new UserExistsException ( "error.user_exists" ) ; } else { throw sqe ; } } } } ) ; return user . userId ; }
Inserts the supplied user record into the user database assigning it a userid in the process which is returned .
11,545
protected User loadUserWhere ( String where ) throws PersistenceException { User user = load ( _utable , where ) ; if ( user != null ) { user . setDirtyMask ( _utable . getFieldMask ( ) ) ; } return user ; }
Loads up a user record that matches the specified where clause . Returns null if no record matches .
11,546
public static synchronized void setToggling ( AbstractButton b ) { if ( _toggler == null ) { _toggler = new ActionListener ( ) { public void actionPerformed ( ActionEvent event ) { AbstractButton but = ( AbstractButton ) event . getSource ( ) ; but . setSelected ( ! but . isSelected ( ) ) ; } } ; } b . addActionListener ( _toggler ) ; }
Set the specified button such that it alternates between being selected and not whenever it is pushed .
11,547
public static ActionListener cycleToProperty ( final String property , final PrefsConfig config , AbstractButton button , final int [ ] values ) { ActionListener al = new ActionListener ( ) { public void actionPerformed ( ActionEvent event ) { int oldval = config . getValue ( property , values [ 0 ] ) ; int newidx = ( 1 + IntListUtil . indexOf ( values , oldval ) ) % values . length ; config . setValue ( property , values [ newidx ] ) ; } } ; button . addActionListener ( al ) ; return al ; }
Configure the specified button to cause the specified property to cycle through the specified values whenever the button is pressed .
11,548
public boolean createTableIfMissing ( Connection conn , String table , List < String > columns , List < ColumnDefinition > defns , List < List < String > > uniqueColumns , List < String > pkColumns ) throws SQLException { if ( columns . size ( ) != defns . size ( ) ) { throw new IllegalArgumentException ( "Column name and definition number mismatch" ) ; } Set < String > seenUniques = new HashSet < String > ( ) ; if ( uniqueColumns != null ) { for ( List < String > udef : uniqueColumns ) { if ( udef . size ( ) == 1 ) { seenUniques . addAll ( udef ) ; } } } seenUniques . addAll ( pkColumns ) ; List < List < String > > newUniques = uniqueColumns ; List < ColumnDefinition > newDefns = new ArrayList < ColumnDefinition > ( defns . size ( ) ) ; for ( int ii = 0 ; ii < defns . size ( ) ; ii ++ ) { ColumnDefinition def = defns . get ( ii ) ; if ( ! def . unique ) { newDefns . add ( def ) ; continue ; } newDefns . add ( new ColumnDefinition ( def . type , def . nullable , false , def . defaultValue ) ) ; if ( ! seenUniques . contains ( columns . get ( ii ) ) ) { if ( newUniques == uniqueColumns ) { newUniques = new ArrayList < List < String > > ( uniqueColumns ) ; } newUniques . add ( Collections . singletonList ( columns . get ( ii ) ) ) ; } } return super . createTableIfMissing ( conn , table , columns , newDefns , newUniques , pkColumns ) ; }
it may be that uniqueness should be removed from ColumnDefinition .
11,549
private boolean canAddTableToFromClause ( Table table , Map < Table , List < JoinCriteria > > destMap , List < Table > allTables ) { if ( ( table == null ) || allTables . contains ( table ) ) { return false ; } if ( ( destMap . get ( table ) != null ) && ( destMap . get ( table ) . size ( ) > 0 ) ) { List < JoinCriteria > list = destMap . get ( table ) ; for ( JoinCriteria jc : list ) { if ( JoinType . isOuter ( jc . getJoinType ( ) ) ) { return false ; } } } return true ; }
outer joins are written in Table class
11,550
public static < T > void sort ( T [ ] a , Comparator < ? super T > comp ) { sort ( a , 0 , a . length - 1 , comp ) ; }
Sorts the supplied array of objects from least to greatest using the supplied comparator .
11,551
public static < T extends Comparable < ? super T > > void sort ( T [ ] a ) { sort ( a , 0 , a . length - 1 ) ; }
Sorts the supplied array of comparable objects from least to greatest .
11,552
public static < T > void rsort ( T [ ] a , Comparator < ? super T > comp ) { rsort ( a , 0 , a . length - 1 , comp ) ; }
Sorts the supplied array of objects from greatest to least using the supplied comparator .
11,553
public static < T extends Comparable < ? super T > > void rsort ( T [ ] a ) { rsort ( a , 0 , a . length - 1 ) ; }
Sorts the supplied array of comparable objects from greatest to least .
11,554
public static < T > void sort ( T [ ] a , int lo0 , int hi0 , Comparator < ? super T > comp ) { if ( hi0 <= lo0 ) { return ; } T t ; if ( hi0 - lo0 == 1 ) { if ( comp . compare ( a [ hi0 ] , a [ lo0 ] ) < 0 ) { t = a [ lo0 ] ; a [ lo0 ] = a [ hi0 ] ; a [ hi0 ] = t ; } return ; } T mid = a [ ( lo0 + hi0 ) >>> 1 ] ; int lo = lo0 - 1 , hi = hi0 + 1 ; for ( ; ; ) { while ( comp . compare ( a [ ++ lo ] , mid ) < 0 ) { } while ( comp . compare ( mid , a [ -- hi ] ) < 0 ) { } if ( hi > lo ) { t = a [ lo ] ; a [ lo ] = a [ hi ] ; a [ hi ] = t ; } else { break ; } } if ( lo0 < lo - 1 ) { sort ( a , lo0 , lo - 1 , comp ) ; } if ( hi + 1 < hi0 ) { sort ( a , hi + 1 , hi0 , comp ) ; } }
Sorts the specified subset of the supplied array from least to greatest using the supplied comparator .
11,555
public static < T extends Comparable < ? super T > > void sort ( T [ ] a , int lo0 , int hi0 ) { if ( hi0 <= lo0 ) { return ; } T t ; if ( hi0 - lo0 == 1 ) { if ( a [ lo0 ] . compareTo ( a [ hi0 ] ) > 0 ) { t = a [ lo0 ] ; a [ lo0 ] = a [ hi0 ] ; a [ hi0 ] = t ; } return ; } T mid = a [ ( lo0 + hi0 ) >>> 1 ] ; int lo = lo0 - 1 , hi = hi0 + 1 ; for ( ; ; ) { while ( mid . compareTo ( a [ ++ lo ] ) > 0 ) { } while ( mid . compareTo ( a [ -- hi ] ) < 0 ) { } if ( hi > lo ) { t = a [ lo ] ; a [ lo ] = a [ hi ] ; a [ hi ] = t ; } else { break ; } } if ( lo0 < lo - 1 ) { sort ( a , lo0 , lo - 1 ) ; } if ( hi + 1 < hi0 ) { sort ( a , hi + 1 , hi0 ) ; } }
Sorts the specified subset of the supplied array of comparables from least to greatest using the supplied comparator .
11,556
public static < T extends Comparable < ? super T > > void sort ( List < T > a ) { sort ( a , new Comparator < T > ( ) { public int compare ( T o1 , T o2 ) { if ( o1 == o2 ) { return 0 ; } else if ( o1 == null ) { return 1 ; } else if ( o2 == null ) { return - 1 ; } return o1 . compareTo ( o2 ) ; } } ) ; }
Sort the elements in the specified List according to their natural order .
11,557
public static < T > void sort ( List < T > a , Comparator < ? super T > comp ) { sort ( a , 0 , a . size ( ) - 1 , comp ) ; }
Sort the elements in the specified List according to the ordering imposed by the specified Comparator .
11,558
public static < T > void rsort ( List < T > a , Comparator < ? super T > comp ) { sort ( a , Collections . reverseOrder ( comp ) ) ; }
Sort the elements in the specified List according to the reverse ordering imposed by the specified Comparator .
11,559
public static < T > void sort ( List < T > a , int lo0 , int hi0 , Comparator < ? super T > comp ) { if ( hi0 <= lo0 ) { return ; } T e1 , e2 ; if ( hi0 - lo0 == 1 ) { e1 = a . get ( lo0 ) ; e2 = a . get ( hi0 ) ; if ( comp . compare ( e2 , e1 ) < 0 ) { a . set ( hi0 , e1 ) ; a . set ( lo0 , e2 ) ; } return ; } T mid = a . get ( ( lo0 + hi0 ) >>> 1 ) ; int lo = lo0 - 1 , hi = hi0 + 1 ; for ( ; ; ) { do { e1 = a . get ( ++ lo ) ; } while ( comp . compare ( e1 , mid ) < 0 ) ; do { e2 = a . get ( -- hi ) ; } while ( comp . compare ( mid , e2 ) < 0 ) ; if ( hi > lo ) { a . set ( lo , e2 ) ; a . set ( hi , e1 ) ; } else { break ; } } if ( lo0 < lo - 1 ) { sort ( a , lo0 , lo - 1 , comp ) ; } if ( hi + 1 < hi0 ) { sort ( a , hi + 1 , hi0 , comp ) ; } }
Sort a subset of the elements in the specified List according to the ordering imposed by the specified Comparator .
11,560
@ ReplacedBy ( "com.google.common.collect.Iterators#concat() or com.google.common.collect.Iterables#concat()" ) public static < T > Iterator < T > getMetaIterator ( Iterable < Iterator < T > > metaIterable ) { return new MetaIterator < T > ( metaIterable ) ; }
Returns an Iterator that iterates over all the elements contained within the Iterators within the specified Iterable .
11,561
public static < T extends Comparable < ? super T > > Iterator < T > getSortedIterator ( Iterable < T > coll ) { return getSortedIterator ( coll . iterator ( ) , new Comparator < T > ( ) { public int compare ( T o1 , T o2 ) { if ( o1 == o2 ) { return 0 ; } else if ( o1 == null ) { return 1 ; } else if ( o2 == null ) { return - 1 ; } return o1 . compareTo ( o2 ) ; } } ) ; }
Get an Iterator over the supplied Collection that returns the elements in their natural order .
11,562
public static < T > Iterator < T > getSortedIterator ( Iterable < T > coll , Comparator < T > comparator ) { return getSortedIterator ( coll . iterator ( ) , comparator ) ; }
Get an Iterator over the supplied Collection that returns the elements in the order dictated by the supplied Comparator .
11,563
public static < T extends Comparable < ? super T > > Iterator < T > getSortedIterator ( Iterator < T > itr ) { return getSortedIterator ( itr , new Comparator < T > ( ) { public int compare ( T o1 , T o2 ) { if ( o1 == o2 ) { return 0 ; } else if ( o1 == null ) { return 1 ; } else if ( o2 == null ) { return - 1 ; } return o1 . compareTo ( o2 ) ; } } ) ; }
Get an Iterator that returns the same elements returned by the supplied Iterator but in their natural order .
11,564
public static < T > Iterator < T > getSortedIterator ( Iterator < T > itr , Comparator < T > comparator ) { SortableArrayList < T > list = new SortableArrayList < T > ( ) ; CollectionUtil . addAll ( list , itr ) ; list . sort ( comparator ) ; return getUnmodifiableIterator ( list ) ; }
Get an Iterator that returns the same elements returned by the supplied Iterator but in the order dictated by the supplied Comparator .
11,565
public static < T > Iterator < T > getRandomIterator ( Iterable < T > c ) { return getRandomIterator ( c . iterator ( ) ) ; }
Get an Iterator over the supplied Iterable that returns the elements in a completely random order . Normally Iterators return elements in an undefined order but it is usually the same between different invocations as long as the underlying Iterable has not changed . This method mixes things up .
11,566
public static < T > Iterator < T > getRandomIterator ( Iterator < T > itr ) { ArrayList < T > list = new ArrayList < T > ( ) ; CollectionUtil . addAll ( list , itr ) ; java . util . Collections . shuffle ( list ) ; return getUnmodifiableIterator ( list ) ; }
Get an Iterator that returns the same elements returned by the supplied Iterator but in a completely random order .
11,567
public static < T > Iterator < T > getUnmodifiableIterator ( Iterable < T > c ) { return getUnmodifiableIterator ( c . iterator ( ) ) ; }
Get an Iterator that returns the elements in the supplied Iterable but blocks removal .
11,568
@ ReplacedBy ( "com.google.common.collect.Iterators#unmodifiableIterator()" ) public static < T > Iterator < T > getUnmodifiableIterator ( final Iterator < T > itr ) { return new Iterator < T > ( ) { public boolean hasNext ( ) { return itr . hasNext ( ) ; } public T next ( ) { return itr . next ( ) ; } public void remove ( ) { throw new UnsupportedOperationException ( "Cannot remove from an UnmodifiableIterator!" ) ; } } ; }
Get an iterator that returns the same elements as the supplied iterator but blocks removal .
11,569
public static Object unmarshal ( Class < ? > type , String source ) throws Exception { if ( type . isEnum ( ) ) { @ SuppressWarnings ( "unchecked" ) Class < Dummy > etype = ( Class < Dummy > ) type ; return Enum . valueOf ( etype , source ) ; } Parser parser = _parsers . get ( type ) ; if ( parser == null ) { throw new Exception ( "Don't know how to convert strings into values of type '" + type + "'." ) ; } return parser . parse ( source ) ; }
Attempts to convert the specified value to an instance of the specified object type .
11,570
protected final void rangeCheck ( int index , boolean insert ) { if ( ( index < 0 ) || ( insert ? ( index > _size ) : ( index >= _size ) ) ) { throw new IndexOutOfBoundsException ( "Index: " + index + ", Size: " + _size ) ; } }
Check the range of a passed - in index to make sure it s valid .
11,571
public Class getValueClass ( ) { if ( valueClass == null ) { if ( valueClassName != null ) { try { valueClass = Class . forName ( valueClassName ) ; } catch ( ClassNotFoundException e ) { throw new RuntimeException ( e ) ; } } } return valueClass ; }
Get java class object for the parameter value
11,572
public void setPreviewValue ( String previewValue ) { if ( ! isProcedureParameter && ( previewValue != null ) ) { throw new IllegalArgumentException ( "Parameter '" + name + "' is not a procedure parameter." ) ; } this . previewValue = previewValue ; }
Set preview value for procedure parameter Allows to set null for any type
11,573
public String getValue ( String name , String defval ) { return _props . getProperty ( name , defval ) ; }
Fetches and returns the value for the specified configuration property . If the value is not specified in the associated properties file the supplied default value is returned instead .
11,574
public Object instantiateValue ( String name , String defcname ) throws Exception { return Class . forName ( getValue ( name , defcname ) ) . newInstance ( ) ; }
Looks up the specified string - valued configuration entry loads the class with that name and instantiates a new instance of that class which is returned .
11,575
public Iterator < String > keys ( ) { HashSet < String > matches = new HashSet < String > ( ) ; enumerateKeys ( matches ) ; return matches . iterator ( ) ; }
Returns an iterator that returns all of the configuration keys in this config object .
11,576
private void put ( PrintStream p , String s , int column , int colSpan , BandElement bandElement ) { if ( s == null ) { put ( p , "" , column , colSpan , bandElement ) ; return ; } int size = 0 ; if ( colSpan > 1 ) { for ( int i = column ; i < column + colSpan ; i ++ ) { size += columnWidth [ i ] ; } } else { size = columnWidth [ column ] ; } if ( ( bandElement != null ) && bandElement . getHorizontalAlign ( ) == BandElement . RIGHT ) { p . print ( String . format ( "%" + size + "s" , s ) ) ; } else { p . print ( String . format ( "%-" + size + "s" , s ) ) ; } }
Write one tsv field to the file followed by a separator unless it is the last field on the line . Lead and trailing blanks will be removed .
11,577
protected static PropRecord parseMetaData ( String path , URL sourceURL ) throws IOException { InputStream input = sourceURL . openStream ( ) ; BufferedReader bin = new BufferedReader ( new InputStreamReader ( input ) ) ; try { PropRecord record = new PropRecord ( path , sourceURL ) ; boolean started = false ; String line ; while ( ( line = bin . readLine ( ) ) != null ) { if ( line . startsWith ( PACKAGE_KEY ) ) { record . _package = parseValue ( line ) ; started = true ; } else if ( line . startsWith ( EXTENDS_KEY ) ) { record . _extends = parseValue ( line ) ; started = true ; } else if ( line . startsWith ( OVERRIDES_KEY ) ) { record . _overrides = parseValues ( line ) ; started = true ; } else if ( started ) { break ; } } return record ; } finally { StreamUtil . close ( bin ) ; } }
Performs simple processing of the supplied input stream to obtain inheritance metadata from the properties file .
11,578
public static InputStream getStream ( String path , ClassLoader loader ) { InputStream in = getResourceAsStream ( path , loader ) ; if ( in != null ) { return in ; } try { ClassLoader sysloader = ClassLoader . getSystemClassLoader ( ) ; if ( sysloader != loader ) { return getResourceAsStream ( path , loader ) ; } } catch ( AccessControlException ace ) { } return null ; }
Returns an input stream referencing a file that exists somewhere in the classpath .
11,579
public boolean waitForResponse ( ) throws TimeoutException { if ( _success == 0 ) { synchronized ( this ) { try { if ( _timeout == NO_TIMEOUT ) { wait ( ) ; } else { wait ( 1000L * _timeout ) ; } if ( _success == 0 ) { throw new TimeoutException ( ) ; } } catch ( InterruptedException ie ) { throw ( TimeoutException ) new TimeoutException ( ) . initCause ( ie ) ; } } } return ( _success > 0 ) ; }
Blocks waiting for the response .
11,580
public static final < T > T silenceDeepCopy ( T object ) { try { return deepCopy ( object ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; throw new RuntimeException ( e ) ; } }
Throws a RuntimeException if an exception occurs .
11,581
public final boolean isModified ( ) { int mcount = _modified . length ; for ( int ii = 0 ; ii < mcount ; ii ++ ) { if ( _modified [ ii ] ) { return true ; } } return false ; }
Returns true if any of the fields in this mask are modified .
11,582
public final boolean isModified ( String fieldName ) { Integer index = _descripMap . get ( fieldName ) ; if ( index == null ) { throw new IllegalArgumentException ( "Field not in mask: " + fieldName ) ; } return _modified [ index . intValue ( ) ] ; }
Returns true if the field with the specified name is modifed .
11,583
public final boolean onlySubsetModified ( Set < String > fieldSet ) { for ( String field : _descripMap . keySet ( ) ) { if ( isModified ( field ) && ( ! fieldSet . contains ( field ) ) ) { return false ; } } return true ; }
Returns true only if the set of modified fields is a subset of the fields specified .
11,584
public void setModified ( String fieldName ) { Integer index = _descripMap . get ( fieldName ) ; if ( index == null ) { throw new IllegalArgumentException ( "Field not in mask: " + fieldName ) ; } _modified [ index . intValue ( ) ] = true ; }
Marks the specified field as modified .
11,585
public void addValue ( int value ) { if ( value < _minValue ) { _buckets [ 0 ] ++ ; } else if ( value >= _maxValue ) { _buckets [ _buckets . length - 1 ] ++ ; } else { _buckets [ ( value - _minValue ) / _bucketWidth ] ++ ; } _count ++ ; }
Registers a value with this histogram .
11,586
public String summarize ( ) { StringBuilder buf = new StringBuilder ( ) ; buf . append ( _count ) . append ( ":" ) ; for ( int ii = 0 ; ii < _buckets . length ; ii ++ ) { if ( ii > 0 ) { buf . append ( "," ) ; } buf . append ( _buckets [ ii ] ) ; } return buf . toString ( ) ; }
Generates a terse summary of the count and contents of the values in this histogram .
11,587
public < E extends T > Iterator < E > filter ( final Iterator < E > input ) { return new Iterator < E > ( ) { public boolean hasNext ( ) { return _found || findNext ( ) ; } public E next ( ) { if ( _found || findNext ( ) ) { _found = false ; return _last ; } else { throw new NoSuchElementException ( ) ; } } public void remove ( ) { if ( _removeable ) { _removeable = false ; input . remove ( ) ; } else { throw new IllegalStateException ( ) ; } } private boolean findNext ( ) { boolean result = false ; while ( input . hasNext ( ) ) { E candidate = input . next ( ) ; if ( isMatch ( candidate ) ) { _last = candidate ; result = true ; break ; } } _found = result ; _removeable = result ; return result ; } private E _last ; private boolean _found ; private boolean _removeable ; } ; }
Return a new iterator that contains only matching elements from the input iterator .
11,588
public < E extends T > void filter ( Collection < E > coll ) { for ( Iterator < E > itr = coll . iterator ( ) ; itr . hasNext ( ) ; ) { if ( ! isMatch ( itr . next ( ) ) ) { itr . remove ( ) ; } } }
Remove non - matching elements from the specified collection .
11,589
public < E extends T > Iterable < E > createView ( final Iterable < E > input ) { return new Iterable < E > ( ) { public Iterator < E > iterator ( ) { return filter ( input . iterator ( ) ) ; } } ; }
Create an Iterable view of the specified Iterable that only contains elements that match the predicate . This Iterable can be iterated over at any time in the future to view the current predicate - matching elements of the input Iterable .
11,590
public < E extends T > Collection < E > createView ( final Collection < E > input ) { return new AbstractCollection < E > ( ) { public int size ( ) { int size = 0 ; for ( Iterator < E > iter = iterator ( ) ; iter . hasNext ( ) ; ) { iter . next ( ) ; size ++ ; } return size ; } public boolean add ( E element ) { return input . add ( element ) ; } public boolean remove ( Object element ) { return input . remove ( element ) ; } public boolean contains ( Object element ) { try { @ SuppressWarnings ( "unchecked" ) E elem = ( E ) element ; return isMatch ( elem ) && input . contains ( elem ) ; } catch ( ClassCastException cce ) { return false ; } } public Iterator < E > iterator ( ) { return filter ( input . iterator ( ) ) ; } } ; }
Create a view of the specified collection that only contains elements that match the predicate . This collection can be examined at any time in the future to view the current predicate - matching elements of the input collection .
11,591
public static Builder at ( long millis ) { Calendar calendar = Calendar . getInstance ( ) ; calendar . setTimeInMillis ( millis ) ; return with ( calendar ) ; }
Returns a fluent wrapper around a calendar configured with the specified time .
11,592
public static Builder at ( int year , int month , int day ) { Calendar calendar = Calendar . getInstance ( ) ; calendar . set ( year , month , day ) ; return with ( calendar ) . zeroTime ( ) ; }
Returns a fluent wrapper around a calendar configured to zero milliseconds after midnight on the specified day in the specified month and year .
11,593
public static Builder in ( TimeZone zone , Locale locale ) { return with ( Calendar . getInstance ( zone , locale ) ) ; }
Returns a fluent wrapper around a calendar for the specifed time zone and locale .
11,594
public RadialMenuItem addMenuItem ( String command , String label , Image icon , Predicate predicate ) { RadialMenuItem item = new RadialMenuItem ( command , label , new ImageIcon ( icon ) , predicate ) ; addMenuItem ( item ) ; return item ; }
Adds a menu item to the menu . The menu should not currently be active .
11,595
public boolean removeMenuItem ( String command ) { int icount = _items . size ( ) ; for ( int i = 0 ; i < icount ; i ++ ) { RadialMenuItem item = _items . get ( i ) ; if ( item . command . equals ( command ) ) { _items . remove ( i ) ; return true ; } } return false ; }
Removes the first menu item that matches the specified command from this menu .
11,596
public void deactivate ( ) { if ( _host != null ) { Component comp = _host . getComponent ( ) ; comp . removeMouseListener ( this ) ; comp . removeMouseMotionListener ( this ) ; if ( _hijacker != null ) { _hijacker . release ( ) ; _hijacker = null ; } _host . menuDeactivated ( this ) ; repaint ( ) ; } _host = null ; _tbounds = null ; _argument = null ; _actlist . clear ( ) ; }
Deactivates the menu .
11,597
public void render ( Graphics2D gfx ) { Component host = _host . getComponent ( ) ; int x = _bounds . x , y = _bounds . y ; if ( _centerLabel != null ) { _centerLabel . paint ( gfx , x + _centerLabel . closedBounds . x , y + _centerLabel . closedBounds . y , this ) ; } int icount = _items . size ( ) ; for ( int i = 0 ; i < icount ; i ++ ) { RadialMenuItem item = _items . get ( i ) ; if ( ! item . isIncluded ( this ) ) { continue ; } if ( item != _activeItem ) { item . render ( host , this , gfx , x + item . closedBounds . x , y + item . closedBounds . y ) ; } } if ( _activeItem != null ) { _activeItem . render ( host , this , gfx , x + _activeItem . closedBounds . x , y + _activeItem . closedBounds . y ) ; } }
Renders the current configuration of this menu .
11,598
protected void repaint ( ) { _host . repaintRect ( _bounds . x , _bounds . y , _bounds . width + 1 , _bounds . height + 1 ) ; }
Requests that our host component repaint the part of itself that we occupy .
11,599
public static String currency ( double value , Locale locale ) { return currency ( value , NumberFormat . getCurrencyInstance ( locale ) ) ; }
Converts a number representing currency in the specified locale to a displayable string .