idx
int64
0
34.9k
question
stringlengths
12
26.4k
target
stringlengths
15
2.3k
200
public boolean showJoinPartAndQuit ( ) { return preferences . getBoolean ( resources . getString ( R . string . key_show_joinpartquit ) , Boolean . parseBoolean ( resources . getString ( R . string . default_show_joinpartquit ) ) ) ; }
Should join, part and quit messages be displayed?
201
public void reset ( ) { lastMtd = null ; map . clear ( ) ; loadCnt . set ( 0 ) ; putCnt . set ( 0 ) ; putAllCnt . set ( 0 ) ; ts = System . currentTimeMillis ( ) ; txs . clear ( ) ; }
Resets the store to initial state.
202
public static Configuration load ( InputStream stream ) throws IOException { try { Properties properties = new Properties ( ) ; properties . load ( stream ) ; return from ( properties ) ; } finally { stream . close ( ) ; } }
Obtain a configuration instance by loading the Properties from the supplied stream.
203
private static String encode_base64 ( final byte d [ ] , final int len ) throws IllegalArgumentException { int off = 0 ; final StringBuffer rs = new StringBuffer ( ) ; int c1 , c2 ; if ( len <= 0 || len > d . length ) { throw new IllegalArgumentException ( "Invalid len" ) ; } while ( off < len ) { c1 = d [ off ++ ] & 0xff ; rs . append ( base64_code [ c1 > > 2 & 0x3f ] ) ; c1 = ( c1 & 0x03 ) << 4 ; if ( off >= len ) { rs . append ( base64_code [ c1 & 0x3f ] ) ; break ; } c2 = d [ off ++ ] & 0xff ; c1 |= c2 > > 4 & 0x0f ; rs . append ( base64_code [ c1 & 0x3f ] ) ; c1 = ( c2 & 0x0f ) << 2 ; if ( off >= len ) { rs . append ( base64_code [ c1 & 0x3f ] ) ; break ; } c2 = d [ off ++ ] & 0xff ; c1 |= c2 > > 6 & 0x03 ; rs . append ( base64_code [ c1 & 0x3f ] ) ; rs . append ( base64_code [ c2 & 0x3f ] ) ; } return rs . toString ( ) ; }
Encode a byte array using bcrypt's slightly-modified base64 encoding scheme. Note that this is *not* compatible with the standard MIME-base64 encoding.
204
protected byte readByteProtected ( DataInputStream istream ) throws java . io . IOException { while ( true ) { int nchars ; nchars = istream . read ( rcvBuffer , 0 , 1 ) ; if ( nchars > 0 ) { return rcvBuffer [ 0 ] ; } } }
Read a single byte, protecting against various timeouts, etc. <P> When a gnu.io port is set to have a receive timeout (via the enableReceiveTimeout() method), some will return zero bytes or an EOFException at the end of the timeout. In that case, the read should be repeated to get the next real character.
205
public JSONException ( Throwable cause ) { super ( cause . getMessage ( ) ) ; this . cause = cause ; }
Constructs a new JSONException with the specified cause.
206
public static PcRunner serializableInstance ( ) { return PcRunner . serializableInstance ( ) ; }
Generates a simple exemplar of this class to test serialization.
207
public void drawFigure ( Graphics2D g ) { AffineTransform savedTransform = null ; if ( get ( TRANSFORM ) != null ) { savedTransform = g . getTransform ( ) ; g . transform ( get ( TRANSFORM ) ) ; } Paint paint = SVGAttributeKeys . getFillPaint ( this ) ; if ( paint != null ) { g . setPaint ( paint ) ; drawFill ( g ) ; } paint = SVGAttributeKeys . getStrokePaint ( this ) ; if ( paint != null && get ( STROKE_WIDTH ) > 0 ) { g . setPaint ( paint ) ; g . setStroke ( SVGAttributeKeys . getStroke ( this ) ) ; drawStroke ( g ) ; } if ( get ( TRANSFORM ) != null ) { g . setTransform ( savedTransform ) ; } }
This method is invoked before the rendered image of the figure is composited.
208
protected Object [ ] parseArguments ( final byte [ ] theBytes ) { Object [ ] myArguments = new Object [ 0 ] ; int myTagIndex = 0 ; int myIndex = 0 ; myArguments = new Object [ _myTypetag . length ] ; isArray = ( _myTypetag . length > 0 ) ? true : false ; while ( myTagIndex < _myTypetag . length ) { if ( myTagIndex == 0 ) { _myArrayType = _myTypetag [ myTagIndex ] ; } else { if ( _myTypetag [ myTagIndex ] != _myArrayType ) { isArray = false ; } } switch ( _myTypetag [ myTagIndex ] ) { case ( 0x63 ) : myArguments [ myTagIndex ] = ( new Character ( ( char ) ( Bytes . toInt ( Bytes . copy ( theBytes , myIndex , 4 ) ) ) ) ) ; myIndex += 4 ; break ; case ( 0x69 ) : myArguments [ myTagIndex ] = ( new Integer ( Bytes . toInt ( Bytes . copy ( theBytes , myIndex , 4 ) ) ) ) ; myIndex += 4 ; break ; case ( 0x66 ) : myArguments [ myTagIndex ] = ( new Float ( Bytes . toFloat ( Bytes . copy ( theBytes , myIndex , 4 ) ) ) ) ; myIndex += 4 ; break ; case ( 0x6c ) : case ( 0x68 ) : myArguments [ myTagIndex ] = ( new Long ( Bytes . toLong ( Bytes . copy ( theBytes , myIndex , 8 ) ) ) ) ; myIndex += 8 ; break ; case ( 0x64 ) : myArguments [ myTagIndex ] = ( new Double ( Bytes . toDouble ( Bytes . copy ( theBytes , myIndex , 8 ) ) ) ) ; myIndex += 8 ; break ; case ( 0x53 ) : case ( 0x73 ) : int newIndex = myIndex ; StringBuffer stringBuffer = new StringBuffer ( ) ; stringLoop : do { if ( theBytes [ newIndex ] == 0x00 ) { break stringLoop ; } else { stringBuffer . append ( ( char ) theBytes [ newIndex ] ) ; } newIndex ++ ; } while ( newIndex < theBytes . length ) ; myArguments [ myTagIndex ] = ( stringBuffer . toString ( ) ) ; myIndex = newIndex + align ( newIndex ) ; break ; case 0x62 : int myLen = Bytes . toInt ( Bytes . copy ( theBytes , myIndex , 4 ) ) ; myIndex += 4 ; myArguments [ myTagIndex ] = Bytes . copy ( theBytes , myIndex , myLen ) ; myIndex += myLen + ( align ( myLen ) % 4 ) ; break ; case 0x6d : myArguments [ myTagIndex ] = Bytes . copy ( theBytes , myIndex , 4 ) ; myIndex += 4 ; break ; } myTagIndex ++ ; } _myData = Bytes . copy ( _myData , 0 , myIndex ) ; return myArguments ; }
cast the arguments passed with the incoming osc message and store them in an object array.
209
private boolean hasNextPostponed ( ) { return ! postponedRoutes . isEmpty ( ) ; }
Returns true if there is another postponed route to try.
210
public static String decodeAttributeCode ( String attributeCode ) { return attributeCode . startsWith ( "+" ) ? attributeCode . substring ( 1 ) : attributeCode ; }
Remove dynamic attribute marker (+) from attribute code (if exists)
211
public boolean toBoolean ( Element el , String attributeName ) { return Caster . toBooleanValue ( el . getAttribute ( attributeName ) , false ) ; }
reads a XML Element Attribute ans cast it to a boolean value
212
private synchronized void rebuildJournal ( ) throws IOException { if ( journalWriter != null ) { journalWriter . close ( ) ; } Writer writer = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( journalFileTmp ) , Util . US_ASCII ) ) ; try { writer . write ( MAGIC ) ; writer . write ( "\n" ) ; writer . write ( VERSION_1 ) ; writer . write ( "\n" ) ; writer . write ( Integer . toString ( appVersion ) ) ; writer . write ( "\n" ) ; writer . write ( Integer . toString ( valueCount ) ) ; writer . write ( "\n" ) ; writer . write ( "\n" ) ; for ( Entry entry : lruEntries . values ( ) ) { if ( entry . currentEditor != null ) { writer . write ( DIRTY + ' ' + entry . key + '\n' ) ; } else { writer . write ( CLEAN + ' ' + entry . key + entry . getLengths ( ) + '\n' ) ; } } } finally { writer . close ( ) ; } if ( journalFile . exists ( ) ) { renameTo ( journalFile , journalFileBackup , true ) ; } renameTo ( journalFileTmp , journalFile , false ) ; journalFileBackup . delete ( ) ; journalWriter = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( journalFile , true ) , Util . US_ASCII ) ) ; }
Creates a new journal that omits redundant information. This replaces the current journal if it exists.
213
void saveToStream ( DataOutputStream out ) throws IOException { out . writeUTF ( mUrl ) ; out . writeUTF ( mName ) ; out . writeUTF ( mValue ) ; out . writeUTF ( mDomain ) ; out . writeUTF ( mPath ) ; out . writeLong ( mCreation ) ; out . writeLong ( mExpiration ) ; out . writeLong ( mLastAccess ) ; out . writeBoolean ( mSecure ) ; out . writeBoolean ( mHttpOnly ) ; out . writeBoolean ( mFirstPartyOnly ) ; out . writeInt ( mPriority ) ; }
Serializes for saving to disk. Does not close the stream. It is up to the caller to do so.
214
public boolean delete ( File f ) { if ( f . isDirectory ( ) ) { for ( File child : f . listFiles ( ) ) { if ( ! delete ( child ) ) { return ( false ) ; } } } boolean result = f . delete ( ) ; MediaScannerConnection . scanFile ( this , new String [ ] { f . getAbsolutePath ( ) } , null , null ) ; return ( result ) ; }
Recursively deletes a directory and its contents.
215
public static void replaceHttpHeaderMapNodeSpecific ( Map < String , String > httpHeaderMap , Map < String , String > requestParameters ) { boolean needToReplaceVarInHttpHeader = false ; for ( String parameter : requestParameters . keySet ( ) ) { if ( parameter . contains ( PcConstants . NODE_REQUEST_PREFIX_REPLACE_VAR ) ) { needToReplaceVarInHttpHeader = true ; break ; } } if ( ! needToReplaceVarInHttpHeader ) { logger . debug ( "No need to replace. Since there are no HTTP header variables. " ) ; return ; } for ( Entry < String , String > entry : httpHeaderMap . entrySet ( ) ) { String key = entry . getKey ( ) ; String valueOriginal = entry . getValue ( ) ; String valueUpdated = NodeReqResponse . replaceStrByMap ( requestParameters , valueOriginal ) ; httpHeaderMap . put ( key , valueUpdated ) ; } }
!!!! ASSUMPTION: all VAR exists in HTTP Header must of type: APIVARREPLACE_NAME_PREFIX_HTTP_HEADER 20140310 This may be costly (O(n^2)) of the updated related # of headers; # of parameters in the requests. Better to only do it when there are some replacement in the request Parameters. a prefix : TOBE tested
216
private void mapPut ( Map map , String name , Object preference ) throws IOException { isEmpty = false ; if ( ( name . length ( ) == 0 ) || ( name == null ) ) { throw new IOException ( "no name specified in preference" + " expression" ) ; } if ( map . put ( name , preference ) != null ) { throw new IOException ( "duplicate map entry: " + name ) ; } }
Insert a preference expression and value into a given map.
217
public Builder withTags ( Map < String , String > tags ) { this . tags = Collections . unmodifiableMap ( tags ) ; return this ; }
Add these tags to all metrics.
218
public static Script createMultiSigInputScript ( List < TransactionSignature > signatures ) { List < byte [ ] > sigs = new ArrayList < byte [ ] > ( signatures . size ( ) ) ; for ( TransactionSignature signature : signatures ) sigs . add ( signature . encodeToBitcoin ( ) ) ; return createMultiSigInputScriptBytes ( sigs ) ; }
Create a program that satisfies an OP_CHECKMULTISIG program.
219
@ Override public Object [ ] toArray ( ) { final ArrayList < Object > out = new ArrayList < Object > ( ) ; final Iterator < IGPO > gpos = iterator ( ) ; while ( gpos . hasNext ( ) ) { out . add ( gpos . next ( ) ) ; } return out . toArray ( ) ; }
Eagerly streams materialized objects into an array
220
public static Angle rhumbAzimuth ( LatLon p1 , LatLon p2 ) { if ( p1 == null || p2 == null ) { throw new IllegalArgumentException ( "LatLon Is Null" ) ; } double lat1 = p1 . getLatitude ( ) . radians ; double lon1 = p1 . getLongitude ( ) . radians ; double lat2 = p2 . getLatitude ( ) . radians ; double lon2 = p2 . getLongitude ( ) . radians ; if ( lat1 == lat2 && lon1 == lon2 ) return Angle . ZERO ; double dLon = lon2 - lon1 ; double dPhi = Math . log ( Math . tan ( lat2 / 2.0 + Math . PI / 4.0 ) / Math . tan ( lat1 / 2.0 + Math . PI / 4.0 ) ) ; if ( Math . abs ( dLon ) > Math . PI ) { dLon = dLon > 0 ? - ( 2 * Math . PI - dLon ) : ( 2 * Math . PI + dLon ) ; } double azimuthRadians = Math . atan2 ( dLon , dPhi ) ; return Double . isNaN ( azimuthRadians ) ? Angle . ZERO : Angle . fromRadians ( azimuthRadians ) ; }
Computes the azimuth angle (clockwise from North) of a rhumb line (a line of constant heading) between two locations.
221
public void takeColumnFamilySnapshot ( String keyspaceName , String columnFamilyName , String tag ) throws IOException { if ( keyspaceName == null ) throw new IOException ( "You must supply a keyspace name" ) ; if ( operationMode == Mode . JOINING ) throw new IOException ( "Cannot snapshot until bootstrap completes" ) ; if ( columnFamilyName == null ) throw new IOException ( "You must supply a table name" ) ; if ( columnFamilyName . contains ( "." ) ) throw new IllegalArgumentException ( "Cannot take a snapshot of a secondary index by itself. Run snapshot on the table that owns the index." ) ; if ( tag == null || tag . equals ( "" ) ) throw new IOException ( "You must supply a snapshot name." ) ; Keyspace keyspace = getValidKeyspace ( keyspaceName ) ; ColumnFamilyStore columnFamilyStore = keyspace . getColumnFamilyStore ( columnFamilyName ) ; if ( columnFamilyStore . snapshotExists ( tag ) ) throw new IOException ( "Snapshot " + tag + " already exists." ) ; columnFamilyStore . snapshot ( tag ) ; }
Takes the snapshot of a specific column family. A snapshot name must be specified.
222
public void clear ( ) { oredCriteria . clear ( ) ; orderByClause = null ; distinct = false ; }
This method was generated by MyBatis Generator. This method corresponds to the database table iteration_object
223
@ Override public Enumeration < Option > listOptions ( ) { Vector < Option > newVector = new Vector < Option > ( 6 ) ; newVector . addElement ( new Option ( "\tGenerate network (instead of instances)\n" , "B" , 0 , "-B" ) ) ; newVector . addElement ( new Option ( "\tNr of nodes\n" , "N" , 1 , "-N <integer>" ) ) ; newVector . addElement ( new Option ( "\tNr of arcs\n" , "A" , 1 , "-A <integer>" ) ) ; newVector . addElement ( new Option ( "\tNr of instances\n" , "M" , 1 , "-M <integer>" ) ) ; newVector . addElement ( new Option ( "\tCardinality of the variables\n" , "C" , 1 , "-C <integer>" ) ) ; newVector . addElement ( new Option ( "\tSeed for random number generator\n" , "S" , 1 , "-S <integer>" ) ) ; newVector . addElement ( new Option ( "\tThe BIF file to obtain the structure from.\n" , "F" , 1 , "-F <file>" ) ) ; return newVector . elements ( ) ; }
Returns an enumeration describing the available options
224
private void dialogChanged ( ) { String fileName = getFilename ( ) ; String set = getSetname ( ) ; if ( ( null == fileName ) || ( fileName . length ( ) < 1 ) ) { updateStatus ( "File name must be specified" ) ; return ; } if ( ( null == set ) || ( set . length ( ) < 1 ) ) { updateStatus ( "Set name must be specified" ) ; return ; } updateStatus ( null ) ; }
Check data entered. File name and set name must be specified.
225
@ SuppressWarnings ( "unchecked" ) private void applyToGroupAndSubGroups ( final AST2BOpContext context , final QueryRoot queryRoot , final QueryHintScope scope , final GraphPatternGroup < IGroupMemberNode > group , final String name , final String value ) { for ( IGroupMemberNode child : group ) { _applyQueryHint ( context , queryRoot , scope , ( ASTBase ) child , name , value ) ; if ( child instanceof GraphPatternGroup < ? > ) { applyToGroupAndSubGroups ( context , queryRoot , scope , ( GraphPatternGroup < IGroupMemberNode > ) child , name , value ) ; } } _applyQueryHint ( context , queryRoot , scope , ( ASTBase ) group , name , value ) ; }
Apply the query hint to the group and, recursively, to any sub-groups.
226
@ Override public boolean equals ( Object otherRules ) { if ( this == otherRules ) { return true ; } if ( otherRules instanceof ZoneRules ) { ZoneRules other = ( ZoneRules ) otherRules ; return Arrays . equals ( standardTransitions , other . standardTransitions ) && Arrays . equals ( standardOffsets , other . standardOffsets ) && Arrays . equals ( savingsInstantTransitions , other . savingsInstantTransitions ) && Arrays . equals ( wallOffsets , other . wallOffsets ) && Arrays . equals ( lastRules , other . lastRules ) ; } return false ; }
Checks if this set of rules equals another. <p> Two rule sets are equal if they will always result in the same output for any given input instant or local date-time. Rules from two different groups may return false even if they are in fact the same. <p> This definition should result in implementations comparing their entire state.
227
public static int readInt ( final JSONObject jsonObject , final String key , final boolean required , final boolean notNull ) throws JSONException { if ( required ) { return jsonObject . getInt ( key ) ; } if ( notNull && jsonObject . isNull ( key ) ) { throw new JSONException ( String . format ( Locale . US , NULL_VALUE_FORMAT_OBJECT , key ) ) ; } int value = 0 ; if ( ! jsonObject . isNull ( key ) ) { value = jsonObject . getInt ( key ) ; } return value ; }
Reads the int value from the Json Object for specified tag.
228
public TimeTableXYDataset ( ) { this ( TimeZone . getDefault ( ) , Locale . getDefault ( ) ) ; }
Creates a new dataset.
229
protected void onPageScrolled ( int position , float offset , int offsetPixels ) { if ( mDecorChildCount > 0 ) { if ( mOrientation == Orientation . VERTICAL ) { final int scrollY = getScrollY ( ) ; int paddingTop = getPaddingTop ( ) ; int paddingBottom = getPaddingBottom ( ) ; final int height = getHeight ( ) ; final int childCount = getChildCount ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { final View child = getChildAt ( i ) ; final LayoutParams lp = ( LayoutParams ) child . getLayoutParams ( ) ; if ( ! lp . isDecor ) continue ; final int vgrav = lp . gravity & Gravity . VERTICAL_GRAVITY_MASK ; int childTop = 0 ; switch ( vgrav ) { default : childTop = paddingTop ; break ; case Gravity . TOP : childTop = paddingTop ; paddingTop += child . getHeight ( ) ; break ; case Gravity . CENTER_VERTICAL : childTop = Math . max ( ( height - child . getMeasuredHeight ( ) ) / 2 , paddingTop ) ; break ; case Gravity . BOTTOM : childTop = height - paddingBottom - child . getMeasuredHeight ( ) ; paddingBottom += child . getMeasuredHeight ( ) ; break ; } childTop += scrollY ; final int childOffset = childTop - child . getTop ( ) ; if ( childOffset != 0 ) { child . offsetTopAndBottom ( childOffset ) ; } } } else { final int scrollX = getScrollX ( ) ; int paddingLeft = getPaddingLeft ( ) ; int paddingRight = getPaddingRight ( ) ; final int width = getWidth ( ) ; final int childCount = getChildCount ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { final View child = getChildAt ( i ) ; final LayoutParams lp = ( LayoutParams ) child . getLayoutParams ( ) ; if ( ! lp . isDecor ) continue ; final int hgrav = lp . gravity & Gravity . HORIZONTAL_GRAVITY_MASK ; int childLeft = 0 ; switch ( hgrav ) { default : childLeft = paddingLeft ; break ; case Gravity . LEFT : childLeft = paddingLeft ; paddingLeft += child . getWidth ( ) ; break ; case Gravity . CENTER_HORIZONTAL : childLeft = Math . max ( ( width - child . getMeasuredWidth ( ) ) / 2 , paddingLeft ) ; break ; case Gravity . RIGHT : childLeft = width - paddingRight - child . getMeasuredWidth ( ) ; paddingRight += child . getMeasuredWidth ( ) ; break ; } childLeft += scrollX ; final int childOffset = childLeft - child . getLeft ( ) ; if ( childOffset != 0 ) { child . offsetLeftAndRight ( childOffset ) ; } } } } if ( mOnPageChangeListener != null ) { mOnPageChangeListener . onPageScrolled ( position , offset , offsetPixels ) ; } if ( mInternalPageChangeListener != null ) { mInternalPageChangeListener . onPageScrolled ( position , offset , offsetPixels ) ; } if ( mPageTransformer != null ) { final int scroll = ( mOrientation == Orientation . VERTICAL ) ? getScrollY ( ) : getScrollX ( ) ; final int childCount = getChildCount ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { final View child = getChildAt ( i ) ; final LayoutParams lp = ( LayoutParams ) child . getLayoutParams ( ) ; if ( lp . isDecor ) continue ; final float transformPos = ( float ) ( ( ( mOrientation == Orientation . VERTICAL ) ? child . getTop ( ) : child . getLeft ( ) ) - scroll ) / getClientSize ( ) ; mPageTransformer . transformPage ( child , transformPos ) ; } } mCalledSuper = true ; }
This method will be invoked when the current page is scrolled, either as part of a programmatically initiated smooth scroll or a user initiated touch scroll. If you override this method you must call through to the superclass implementation (e.g. super.onPageScrolled(position, offset, offsetPixels)) before onPageScrolled returns.
230
public void removeTmpStore ( IMXStore store ) { if ( null != store ) { mTmpStores . remove ( store ) ; } }
Remove the dedicated store from the tmp stores list.
231
public static List < AnnotationDto > transformToDto ( List < Annotation > annotations ) { if ( annotations == null ) { throw new WebApplicationException ( "Null entity object cannot be converted to Dto object." , Status . INTERNAL_SERVER_ERROR ) ; } List < AnnotationDto > result = new ArrayList < > ( ) ; for ( Annotation annotation : annotations ) { result . add ( transformToDto ( annotation ) ) ; } return result ; }
Converts list of alert entity objects to list of alertDto objects.
232
protected void enableButtons ( ) { m_M_Product_ID = - 1 ; m_ProductName = null ; m_Price = null ; int row = m_table . getSelectedRow ( ) ; boolean enabled = row != - 1 ; if ( enabled ) { Integer ID = m_table . getSelectedRowKey ( ) ; if ( ID != null ) { m_M_Product_ID = ID . intValue ( ) ; m_ProductName = ( String ) m_table . getValueAt ( row , 2 ) ; m_Price = ( BigDecimal ) m_table . getValueAt ( row , 7 ) ; } } f_ok . setEnabled ( enabled ) ; log . fine ( "M_Product_ID=" + m_M_Product_ID + " - " + m_ProductName + " - " + m_Price ) ; }
Enable/Set Buttons and set ID
233
public static Matrix random ( int m , int n ) { Matrix A = new Matrix ( m , n ) ; double [ ] [ ] X = A . getArray ( ) ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { X [ i ] [ j ] = Math . random ( ) ; } } return A ; }
Generate matrix with random elements
234
public static List < IAType > validatePartitioningExpressions ( ARecordType recType , ARecordType metaRecType , List < List < String > > partitioningExprs , List < Integer > keySourceIndicators , boolean autogenerated ) throws AsterixException { List < IAType > partitioningExprTypes = new ArrayList < IAType > ( partitioningExprs . size ( ) ) ; if ( autogenerated ) { if ( partitioningExprs . size ( ) > 1 ) { throw new AsterixException ( "Cannot autogenerate a composite primary key" ) ; } List < String > fieldName = partitioningExprs . get ( 0 ) ; IAType fieldType = recType . getSubFieldType ( fieldName ) ; partitioningExprTypes . add ( fieldType ) ; ATypeTag pkTypeTag = fieldType . getTypeTag ( ) ; if ( pkTypeTag != ATypeTag . UUID ) { throw new AsterixException ( "Cannot autogenerate a primary key for type " + pkTypeTag + ". Autogenerated primary keys must be of type " + ATypeTag . UUID + "." ) ; } } else { partitioningExprTypes = KeyFieldTypeUtils . getKeyTypes ( recType , metaRecType , partitioningExprs , keySourceIndicators ) ; for ( int fidx = 0 ; fidx < partitioningExprTypes . size ( ) ; ++ fidx ) { IAType fieldType = partitioningExprTypes . get ( fidx ) ; if ( fieldType == null ) { throw new AsterixException ( "Type not found for partitioning key " + partitioningExprs . get ( fidx ) ) ; } switch ( fieldType . getTypeTag ( ) ) { case INT8 : case INT16 : case INT32 : case INT64 : case FLOAT : case DOUBLE : case STRING : case BINARY : case DATE : case TIME : case UUID : case DATETIME : case YEARMONTHDURATION : case DAYTIMEDURATION : break ; case UNION : throw new AsterixException ( "The partitioning key " + partitioningExprs . get ( fidx ) + " cannot be nullable" ) ; default : throw new AsterixException ( "The partitioning key " + partitioningExprs . get ( fidx ) + " cannot be of type " + fieldType . getTypeTag ( ) + "." ) ; } } } return partitioningExprTypes ; }
Validates the partitioning expression that will be used to partition a dataset and returns expression type.
235
public static void d ( String tag , String msg , Object ... args ) { if ( sLevel > LEVEL_DEBUG ) { return ; } if ( args . length > 0 ) { msg = String . format ( msg , args ) ; } Log . d ( tag , msg ) ; }
Send a DEBUG log message
236
public void start ( ) { managedPorts . add ( createPort ( ) ) ; fixNames ( ) ; ports . addObserver ( observer , false ) ; }
Creates an initial port and starts to listen.
237
public HessianDebugOutputStream ( OutputStream os , PrintWriter dbg ) { _os = os ; _state = new HessianDebugState ( dbg ) ; }
Creates an uninitialized Hessian input stream.
238
public Configurator fromFile ( File file ) { if ( ! file . exists ( ) ) { throw new FileNotFoundException ( file . getAbsolutePath ( ) + " does not exist." ) ; } return new Configurator ( file . getAbsolutePath ( ) , false ) ; }
Use a file as the pdf source
239
public synchronized void insertText ( String inputtype , String outputtype , String locale , String voice , String outputparams , String style , String effects , String inputtext , String outputtext ) throws SQLException { if ( inputtype == null || outputtype == null || locale == null || voice == null || inputtext == null || outputtext == null ) { throw new NullPointerException ( "Null argument" ) ; } if ( lookupText ( inputtype , outputtype , locale , voice , outputparams , style , effects , inputtext ) != null ) { return ; } String query = "INSERT INTO MARYCACHE (inputtype, outputtype, locale, voice, outputparams, style, effects, inputtext, outputtext) VALUES ('" + inputtype + "','" + outputtype + "','" + locale + "','" + voice + "','" + outputparams + "','" + style + "','" + effects + "',?,?)" ; PreparedStatement st = connection . prepareStatement ( query ) ; st . setString ( 1 , inputtext ) ; st . setString ( 2 , outputtext ) ; st . executeUpdate ( ) ; st . close ( ) ; }
Insert a record of a MARY request producing data of type text into the cache. If a record with the same lookup keys (i.e., all parameters everything except outputtext) exists already, this call does nothing.
240
public boolean isEmpty ( ) { return true ; }
Methods that need to be implemented from GeneralTaskRunnable.
241
public static boolean isNumericOrPunctuationOrSymbols ( String token ) { int len = token . length ( ) ; for ( int i = 0 ; i < len ; ++ i ) { char c = token . charAt ( i ) ; if ( ! ( Character . isDigit ( c ) || Characters . isPunctuation ( c ) || Characters . isSymbol ( c ) ) ) { return false ; } } return true ; }
Returns true if a string consists entirely of numbers, punctuation, and/or symbols.
242
@ Deprecated public DCCppMessage ( String s ) { setBinary ( false ) ; setRetries ( _nRetries ) ; setTimeout ( DCCppMessageTimeout ) ; myMessage = new StringBuilder ( s ) ; _nDataChars = myMessage . length ( ) ; _dataChars = new int [ _nDataChars ] ; }
Create a DCCppMessage from a String containing bytes. Since DCCppMessages are text, there is no Hex-to-byte conversion
243
@ Override public void start ( ) throws BaleenException { }
Will not start controllers.
244
public ObjectInstance ( ObjectName objectName , String className ) { if ( objectName . isPattern ( ) ) { final IllegalArgumentException iae = new IllegalArgumentException ( "Invalid name->" + objectName . toString ( ) ) ; throw new RuntimeOperationsException ( iae ) ; } this . name = objectName ; this . className = className ; }
Allows an object instance to be created given an object name and the full class name, including the package name.
245
public static void flushEL ( Writer w ) { try { if ( w != null ) w . flush ( ) ; } catch ( Exception e ) { } }
flush OutputStream without a Exception
246
public Dimension maximumLayoutSize ( Container target ) { Dimension size ; synchronized ( this ) { checkContainer ( target ) ; checkRequests ( ) ; size = new Dimension ( xTotal . maximum , yTotal . maximum ) ; } Insets insets = target . getInsets ( ) ; size . width = ( int ) Math . min ( ( long ) size . width + ( long ) insets . left + ( long ) insets . right , Integer . MAX_VALUE ) ; size . height = ( int ) Math . min ( ( long ) size . height + ( long ) insets . top + ( long ) insets . bottom , Integer . MAX_VALUE ) ; return size ; }
Returns the maximum dimensions the target container can use to lay out the components it contains.
247
private void addGroupText ( FormEntryCaption [ ] groups ) { StringBuilder s = new StringBuilder ( "" ) ; String t = "" ; int i ; for ( FormEntryCaption g : groups ) { i = g . getMultiplicity ( ) + 1 ; t = g . getLongText ( ) ; if ( t != null ) { s . append ( t ) ; if ( g . repeats ( ) && i > 0 ) { s . append ( " (" + i + ")" ) ; } s . append ( " > " ) ; } } if ( s . length ( ) > 0 ) { TextView tv = new TextView ( getContext ( ) ) ; tv . setText ( s . substring ( 0 , s . length ( ) - 3 ) ) ; int questionFontsize = Collect . getQuestionFontsize ( ) ; tv . setTextSize ( TypedValue . COMPLEX_UNIT_DIP , questionFontsize - 4 ) ; tv . setPadding ( 0 , 0 , 0 , 5 ) ; mView . addView ( tv , mLayout ) ; } }
// * Add a TextView containing the hierarchy of groups to which the question belongs. //
248
public static Number plus ( Number left , Character right ) { return NumberNumberPlus . plus ( left , Integer . valueOf ( right ) ) ; }
Add a Number and a Character. The ordinal value of the Character is used in the addition (the ordinal value is the unicode value which for simple character sets is the ASCII value).
249
public void addFlag ( OptionID optionid ) { parameters . add ( new ParameterPair ( optionid , Flag . SET ) ) ; }
Add a flag to the parameter list
250
public static ByteBuffer toBuffer ( String spacedHex ) { return ByteBuffer . wrap ( toByteArray ( spacedHex ) ) ; }
Convert the spaced hex form of a String into a ByteBuffer.
251
protected void print ( char v ) throws IOException { os . write ( v ) ; }
Prints a char to the stream.
252
public void runTest ( ) throws Throwable { Document doc ; NodeList elementList ; Node nameNode ; CharacterData child ; String childData ; doc = ( Document ) load ( "hc_staff" , true ) ; elementList = doc . getElementsByTagName ( "acronym" ) ; nameNode = elementList . item ( 0 ) ; child = ( CharacterData ) nameNode . getFirstChild ( ) ; child . deleteData ( 30 , 5 ) ; childData = child . getData ( ) ; assertEquals ( "characterdataDeleteDataEndAssert" , "1230 North Ave. Dallas, Texas " , childData ) ; }
Runs the test case.
253
public static boolean isRightTurn ( Point p1 , Point p2 , Point p3 ) { if ( p1 . equals ( p2 ) || p2 . equals ( p3 ) ) { return false ; } double val = ( p2 . x * p3 . y + p1 . x * p2 . y + p3 . x * p1 . y ) - ( p2 . x * p1 . y + p3 . x * p2 . y + p1 . x * p3 . y ) ; return val > 0 ; }
Returns true, if the three given points make a right turn.
254
private String convertLessThanOneThousand ( int number ) { String soFar ; if ( number % 100 < 20 ) { soFar = numNames [ number % 100 ] ; number /= 100 ; } else { soFar = numNames [ number % 10 ] ; number /= 10 ; String s = Double . toString ( number ) ; if ( s . endsWith ( "2" ) && ! soFar . equals ( "" ) ) soFar = " Vinte e " + soFar . trim ( ) ; else if ( soFar . equals ( "" ) ) soFar = tensNames [ number % 10 ] + " e" + soFar ; else soFar = tensNames [ number % 10 ] + " e" + soFar ; number /= 10 ; } if ( number == 0 ) return tensNames [ number % 10 ] + soFar ; if ( number > 1 ) soFar = "s e" + soFar ; if ( number == 1 && ! soFar . equals ( "" ) ) number = 0 ; soFar = " e" + soFar ; return numNames [ number ] + " Cento" + soFar ; }
Convert Less Than One Thousand
255
public boolean isRefreshTokenExpired ( ) { return refreshTokenExpiresAt . before ( new Date ( ) ) ; }
checks if the time the refresh access token will be valid are over
256
public static String encodeECC200 ( String codewords , SymbolInfo symbolInfo ) { if ( codewords . length ( ) != symbolInfo . getDataCapacity ( ) ) { throw new IllegalArgumentException ( "The number of codewords does not match the selected symbol" ) ; } StringBuilder sb = new StringBuilder ( symbolInfo . getDataCapacity ( ) + symbolInfo . getErrorCodewords ( ) ) ; sb . append ( codewords ) ; int blockCount = symbolInfo . getInterleavedBlockCount ( ) ; if ( blockCount == 1 ) { String ecc = createECCBlock ( codewords , symbolInfo . getErrorCodewords ( ) ) ; sb . append ( ecc ) ; } else { sb . setLength ( sb . capacity ( ) ) ; int [ ] dataSizes = new int [ blockCount ] ; int [ ] errorSizes = new int [ blockCount ] ; int [ ] startPos = new int [ blockCount ] ; for ( int i = 0 ; i < blockCount ; i ++ ) { dataSizes [ i ] = symbolInfo . getDataLengthForInterleavedBlock ( i + 1 ) ; errorSizes [ i ] = symbolInfo . getErrorLengthForInterleavedBlock ( i + 1 ) ; startPos [ i ] = 0 ; if ( i > 0 ) { startPos [ i ] = startPos [ i - 1 ] + dataSizes [ i ] ; } } for ( int block = 0 ; block < blockCount ; block ++ ) { StringBuilder temp = new StringBuilder ( dataSizes [ block ] ) ; for ( int d = block ; d < symbolInfo . getDataCapacity ( ) ; d += blockCount ) { temp . append ( codewords . charAt ( d ) ) ; } String ecc = createECCBlock ( temp . toString ( ) , errorSizes [ block ] ) ; int pos = 0 ; for ( int e = block ; e < errorSizes [ block ] * blockCount ; e += blockCount ) { sb . setCharAt ( symbolInfo . getDataCapacity ( ) + e , ecc . charAt ( pos ++ ) ) ; } } } return sb . toString ( ) ; }
Creates the ECC200 error correction for an encoded message.
257
public String toString ( ) { if ( m_FilteredInstances == null ) { return "RandomizableFilteredClassifier: No model built yet." ; } String result = "RandomizableFilteredClassifier using " + getClassifierSpec ( ) + " on data filtered through " + getFilterSpec ( ) + "\n\nFiltered Header\n" + m_FilteredInstances . toString ( ) + "\n\nClassifier Model\n" + m_Classifier . toString ( ) ; return result ; }
Output a representation of this classifier
258
public void addSlide ( @ NonNull Fragment fragment ) { fragments . add ( fragment ) ; if ( isWizardMode ) { setOffScreenPageLimit ( fragments . size ( ) ) ; } mPagerAdapter . notifyDataSetChanged ( ) ; }
Adds a new slide
259
@ Bean public SpringProcessEngineConfiguration activitiProcessEngineConfiguration ( AsyncExecutor activitiAsyncExecutor ) { SpringProcessEngineConfiguration configuration = new SpringProcessEngineConfiguration ( ) ; configuration . setDataSource ( herdDataSource ) ; configuration . setTransactionManager ( herdTransactionManager ) ; configuration . setDatabaseSchemaUpdate ( getActivitiDbSchemaUpdateParamBeanName ( ) ) ; configuration . setAsyncExecutorActivate ( true ) ; configuration . setAsyncExecutorEnabled ( true ) ; configuration . setAsyncExecutor ( activitiAsyncExecutor ) ; configuration . setBeans ( new HashMap < > ( ) ) ; configuration . setDelegateInterceptor ( herdDelegateInterceptor ) ; configuration . setCommandInvoker ( herdCommandInvoker ) ; initScriptingEngines ( configuration ) ; configuration . setMailServerDefaultFrom ( configurationHelper . getProperty ( ConfigurationValue . ACTIVITI_DEFAULT_MAIL_FROM ) ) ; List < ProcessEngineConfigurator > herdConfigurators = new ArrayList < > ( ) ; herdConfigurators . add ( herdProcessEngineConfigurator ) ; configuration . setConfigurators ( herdConfigurators ) ; return configuration ; }
Gets the Activiti Process Engine Configuration.
260
protected < T > void runTasksConcurrent ( final List < AbstractTask < T > > tasks ) throws InterruptedException { assert resourceManager . overflowTasksConcurrent >= 0 ; try { final List < Future < T > > futures = resourceManager . getConcurrencyManager ( ) . invokeAll ( tasks , resourceManager . overflowTimeout , TimeUnit . MILLISECONDS ) ; final Iterator < AbstractTask < T > > titr = tasks . iterator ( ) ; for ( Future < ? extends Object > f : futures ) { final AbstractTask < T > task = titr . next ( ) ; getFutureForTask ( f , task , 0L , TimeUnit . NANOSECONDS ) ; } } finally { } }
Runs the overflow tasks in parallel, cancelling any tasks which have not completed if we run out of time. A dedicated thread pool is allocated for this purpose. Depending on the configuration, it will be either a cached thread pool (full parallelism) or a fixed thread pool (limited parallelism).
261
public void initComponents ( ) { setTitle ( Bundle . getMessage ( "WindowTitle" ) ) ; Container contentPane = getContentPane ( ) ; contentPane . setLayout ( new BoxLayout ( contentPane , BoxLayout . Y_AXIS ) ) ; contentPane . add ( initAddressPanel ( ) ) ; contentPane . add ( initNotesPanel ( ) ) ; contentPane . add ( initButtonPanel ( ) ) ; pack ( ) ; }
Initialize the config window
262
public void makeImmutable ( ) { if ( isMutable ) { isMutable = false ; } }
Makes this object immutable.
263
public void accumulate ( TaggedLogAPIEntity entity ) throws Exception { AggregateAPIEntity current = root ; for ( String groupby : groupbys ) { String tagv = locateGroupbyField ( groupby , entity ) ; if ( tagv == null || tagv . isEmpty ( ) ) { tagv = UNASSIGNED_GROUPBY_ROOT_FIELD_NAME ; } Map < String , AggregateAPIEntity > children = current . getEntityList ( ) ; if ( children . get ( tagv ) == null ) { children . put ( tagv , factory . create ( ) ) ; current . setNumDirectDescendants ( current . getNumDirectDescendants ( ) + 1 ) ; } AggregateAPIEntity child = children . get ( tagv ) ; if ( counting ) count ( child ) ; for ( String sumFunctionField : sumFunctionFields ) { sum ( child , entity , sumFunctionField ) ; } current = child ; } }
currently only group by tags groupbys' first item always is site, which is a reserved field
264
private static double CallDoubleMethodV ( JNIEnvironment env , int objJREF , int methodID , Address argAddress ) throws Exception { if ( traceJNI ) VM . sysWrite ( "JNI called: CallDoubleMethodV \n" ) ; RuntimeEntrypoints . checkJNICountDownToGC ( ) ; try { Object obj = env . getJNIRef ( objJREF ) ; Object returnObj = JNIHelpers . invokeWithVarArg ( obj , methodID , argAddress , TypeReference . Double , false ) ; return Reflection . unwrapDouble ( returnObj ) ; } catch ( Throwable unexpected ) { if ( traceJNI ) unexpected . printStackTrace ( System . err ) ; env . recordException ( unexpected ) ; return 0 ; } }
CallDoubleMethodV: invoke a virtual method that returns a double value
265
private final int tradeBonus ( Position pos ) { final int wM = pos . wMtrl ; final int bM = pos . bMtrl ; final int wPawn = pos . wMtrlPawns ; final int bPawn = pos . bMtrlPawns ; final int deltaScore = wM - bM ; int pBonus = 0 ; pBonus += interpolate ( ( deltaScore > 0 ) ? wPawn : bPawn , 0 , - 30 * deltaScore / 100 , 6 * pV , 0 ) ; pBonus += interpolate ( ( deltaScore > 0 ) ? bM : wM , 0 , 30 * deltaScore / 100 , qV + 2 * rV + 2 * bV + 2 * nV , 0 ) ; return pBonus ; }
Implement the "when ahead trade pieces, when behind trade pawns" rule.
266
private List < Vcenter > filterVcentersByTenant ( List < Vcenter > vcenters , URI tenantId ) { List < Vcenter > tenantVcenterList = new ArrayList < Vcenter > ( ) ; Iterator < Vcenter > vcenterIt = vcenters . iterator ( ) ; while ( vcenterIt . hasNext ( ) ) { Vcenter vcenter = vcenterIt . next ( ) ; if ( vcenter == null ) { continue ; } Set < URI > tenantUris = _permissionsHelper . getUsageURIsFromAcls ( vcenter . getAcls ( ) ) ; if ( CollectionUtils . isEmpty ( tenantUris ) ) { continue ; } if ( ! NullColumnValueGetter . isNullURI ( tenantId ) && ! tenantUris . contains ( tenantId ) ) { continue ; } Iterator < URI > tenantUriIt = tenantUris . iterator ( ) ; while ( tenantUriIt . hasNext ( ) ) { if ( verifyAuthorizedInTenantOrg ( tenantUriIt . next ( ) ) ) { tenantVcenterList . add ( vcenter ) ; } } } return tenantVcenterList ; }
Filters the vCenters by the tenant. If the provided tenant is null or the tenant does not share the vCenter than the vCenters are filtered with the user's tenant.
267
public void updateVisiblityValue ( int referenceIndex ) { mCachedVisibleArea = mLayoutTab . computeVisibleArea ( ) ; mCachedIndexDistance = Math . abs ( mIndex - referenceIndex ) ; mOrderSortingValue = computeOrderSortingValue ( mCachedIndexDistance , mCacheStackVisibility ) ; mVisiblitySortingValue = computeVisibilitySortingValue ( mCachedVisibleArea , mOrderSortingValue , mCacheStackVisibility ) ; }
Updates the cached visible area value to be used to sort tabs by visibility.
268
public boolean contains ( EventPoint ep ) { return events . contains ( ep ) ; }
Determine whether event point already exists within the queue.
269
public FacebookException ( String format , Object ... args ) { this ( String . format ( format , args ) ) ; }
Constructs a new FacebookException.
270
private List < String > convertByteArrayListToStringValueList ( List < byte [ ] > dictionaryByteArrayList ) { List < String > valueList = new ArrayList < > ( dictionaryByteArrayList . size ( ) ) ; for ( byte [ ] value : dictionaryByteArrayList ) { valueList . add ( new String ( value , Charset . forName ( CarbonCommonConstants . DEFAULT_CHARSET ) ) ) ; } return valueList ; }
This method will convert list of byte array to list of string
271
public static void main ( String [ ] args ) { Log . printLine ( "Starting NetworkExample2..." ) ; try { int num_user = 1 ; Calendar calendar = Calendar . getInstance ( ) ; boolean trace_flag = false ; CloudSim . init ( num_user , calendar , trace_flag ) ; Datacenter datacenter0 = createDatacenter ( "Datacenter_0" ) ; Datacenter datacenter1 = createDatacenter ( "Datacenter_1" ) ; DatacenterBroker broker = createBroker ( ) ; int brokerId = broker . getId ( ) ; vmlist = new ArrayList < Vm > ( ) ; int vmid = 0 ; int mips = 250 ; long size = 10000 ; int ram = 512 ; long bw = 1000 ; int pesNumber = 1 ; String vmm = "Xen" ; Vm vm1 = new Vm ( vmid , brokerId , mips , pesNumber , ram , bw , size , vmm , new CloudletSchedulerTimeShared ( ) ) ; vmid ++ ; Vm vm2 = new Vm ( vmid , brokerId , mips , pesNumber , ram , bw , size , vmm , new CloudletSchedulerTimeShared ( ) ) ; vmlist . add ( vm1 ) ; vmlist . add ( vm2 ) ; broker . submitVmList ( vmlist ) ; cloudletList = new ArrayList < Cloudlet > ( ) ; int id = 0 ; long length = 40000 ; long fileSize = 300 ; long outputSize = 300 ; UtilizationModel utilizationModel = new UtilizationModelFull ( ) ; Cloudlet cloudlet1 = new Cloudlet ( id , length , pesNumber , fileSize , outputSize , utilizationModel , utilizationModel , utilizationModel ) ; cloudlet1 . setUserId ( brokerId ) ; id ++ ; Cloudlet cloudlet2 = new Cloudlet ( id , length , pesNumber , fileSize , outputSize , utilizationModel , utilizationModel , utilizationModel ) ; cloudlet2 . setUserId ( brokerId ) ; cloudletList . add ( cloudlet1 ) ; cloudletList . add ( cloudlet2 ) ; broker . submitCloudletList ( cloudletList ) ; broker . bindCloudletToVm ( cloudlet1 . getCloudletId ( ) , vm1 . getId ( ) ) ; broker . bindCloudletToVm ( cloudlet2 . getCloudletId ( ) , vm2 . getId ( ) ) ; NetworkTopology . buildNetworkTopology ( "topology.brite" ) ; int briteNode = 0 ; NetworkTopology . mapNode ( datacenter0 . getId ( ) , briteNode ) ; briteNode = 2 ; NetworkTopology . mapNode ( datacenter1 . getId ( ) , briteNode ) ; briteNode = 3 ; NetworkTopology . mapNode ( broker . getId ( ) , briteNode ) ; CloudSim . startSimulation ( ) ; List < Cloudlet > newList = broker . getCloudletReceivedList ( ) ; CloudSim . stopSimulation ( ) ; printCloudletList ( newList ) ; Log . printLine ( "NetworkExample2 finished!" ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; Log . printLine ( "The simulation has been terminated due to an unexpected error" ) ; } }
Creates main() to run this example
272
private boolean isNanpaNumberWithNationalPrefix ( ) { return ( currentMetadata . getCountryCode ( ) == 1 ) && ( nationalNumber . charAt ( 0 ) == '1' ) && ( nationalNumber . charAt ( 1 ) != '0' ) && ( nationalNumber . charAt ( 1 ) != '1' ) ; }
Returns true if the current country is a NANPA country and the national number begins with the national prefix.
273
public static void zipFiles ( File zip , File ... files ) throws IOException { try ( BufferedOutputStream bufferedOut = new BufferedOutputStream ( new FileOutputStream ( zip ) ) ) { zipFiles ( bufferedOut , files ) ; } }
Create an output ZIP stream and add each file to that stream. Directory files are added recursively. The contents of the zip are written to the given file.
274
protected void processClientPom ( ) throws IOException { File pom = new File ( projectRoot , CLIENT_POM ) ; String pomContent = readFileContent ( pom ) ; String depString = GEN_START + String . format ( "<dependency>%n<groupId>%s</groupId>%n<artifactId>%s</artifactId>%n</dependency>%n" , mavenGroupId , mavenArtifactId ) + GEN_END ; if ( ! pomContent . contains ( DEP_END_TAG ) ) { throw new IOException ( String . format ( "File '%s' doesn't contain '%s'. Can't process file." , CLIENT_POM , DEP_END_TAG ) ) ; } pomContent = pomContent . replace ( DEP_END_TAG , depString + DEP_END_TAG ) ; writeFileContent ( pomContent , pom ) ; }
Insert dependency at the end of "dependencies" section.
275
private void push ( final int type ) { if ( outputStack == null ) { outputStack = new int [ 10 ] ; } int n = outputStack . length ; if ( outputStackTop >= n ) { int [ ] t = new int [ Math . max ( outputStackTop + 1 , 2 * n ) ] ; System . arraycopy ( outputStack , 0 , t , 0 , n ) ; outputStack = t ; } outputStack [ outputStackTop ++ ] = type ; int top = owner . inputStackTop + outputStackTop ; if ( top > owner . outputStackMax ) { owner . outputStackMax = top ; } }
Pushes a new type onto the output frame stack.
276
public void put ( URI uri , byte [ ] bimg , BufferedImage img ) { synchronized ( bytemap ) { while ( bytesize > 1000 * 1000 * 50 ) { URI olduri = bytemapAccessQueue . removeFirst ( ) ; byte [ ] oldbimg = bytemap . remove ( olduri ) ; bytesize -= oldbimg . length ; log ( "removed 1 img from byte cache" ) ; } bytemap . put ( uri , bimg ) ; bytesize += bimg . length ; bytemapAccessQueue . addLast ( uri ) ; } addToImageCache ( uri , img ) ; }
Put a tile image into the cache. This puts both a buffered image and array of bytes that make up the compressed image.
277
public static void overScrollBy ( final PullToRefreshBase < ? > view , final int deltaX , final int scrollX , final int deltaY , final int scrollY , final int scrollRange , final int fuzzyThreshold , final float scaleFactor , final boolean isTouchEvent ) { final int deltaValue , currentScrollValue , scrollValue ; switch ( view . getPullToRefreshScrollDirection ( ) ) { case HORIZONTAL : deltaValue = deltaX ; scrollValue = scrollX ; currentScrollValue = view . getScrollX ( ) ; break ; case VERTICAL : default : deltaValue = deltaY ; scrollValue = scrollY ; currentScrollValue = view . getScrollY ( ) ; break ; } if ( view . isPullToRefreshOverScrollEnabled ( ) && ! view . isRefreshing ( ) ) { final Mode mode = view . getMode ( ) ; if ( mode . permitsPullToRefresh ( ) && ! isTouchEvent && deltaValue != 0 ) { final int newScrollValue = ( deltaValue + scrollValue ) ; if ( PullToRefreshBase . DEBUG ) { Log . d ( LOG_TAG , "OverScroll. DeltaX: " + deltaX + ", ScrollX: " + scrollX + ", DeltaY: " + deltaY + ", ScrollY: " + scrollY + ", NewY: " + newScrollValue + ", ScrollRange: " + scrollRange + ", CurrentScroll: " + currentScrollValue ) ; } if ( newScrollValue < ( 0 - fuzzyThreshold ) ) { if ( mode . showHeaderLoadingLayout ( ) ) { if ( currentScrollValue == 0 ) { view . setState ( State . OVERSCROLLING ) ; } view . setHeaderScroll ( ( int ) ( scaleFactor * ( currentScrollValue + newScrollValue ) ) ) ; } } else if ( newScrollValue > ( scrollRange + fuzzyThreshold ) ) { if ( mode . showFooterLoadingLayout ( ) ) { if ( currentScrollValue == 0 ) { view . setState ( State . OVERSCROLLING ) ; } view . setHeaderScroll ( ( int ) ( scaleFactor * ( currentScrollValue + newScrollValue - scrollRange ) ) ) ; } } else if ( Math . abs ( newScrollValue ) <= fuzzyThreshold || Math . abs ( newScrollValue - scrollRange ) <= fuzzyThreshold ) { view . setState ( State . RESET ) ; } } else if ( isTouchEvent && State . OVERSCROLLING == view . getState ( ) ) { view . setState ( State . RESET ) ; } } }
Helper method for Overscrolling that encapsulates all of the necessary function. This is the advanced version of the call.
278
public static AttribKey forAttribute ( Namespaces inScope , ElKey el , String qname ) { Namespaces ns ; String localName ; int colon = qname . indexOf ( ':' ) ; if ( colon < 0 ) { ns = el . ns ; localName = qname ; } else { ns = inScope . forAttrName ( el . ns , qname ) ; if ( ns == null ) { return null ; } ns = inScope . forUri ( ns . uri ) ; localName = qname . substring ( colon + 1 ) ; } return new AttribKey ( el , ns , localName ) ; }
Looks up an attribute key by qualified name.
279
public void removeMapEventsListener ( MapEventsListener listener ) { if ( mapEventsListeners != null ) { mapEventsListeners . remove ( listener ) ; } }
Removes map event listener from the map.
280
@ RequestMapping ( value = { "/{cg}/{k}" , "{cg}/{k}/" } , method = RequestMethod . GET ) @ ResponseBody public RestWrapper listUsingKey ( @ PathVariable ( "cg" ) String configGroup , @ PathVariable ( "k" ) String key , Principal principal ) { RestWrapper restWrapper = null ; GetGeneralConfig getGeneralConfig = new GetGeneralConfig ( ) ; GeneralConfig generalConfig = getGeneralConfig . byConigGroupAndKey ( configGroup , key ) ; if ( generalConfig . getRequired ( ) == 2 ) { restWrapper = new RestWrapper ( "Object with specified config_group and key not found" , RestWrapper . ERROR ) ; } else { restWrapper = new RestWrapper ( generalConfig , RestWrapper . OK ) ; LOGGER . info ( "Record with config group: " + configGroup + " and key:" + key + "selected from General Config by User:" + principal . getName ( ) ) ; } return restWrapper ; }
This method calls proc GetGenConfigProperty and fetches a record from GeneralConfig table corresponding to Config group and key passed.
281
private ColorStateList applyTextAppearance ( Paint p , int resId ) { TextView tv = new TextView ( mContext ) ; if ( SUtils . isApi_23_OrHigher ( ) ) { tv . setTextAppearance ( resId ) ; } else { tv . setTextAppearance ( mContext , resId ) ; } p . setTypeface ( tv . getTypeface ( ) ) ; p . setTextSize ( tv . getTextSize ( ) ) ; final ColorStateList textColor = tv . getTextColors ( ) ; if ( textColor != null ) { final int enabledColor = textColor . getColorForState ( ENABLED_STATE_SET , 0 ) ; p . setColor ( enabledColor ) ; } return textColor ; }
Applies the specified text appearance resource to a paint, returning the text color if one is set in the text appearance.
282
public void removeDiscoveryListener ( DiscoveryListener l ) { synchronized ( registrars ) { if ( terminated ) { throw new IllegalStateException ( "discovery terminated" ) ; } listeners . remove ( l ) ; } }
Indicate that a listener is no longer interested in receiving DiscoveryEvent notifications.
283
public static void copyFile ( File in , File out ) throws IOException { FileInputStream fis = new FileInputStream ( in ) ; FileOutputStream fos = new FileOutputStream ( out ) ; try { copyStream ( fis , fos ) ; } finally { fis . close ( ) ; fos . close ( ) ; } }
Copy a file from one place to another
284
private boolean airAppTerminated ( ProcessListener pl ) { if ( pl != null ) { if ( pl . isAIRApp ( ) ) { if ( pl . isProcessDead ( ) ) { return true ; } } } return false ; }
Returns true if the passed-in process listener is for an AIR application that has terminated. This is used by accept() in order to detect that it should give up listening on the socket. The reason we can't do this for Flash player-based apps is that unlike AIR apps, the process that we launched sometimes acts as just sort of a "launcher" process that terminates quickly, and the actual Flash player is in some other process. For example, on Mac, we often invoke the "open" program to open a web browser; and on Windows, if you launch firefox.exe but it detects that there is already a running instance of firefox.exe, the new instance will just pass a message to the old instance, and then the new instance will terminate.
285
private int xToScreenCoords ( int mapCoord ) { return ( int ) ( mapCoord * map . getScale ( ) - map . getScrollX ( ) ) ; }
Transforms coordinate in map coordinate system to screen coordinate system
286
public Alias filter ( Map < String , Object > filter ) { if ( filter == null || filter . isEmpty ( ) ) { this . filter = null ; return this ; } try { XContentBuilder builder = XContentFactory . contentBuilder ( XContentType . JSON ) ; builder . map ( filter ) ; this . filter = builder . string ( ) ; return this ; } catch ( IOException e ) { throw new ElasticsearchGenerationException ( "Failed to generate [" + filter + "]" , e ) ; } }
Associates a filter to the alias
287
public void connectToBeanContext ( BeanContext in_bc ) throws PropertyVetoException { if ( in_bc != null ) { in_bc . addBeanContextMembershipListener ( this ) ; beanContextChildSupport . setBeanContext ( in_bc ) ; } }
Layer method to just connect to the BeanContext, without grabbing the iterator as in setBeanContext(). Good for protected sub-layers where you want to optimize the calling of the findAndInit() method over them.
288
public static CertificateID createCertId ( BigInteger subjectSerialNumber , X509Certificate issuer ) throws Exception { return new CertificateID ( createDigestCalculator ( SHA1_ID ) , new X509CertificateHolder ( issuer . getEncoded ( ) ) , subjectSerialNumber ) ; }
Creates a new certificate ID instance (using SHA-1 digest calculator) for the specified subject certificate serial number and issuer certificate.
289
public static final String convertToText ( final String input , final boolean isXMLExtraction ) { final StringBuffer output_data ; if ( isXMLExtraction ) { final byte [ ] rawData = StringUtils . toBytes ( input ) ; final int length = rawData . length ; int ptr = 0 ; boolean inToken = false ; for ( int i = 0 ; i < length ; i ++ ) { if ( rawData [ i ] == '<' ) { inToken = true ; if ( rawData [ i + 1 ] == 'S' && rawData [ i + 2 ] == 'p' && rawData [ i + 3 ] == 'a' && rawData [ i + 4 ] == 'c' && rawData [ i + 5 ] == 'e' ) { rawData [ ptr ] = '\t' ; ptr ++ ; } } else if ( rawData [ i ] == '>' ) { inToken = false ; } else if ( ! inToken ) { rawData [ ptr ] = rawData [ i ] ; ptr ++ ; } } final byte [ ] cleanedString = new byte [ ptr ] ; System . arraycopy ( rawData , 0 , cleanedString , 0 , ptr ) ; output_data = new StringBuffer ( new String ( cleanedString ) ) ; } else { output_data = new StringBuffer ( input ) ; } return output_data . toString ( ) ; }
Strip out XML tags and put in a tab (do not use on Chinese text)
290
private int parseKey ( final byte [ ] b , final int off ) throws ParseException { final int bytesToParseLen = b . length - off ; if ( bytesToParseLen >= encryptedKeyLen_ ) { encryptedKey_ = Arrays . copyOfRange ( b , off , off + encryptedKeyLen_ ) ; return encryptedKeyLen_ ; } else { throw new ParseException ( "Not enough bytes to parse key" ) ; } }
Parse the key in the provided bytes. It looks for bytes of size defined by the key length in the provided bytes starting at the specified off. <p> If successful, it returns the size of the parsed bytes which is the key length. On failure, it throws a parse exception.
291
private void calculateIntersectPoints ( ) { intersectPoints . clear ( ) ; if ( center . x - menuBounds . left < expandedRadius ) { int dy = ( int ) Math . sqrt ( Math . pow ( expandedRadius , 2 ) - Math . pow ( center . x - menuBounds . left , 2 ) ) ; if ( center . y - dy > menuBounds . top ) { intersectPoints . add ( new Point ( menuBounds . left , center . y - dy ) ) ; } if ( center . y + dy < menuBounds . bottom ) { intersectPoints . add ( new Point ( menuBounds . left , center . y + dy ) ) ; } } if ( center . y - menuBounds . top < expandedRadius ) { int dx = ( int ) Math . sqrt ( Math . pow ( expandedRadius , 2 ) - Math . pow ( center . y - menuBounds . top , 2 ) ) ; if ( center . x + dx < menuBounds . right ) { intersectPoints . add ( new Point ( center . x + dx , menuBounds . top ) ) ; } if ( center . x - dx > menuBounds . left ) { intersectPoints . add ( new Point ( center . x - dx , menuBounds . top ) ) ; } } if ( menuBounds . right - center . x < expandedRadius ) { int dy = ( int ) Math . sqrt ( Math . pow ( expandedRadius , 2 ) - Math . pow ( menuBounds . right - center . x , 2 ) ) ; if ( center . y - dy > menuBounds . top ) { intersectPoints . add ( new Point ( menuBounds . right , center . y - dy ) ) ; } if ( center . y + dy < menuBounds . bottom ) { intersectPoints . add ( new Point ( menuBounds . right , center . y + dy ) ) ; } } if ( menuBounds . bottom - center . y < expandedRadius ) { int dx = ( int ) Math . sqrt ( Math . pow ( expandedRadius , 2 ) - Math . pow ( menuBounds . bottom - center . y , 2 ) ) ; if ( center . x + dx < menuBounds . right ) { intersectPoints . add ( new Point ( center . x + dx , menuBounds . bottom ) ) ; } if ( center . x - dx > menuBounds . left ) { intersectPoints . add ( new Point ( center . x - dx , menuBounds . bottom ) ) ; } } int size = intersectPoints . size ( ) ; if ( size == 0 ) { fromAngle = 0 ; toAngle = 360 ; return ; } int indexA = size - 1 ; double maxAngle = arcAngle ( center , intersectPoints . get ( 0 ) , intersectPoints . get ( indexA ) , menuBounds , expandedRadius ) ; for ( int i = 0 ; i < size - 1 ; i ++ ) { Point a = intersectPoints . get ( i ) ; Point b = intersectPoints . get ( i + 1 ) ; double angle = arcAngle ( center , a , b , menuBounds , expandedRadius ) ; Point midnormalPoint = findMidnormalPoint ( center , a , b , menuBounds , expandedRadius ) ; int pointerIndex = i ; int endIndex = indexA + 1 ; if ( ! isClockwise ( center , a , midnormalPoint ) ) { int tmpIndex = pointerIndex ; pointerIndex = endIndex ; endIndex = tmpIndex ; } if ( pointerIndex == intersectPoints . size ( ) - 1 ) { pointerIndex = 0 ; } else { pointerIndex ++ ; } if ( pointerIndex == endIndex && angle > maxAngle ) { indexA = i ; maxAngle = angle ; } } Point a = intersectPoints . get ( indexA ) ; Point b = intersectPoints . get ( indexA + 1 >= size ? 0 : indexA + 1 ) ; Point midnormalPoint = findMidnormalPoint ( center , a , b , menuBounds , expandedRadius ) ; Point x = new Point ( menuBounds . right , center . y ) ; if ( ! isClockwise ( center , a , midnormalPoint ) ) { Point tmp = a ; a = b ; b = tmp ; } fromAngle = pointAngleOnCircle ( center , a , x ) ; toAngle = pointAngleOnCircle ( center , b , x ) ; toAngle = toAngle <= fromAngle ? 360 + toAngle : toAngle ; }
find all intersect points, and calculate menu items display area;
292
public static ReplyProcessor21 send ( Set recipients , DM dm , int prId , int bucketId , BucketProfile bp , boolean requireAck ) { if ( recipients . isEmpty ( ) ) { return null ; } ReplyProcessor21 rp = null ; int procId = 0 ; if ( requireAck ) { rp = new ReplyProcessor21 ( dm , recipients ) ; procId = rp . getProcessorId ( ) ; } BucketProfileUpdateMessage m = new BucketProfileUpdateMessage ( recipients , prId , procId , bucketId , bp ) ; dm . putOutgoing ( m ) ; return rp ; }
Send a profile update to a set of members.
293
static boolean isCallerSensitive ( MemberName mem ) { if ( ! mem . isInvocable ( ) ) return false ; return mem . isCallerSensitive ( ) || canBeCalledVirtual ( mem ) ; }
Is this method a caller-sensitive method? I.e., does it call Reflection.getCallerClass or a similer method to ask about the identity of its caller?
294
public void stopSearch ( ) { mMatchedNode . clear ( ) ; mQueryText . setLength ( 0 ) ; mSearchOverlay . hide ( ) ; mActive = false ; }
Stop the current search. Hides the search overlay and clears the search query.
295
boolean persistManagedSchema ( boolean createOnly ) { if ( loader instanceof ZkSolrResourceLoader ) { return persistManagedSchemaToZooKeeper ( createOnly ) ; } File managedSchemaFile = new File ( loader . getConfigDir ( ) , managedSchemaResourceName ) ; OutputStreamWriter writer = null ; try { File parentDir = managedSchemaFile . getParentFile ( ) ; if ( ! parentDir . isDirectory ( ) ) { if ( ! parentDir . mkdirs ( ) ) { final String msg = "Can't create managed schema directory " + parentDir . getAbsolutePath ( ) ; log . error ( msg ) ; throw new SolrException ( ErrorCode . SERVER_ERROR , msg ) ; } } final FileOutputStream out = new FileOutputStream ( managedSchemaFile ) ; writer = new OutputStreamWriter ( out , StandardCharsets . UTF_8 ) ; persist ( writer ) ; log . info ( "Upgraded to managed schema at " + managedSchemaFile . getPath ( ) ) ; } catch ( IOException e ) { final String msg = "Error persisting managed schema " + managedSchemaFile ; log . error ( msg , e ) ; throw new SolrException ( ErrorCode . SERVER_ERROR , msg , e ) ; } finally { IOUtils . closeQuietly ( writer ) ; try { FileUtils . sync ( managedSchemaFile ) ; } catch ( IOException e ) { final String msg = "Error syncing the managed schema file " + managedSchemaFile ; log . error ( msg , e ) ; } } return true ; }
Persist the schema to local storage or to ZooKeeper
296
public static String makeXmlSafe ( String text ) { if ( StringUtil . isNullOrEmpty ( text ) ) return "" ; text = text . replace ( ESC_AMPERSAND , "&" ) ; text = text . replace ( "\"" , ESC_QUOTE ) ; text = text . replace ( "&" , ESC_AMPERSAND ) ; text = text . replace ( "'" , ESC_APOSTROPHE ) ; text = text . replace ( "<" , ESC_LESS_THAN ) ; text = text . replace ( ">" , ESC_GREATER_THAN ) ; text = text . replace ( "" , " " ) ; return text ; }
Takes in a string, and replaces all XML special characters with the approprate escape strings.
297
private static float strength ( final Collection < Unit > units , final boolean attacking , final boolean sea , final boolean transportsFirst ) { float strength = 0.0F ; if ( units . isEmpty ( ) ) { return strength ; } if ( attacking && Match . noneMatch ( units , Matches . unitHasAttackValueOfAtLeast ( 1 ) ) ) { return strength ; } else if ( ! attacking && Match . noneMatch ( units , Matches . unitHasDefendValueOfAtLeast ( 1 ) ) ) { return strength ; } for ( final Unit u : units ) { final UnitAttachment unitAttachment = UnitAttachment . get ( u . getType ( ) ) ; if ( unitAttachment . getIsInfrastructure ( ) ) { continue ; } else if ( unitAttachment . getIsSea ( ) == sea ) { final int unitAttack = unitAttachment . getAttack ( u . getOwner ( ) ) ; strength += 1.00F ; if ( attacking ) { strength += unitAttack * unitAttachment . getHitPoints ( ) ; } else { strength += unitAttachment . getDefense ( u . getOwner ( ) ) * unitAttachment . getHitPoints ( ) ; } if ( attacking ) { if ( unitAttack == 0 ) { strength -= 0.50F ; } } if ( unitAttack == 0 && unitAttachment . getTransportCapacity ( ) > 0 && ! transportsFirst ) { strength -= 0.50F ; } } else if ( unitAttachment . getIsAir ( ) == sea ) { strength += 1.00F ; if ( attacking ) { strength += unitAttachment . getAttack ( u . getOwner ( ) ) * unitAttachment . getAttackRolls ( u . getOwner ( ) ) ; } else { strength += unitAttachment . getDefense ( u . getOwner ( ) ) ; } } } if ( attacking && ! sea ) { final int art = Match . countMatches ( units , Matches . UnitIsArtillery ) ; final int artSupport = Match . countMatches ( units , Matches . UnitIsArtillerySupportable ) ; strength += Math . min ( art , artSupport ) ; } return strength ; }
Get a quick and dirty estimate of the strength of some units in a battle.
298
final public MutableString toUpperCase ( ) { int n = length ( ) ; final char [ ] a = array ; while ( n -- != 0 ) a [ n ] = Character . toUpperCase ( a [ n ] ) ; changed ( ) ; return this ; }
Converts all of the characters in this mutable string to upper case using the rules of the default locale.
299
@ Override public void handleMousePressed ( ChartCanvas canvas , MouseEvent e ) { this . mousePressedPoint = new Point2D . Double ( e . getX ( ) , e . getY ( ) ) ; }
Handles a mouse pressed event by recording the location of the mouse pointer (so that later we can check that the click isn't part of a drag).