idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
11,200
public TCert getNextTCert ( List < String > attrs ) { if ( ! isEnrolled ( ) ) { throw new RuntimeException ( String . format ( "user '%s' is not enrolled" , this . getName ( ) ) ) ; } String key = getAttrsKey ( attrs ) ; logger . debug ( String . format ( "Member.getNextTCert: key=%s" , key ) ) ; TCertGetter tcertGetter = this . tcertGetterMap . get ( key ) ; if ( tcertGetter == null ) { logger . debug ( String . format ( "Member.getNextTCert: key=%s, creating new getter" , key ) ) ; tcertGetter = new TCertGetter ( this , attrs , key ) ; this . tcertGetterMap . put ( key , tcertGetter ) ; } return tcertGetter . getNextTCert ( ) ; }
Get the next available transaction certificate with the appropriate attributes .
11,201
public void saveState ( ) { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; try { ObjectOutputStream oos = new ObjectOutputStream ( bos ) ; oos . writeObject ( this ) ; oos . flush ( ) ; keyValStore . setValue ( keyValStoreName , Hex . toHexString ( bos . toByteArray ( ) ) ) ; bos . close ( ) ; } catch ( IOException e ) { logger . debug ( String . format ( "Could not save state of member %s" , this . name ) , e ) ; } }
Save the state of this member to the key value store .
11,202
void addDataSource ( DataSource dataSource ) { if ( dataSource == null ) return ; this . dataSources . add ( new DataSourceDefinition ( dataSource . name ( ) , dataSource . driverClass ( ) , dataSource . url ( ) , dataSource . username ( ) , dataSource . password ( ) ) ) ; }
Adds a DataSource
11,203
void addTransactionManager ( TransactionManager transactionManager ) { if ( transactionManager == null ) return ; this . transactionManagers . add ( new TransactionManagerDefinition ( transactionManager . name ( ) ) ) ; }
Adds a TransactionManager
11,204
public void addJmsBrokers ( Jms [ ] jmses ) { for ( Jms jms : jmses ) { final JmsDefinition jmsDefinition = new JmsDefinition ( jms . connectionFactoryName ( ) ) ; jmsDefinition . addQueues ( jms . queues ( ) ) ; jmsDefinition . addTopics ( jms . topics ( ) ) ; this . jmsDefinitions . add ( jmsDefinition ) ; } }
Add all JMS broker defintions
11,205
void addBean ( Bean bean ) { if ( bean == null ) return ; this . beans . add ( new BeanDefinition ( bean . name ( ) , bean . clazz ( ) ) ) ; }
Adds a Bean definition
11,206
static long incrementAndGetTime ( Context context ) { Context appContext = context . getApplicationContext ( ) ; String key = appContext . getString ( R . string . wings__retry_policy_consecutive_fails ) ; SharedPreferences preferences = PreferenceManager . getDefaultSharedPreferences ( appContext ) ; int consecutiveFails = preferences . getInt ( key , 0 ) ; Editor editor = preferences . edit ( ) ; editor . putInt ( key , consecutiveFails + 1 ) ; editor . commit ( ) ; return getFibonacci ( consecutiveFails ) * MINUTE_TO_MILLIS ; }
Gets how far in the future to schedule the next attempt to share . An internal counter is incremented every time this method gets called so a subsequent call will return a different time .
11,207
public Collection < Effort > getEffortRecords ( EffortFilter filter ) { filter = ( filter == null ) ? new EffortFilter ( ) : filter ; filter . workitem . clear ( ) ; filter . workitem . add ( this ) ; return getInstance ( ) . get ( ) . effortRecords ( filter ) ; }
Gets Effort Records tracked against this Workitem .
11,208
public Effort createEffort ( double value , Map < String , Object > attributes ) { return createEffort ( value , null , null , attributes ) ; }
Log an effort record against this workitem .
11,209
public JoinDescription nested ( JoinDescription ... joins ) { for ( JoinDescription join : joins ) { join . parent = this ; join . alias ( J . path ( this . getAlias ( ) , join . getOriginalAlias ( ) ) ) ; addJoin ( join ) ; reAliasChildren ( join ) ; } return this ; }
Add children joins to current join
11,210
public JoinDescription nested ( EntityPath < ? > ... paths ) { for ( EntityPath < ? > path : paths ) { nested ( J . left ( path ) ) ; } return this ; }
Add children joins to current join from specified paths
11,211
public String getToken ( ) { if ( isNull ( ) ) { return NullOidToken ; } StringBuilder res = new StringBuilder ( ) ; res . append ( _type . getToken ( ) ) . append ( SEPARATOR ) . append ( _id ) ; if ( hasMoment ( ) ) { res . append ( SEPARATOR ) . append ( _moment ) ; } return res . toString ( ) ; }
Get the token for this object identifier
11,212
public static Oid fromToken ( String oidtoken , IMetaModel meta ) throws OidException { try { if ( oidtoken . equals ( NullOidToken ) ) { return Null ; } String [ ] parts = oidtoken . split ( SEPARATOR ) ; IAssetType type = meta . getAssetType ( parts [ 0 ] ) ; int id = Integer . parseInt ( parts [ 1 ] ) ; if ( parts . length > 2 ) { int moment = Integer . parseInt ( parts [ 2 ] ) ; return new com . versionone . Oid ( type , id , moment ) ; } return new com . versionone . Oid ( type , id ) ; } catch ( Exception e ) { throw new OidException ( "Invalid OID token" , oidtoken , e ) ; } }
Create an OID from a token
11,213
public static boolean compare ( Oid lhs , Oid rhs ) { if ( lhs == null || rhs == null ) return ( lhs == rhs ) ; return lhs . equals ( rhs ) ; }
Compare two oids
11,214
public String [ ] getTags ( ) { for ( int i = 0 ; i < length ; i ++ ) localeStrings [ i ] = locales [ i ] . getDisplayName ( ) ; return localeStrings ; }
Returns the locale strings .
11,215
public Collection < PrimaryWorkitem > getAffectedPrimaryWorkitems ( PrimaryWorkitemFilter filter ) { filter = ( filter != null ) ? filter : new PrimaryWorkitemFilter ( ) ; filter . affectedByDefects . clear ( ) ; filter . affectedByDefects . add ( this ) ; return getInstance ( ) . get ( ) . primaryWorkitems ( filter ) ; }
Primary workitems that are affected by this defect .
11,216
public ExtViewQuery image ( String url , boolean cache ) { if ( cache ) { image ( url ) ; } else { Picasso . with ( context ) . load ( url ) . skipMemoryCache ( ) . into ( ( ImageView ) view ) ; } return this ; }
Load network image to current ImageView with cache control
11,217
public ExtViewQuery image ( String url , Callback callback ) { if ( ! TextUtils . isEmpty ( url ) && view instanceof ImageView ) { Picasso . with ( context ) . load ( url ) . into ( ( ImageView ) view , callback ) ; } return self ( ) ; }
Load network image to current ImageView with callback
11,218
public static NumberFormat format ( int precision ) { NumberFormat format = precisionFormat . get ( precision ) ; if ( format == null ) { precisionFormat . put ( precision , createFormatter ( precision ) ) ; } return precisionFormat . get ( precision ) ; }
Returns a number format that formats a number with the given number of precision digits . Parsing is not currently supported .
11,219
private static DecimalFormat createFormatter ( int precision ) { if ( precision < 0 ) throw new IllegalArgumentException ( "Precision must be non-negative" ) ; if ( precision == 0 ) return new DecimalFormat ( "0" , symbols ) ; StringBuilder sb = new StringBuilder ( "0." ) ; for ( int i = 0 ; i < precision ; i ++ ) { sb . append ( "0" ) ; } return new DecimalFormat ( sb . toString ( ) , symbols ) ; }
Creates a new number format that formats a number with the given number of precision digits .
11,220
public String toJSONString ( ) { Gson gson = new GsonBuilder ( ) . excludeFieldsWithoutExposeAnnotation ( ) . create ( ) ; return gson . toJson ( this ) ; }
Creates the JSON representation of an Item
11,221
public Date getDate ( ) { Date date = new Date ( ) ; try { String dateText = field . getText ( ) ; SimpleDateFormat fmt = new SimpleDateFormat ( format ) ; date = fmt . parse ( dateText ) ; } catch ( Exception e ) { } return date ; }
Convert text of textfield to Date
11,222
public String encryptPropertyValue ( String propertyValue ) { byte [ ] bytes = cryptex . encryptString ( key , propertyValue ) ; String encryptedValue = Base64Utils . encode ( bytes ) ; return ENCRYPTED_NOTATION + encryptedValue ; }
This method encrypts a property value in such a way that it can be placed in a properties file and automatically decrypted using this placeholder configurer .
11,223
public static < T > T newInstance ( final Class < T > clazz ) { try { return clazz . newInstance ( ) ; } catch ( InstantiationException | IllegalAccessException e ) { throw new ClassApiException ( e ) ; } }
Creates new instance of class rethrowing all exceptions in runtime .
11,224
public static < T > Optional < T > cast ( final Object o , final Class < T > clazz ) { T result = null ; if ( o != null && clazz . isInstance ( o ) ) { result = ( T ) o ; } return Optional . ofNullable ( result ) ; }
Cast object to clazz and returns Optional . If it can not be cast then the Optional is empty .
11,225
private static int classDistance ( Class < ? > from , Class < ? > to , int current ) { return to . isAssignableFrom ( from ) ? to . equals ( from ) ? current : classDistance ( findAssignableAncestor ( from , to ) , to , current + 1 ) : - 1 ; }
Calculates distance between from and to classes counting from current .
11,226
public static int methodDistance ( Method from , Method to ) { return from . getName ( ) . equals ( to . getName ( ) ) && to . getDeclaringClass ( ) . isAssignableFrom ( from . getDeclaringClass ( ) ) ? classDistance ( from . getDeclaringClass ( ) , to . getDeclaringClass ( ) ) : - 1 ; }
Calculates distance between from and to methods .
11,227
public static Map < String , List < Method > > getDeclaredMethodsRecursively ( Class clazz ) { final Map < String , List < Method > > current = Arrays . stream ( clazz . getDeclaredMethods ( ) ) . filter ( m -> ! m . getName ( ) . startsWith ( "lambda" ) ) . collect ( Collectors . groupingBy ( Method :: getName ) ) ; for ( Class interfaceClazz : clazz . getInterfaces ( ) ) { getDeclaredMethodsRecursively ( interfaceClazz ) . forEach ( current :: putIfAbsent ) ; } if ( clazz . getSuperclass ( ) != null ) { getDeclaredMethodsRecursively ( clazz . getSuperclass ( ) ) . forEach ( current :: putIfAbsent ) ; } return current ; }
Recursively collects all declared methods of the clazz and it s ancestors .
11,228
public static Method findMethod ( Class clazz , String methodName ) { final List < Method > methods = getDeclaredMethodsRecursively ( clazz ) . get ( methodName ) ; if ( methods . isEmpty ( ) ) { throw new IllegalArgumentException ( clazz . getName ( ) + "::" + methodName + " not found" ) ; } final List < Method > specificMethods ; if ( methods . size ( ) > 1 ) { specificMethods = methods . stream ( ) . filter ( m -> m . getReturnType ( ) != Object . class ) . collect ( Collectors . toList ( ) ) ; } else { specificMethods = methods ; } if ( specificMethods . size ( ) != 1 ) { throw new IllegalArgumentException ( clazz . getName ( ) + "::" + methodName + " more then one method found, can not decide which one to use. " + methods ) ; } return specificMethods . get ( 0 ) ; }
Finds method with name throws exception if no method found or there are many of them .
11,229
public static < T > Type [ ] resolveActualTypeArgs ( Class < ? extends T > offspring , Class < T > base , Type ... actualArgs ) { if ( offspring == null || base == null || ( actualArgs . length != 0 && actualArgs . length != offspring . getTypeParameters ( ) . length ) ) { throw new IllegalArgumentException ( "offspring and base should not be null, number ot actualArgs should match number of offspring types" ) ; } if ( actualArgs . length == 0 ) { actualArgs = offspring . getTypeParameters ( ) ; } Map < String , Type > typeVariables = new HashMap < > ( ) ; for ( int i = 0 ; i < actualArgs . length ; i ++ ) { TypeVariable < ? > typeVariable = offspring . getTypeParameters ( ) [ i ] ; typeVariables . put ( typeVariable . getName ( ) , actualArgs [ i ] ) ; } List < Type > ancestors = new LinkedList < > ( ) ; if ( offspring . getGenericSuperclass ( ) != null ) { ancestors . add ( offspring . getGenericSuperclass ( ) ) ; } Collections . addAll ( ancestors , offspring . getGenericInterfaces ( ) ) ; for ( Type type : ancestors ) { if ( type instanceof Class < ? > ) { Class < ? > ancestorClass = ( Class < ? > ) type ; if ( base . isAssignableFrom ( ancestorClass ) ) { Type [ ] result = resolveActualTypeArgs ( ( Class < ? extends T > ) ancestorClass , base ) ; if ( result != null ) { return result ; } } } if ( type instanceof ParameterizedType ) { ParameterizedType parameterizedType = ( ParameterizedType ) type ; Type rawType = parameterizedType . getRawType ( ) ; if ( rawType instanceof Class < ? > ) { Class < ? > rawTypeClass = ( Class < ? > ) rawType ; if ( base . isAssignableFrom ( rawTypeClass ) ) { List < Type > resolvedTypes = new LinkedList < > ( ) ; for ( Type t : parameterizedType . getActualTypeArguments ( ) ) { if ( t instanceof TypeVariable < ? > ) { Type resolvedType = typeVariables . get ( ( ( TypeVariable < ? > ) t ) . getName ( ) ) ; resolvedTypes . add ( resolvedType != null ? resolvedType : t ) ; } else { resolvedTypes . add ( t ) ; } } Type [ ] result = resolveActualTypeArgs ( ( Class < ? extends T > ) rawTypeClass , base , resolvedTypes . toArray ( new Type [ ] { } ) ) ; if ( result != null ) { return result ; } } } } } return offspring . equals ( base ) ? actualArgs : new Type [ ] { } ; }
Resolves the actual generic type arguments for a base class as viewed from a subclass or implementation .
11,230
public static List < JoinDescription > unrollChildrenJoins ( Collection < JoinDescription > joins ) { List < JoinDescription > collection = new LinkedList < > ( ) ; for ( JoinDescription joinDescription : joins ) { unrollChildrenInternal ( joinDescription , collection ) ; } return collection ; }
Collect all joins and its children to single collection
11,231
public Note createResponse ( String name , String content , boolean personal ) { return getInstance ( ) . create ( ) . note ( this , name , content , personal ) ; }
Create a response to this note
11,232
public Note createResponse ( String name , String content , boolean personal , Map < String , Object > attributes ) { return getInstance ( ) . create ( ) . note ( this , name , content , personal , attributes ) ; }
Create a response to this note .
11,233
public boolean contains ( Timestamp instant ) { return ( start == null || start . compareTo ( instant ) <= 0 ) && ( end == null || end . compareTo ( instant ) >= 0 ) ; }
True if the given time stamp is inside the interval .
11,234
public TimeInterval minus ( TimeDuration duration ) { return between ( start . minus ( duration ) , end . minus ( duration ) ) ; }
Returns a new interval shifted backward in time by the given duration .
11,235
public void setEnabled ( boolean b ) { super . setEnabled ( b ) ; if ( ! b ) { ( ( JSpinner . DateEditor ) getEditor ( ) ) . getTextField ( ) . setBackground ( UIManager . getColor ( "TextField.inactiveBackground" ) ) ; } }
Enables and disabled the compoment . It also fixes the background bug 4991597 and sets the background explicitely to a TextField . inactiveBackground .
11,236
Double getSum ( String multiRelationName , EntityFilter filter , String numericAttributeName ) { return instance . getSum ( this , multiRelationName , filter , numericAttributeName ) ; }
Get a total of an attribute thru a multi - relation possibly slicing by a filter .
11,237
< T extends Entity > T getRelation ( Class < T > valuesClass , String name ) { return getRelation ( valuesClass , name , true ) ; }
Get a relation by name for this entity .
11,238
< T extends Entity > T getRelation ( Class < T > valuesClass , String name , boolean cachable ) { return instance . getRelation ( this , valuesClass , name , cachable ) ; }
Get a relation by name for this entity . Ignore cache if cachable is false .
11,239
< T extends Entity > EntityCollection < T > getMultiRelation ( String name ) { return getMultiRelation ( name , true ) ; }
Get a multi - value relation by name for this entity .
11,240
< T extends Entity > EntityCollection < T > getMultiRelation ( String name , boolean cachable ) { return instance . getMultiRelation ( this , name , cachable ) ; }
Get a multi - value relation by name for this entity . Ignore cache if cachable is false .
11,241
public void save ( String comment ) throws DataException , ApplicationUnavailableException { assetID = instance . commit ( this , comment ) ; stubAssetID = null ; }
Save any changes to this entity to the VersionOne System with a comment .
11,242
< T extends ListValue > T getListRelation ( Class < T > valuesClass , String name ) { return getRelation ( valuesClass , name , true ) ; }
Method getListRelation .
11,243
< T extends ListValue > void setListRelation ( String attributeName , String value , Class < T > valuesClass ) { instance . setListRelation ( this , attributeName , value , valuesClass ) ; }
Sets a List relation by name .
11,244
< T extends ListValue > Collection < T > getListTypeValues ( Class < T > valuesClass ) { return instance . get ( ) . listTypeValues ( valuesClass ) ; }
Method getListTypeValues .
11,245
< T extends ListValue > IListValueProperty getListValue ( Class < T > valuesClass , String name ) { return new ListValueProperty < T > ( valuesClass , name ) ; }
Get a list value for this entity by name .
11,246
public Project project ( String name , Project parentProject , DateTime beginDate , Schedule schedule , Map < String , Object > attributes ) { Project project = new Project ( instance ) ; project . setName ( name ) ; project . setParentProject ( parentProject ) ; project . setBeginDate ( beginDate ) ; project . setSchedule ( schedule ) ; addAttributes ( project , attributes ) ; project . save ( ) ; return project ; }
Create a new project entity with a name parent project begin date and optional schedule with specified attributes .
11,247
public Team team ( String name , Map < String , Object > attributes ) { Team team = new Team ( instance ) ; team . setName ( name ) ; addAttributes ( team , attributes ) ; team . save ( ) ; return team ; }
Create a new team entity with a name .
11,248
public Iteration iteration ( Project project , Map < String , Object > attributes ) { Iteration iteration = instance . createNew ( Iteration . class , project ) ; addAttributes ( iteration , attributes ) ; iteration . save ( ) ; iteration . makeFuture ( ) ; return iteration ; }
Create a new iteration using suggested system values .
11,249
protected void addAttributes ( Entity entity , Map < String , Object > attributes ) { if ( attributes != null ) { for ( Entry < String , Object > pairs : attributes . entrySet ( ) ) { entity . set ( pairs . getKey ( ) , pairs . getValue ( ) ) ; } } }
Fill attributes for specified entity .
11,250
public Expression expression ( Member author , String content , Expression inReplyTo ) { Expression expression = new Expression ( instance ) ; expression . setAuthor ( author ) ; expression . setContent ( content ) ; expression . setInReplyTo ( inReplyTo ) ; expression . save ( ) ; return expression ; }
Adds new Expression in Reply To an existing Expression .
11,251
protected Action toAction ( Object item ) { if ( item instanceof Action ) { return ( Action ) item ; } else if ( item instanceof String ) { final String definition = ( String ) item ; return new DefaultAction ( definition + "@" + RANDOM . nextInt ( ) , resolveDataFunction ( ( String ) item ) , getMiddleware ( definition ) ) ; } else { String name ; List < Middleware > middleware ; try { name = ( String ) ClassApi . findMethod ( item . getClass ( ) , "getName" ) . invoke ( item ) ; middleware = getMiddleware ( name ) ; } catch ( Throwable t ) { name = item . getClass ( ) . getName ( ) ; middleware = Collections . emptyList ( ) ; } return new DefaultAction ( name + "@" + RANDOM . nextInt ( ) , getDataFunctionExtractor ( ) . apply ( item , DEFAULT_FUNCTION ) , middleware ) ; } }
Convert supplied object to of action if possible .
11,252
public void stateChanged ( ChangeEvent e ) { SpinnerNumberModel model = ( SpinnerNumberModel ) spinner . getModel ( ) ; int value = model . getNumber ( ) . intValue ( ) ; setValue ( value ) ; }
Is invoked when the spinner model changes
11,253
protected void setValue ( int newValue , boolean updateTextField , boolean firePropertyChange ) { int oldValue = value ; if ( newValue < min ) { value = min ; } else if ( newValue > max ) { value = max ; } else { value = newValue ; } if ( updateTextField ) { textField . setText ( Integer . toString ( value ) ) ; textField . setForeground ( Color . black ) ; } if ( firePropertyChange ) { firePropertyChange ( "value" , oldValue , value ) ; } }
Sets the value attribute of the JSpinField object .
11,254
public void setValue ( int newValue ) { setValue ( newValue , true , true ) ; spinner . setValue ( new Integer ( value ) ) ; }
Sets the value . This is a bound property .
11,255
public void caretUpdate ( CaretEvent e ) { try { int testValue = Integer . valueOf ( textField . getText ( ) ) . intValue ( ) ; if ( ( testValue >= min ) && ( testValue <= max ) ) { textField . setForeground ( darkGreen ) ; setValue ( testValue , false , true ) ; } else { textField . setForeground ( Color . red ) ; } } catch ( Exception ex ) { if ( ex instanceof NumberFormatException ) { textField . setForeground ( Color . red ) ; } } textField . repaint ( ) ; }
After any user input the value of the textfield is proofed . Depending on being an integer the value is colored green or red .
11,256
public void actionPerformed ( ActionEvent e ) { if ( textField . getForeground ( ) . equals ( darkGreen ) ) { setValue ( Integer . valueOf ( textField . getText ( ) ) . intValue ( ) ) ; } }
After any user input the value of the textfield is proofed . Depending on being an integer the value is colored green or red . If the textfield is green the enter key is accepted and the new value is set .
11,257
public void setEnabled ( boolean enabled ) { super . setEnabled ( enabled ) ; spinner . setEnabled ( enabled ) ; textField . setEnabled ( enabled ) ; if ( ! enabled ) { textField . setBackground ( UIManager . getColor ( "TextField.inactiveBackground" ) ) ; } }
Enable or disable the JSpinField .
11,258
public static void main ( String [ ] s ) { JFrame frame = new JFrame ( "JSpinField" ) ; frame . getContentPane ( ) . add ( new JSpinField ( ) ) ; frame . pack ( ) ; frame . setVisible ( true ) ; }
Creates a JFrame with a JSpinField inside and can be used for testing .
11,259
private void showLinkError ( ) { Toast . makeText ( mContext , mContext . getString ( R . string . wings_dropbox__error_link ) , Toast . LENGTH_SHORT ) . show ( ) ; }
Displays the link error message .
11,260
private boolean createPhotoFolder ( DropboxAPI < AndroidAuthSession > dropboxApi ) { boolean folderCreated = false ; if ( dropboxApi != null ) { try { dropboxApi . createFolder ( mContext . getString ( R . string . wings_dropbox__photo_folder ) ) ; folderCreated = true ; } catch ( DropboxException e ) { if ( e instanceof DropboxServerException ) { folderCreated = DropboxServerException . _403_FORBIDDEN == ( ( DropboxServerException ) e ) . error ; } } } return folderCreated ; }
Creates a directory for photos if one does not already exist . If the folder already exists this call will do nothing .
11,261
private String requestAccountName ( DropboxAPI < AndroidAuthSession > dropboxApi ) { String accountName = null ; if ( dropboxApi != null ) { try { accountName = dropboxApi . accountInfo ( ) . displayName ; } catch ( DropboxException e ) { } } return accountName ; }
Requests the linked account name .
11,262
private String requestShareUrl ( DropboxAPI < AndroidAuthSession > dropboxApi ) { String shareUrl = null ; if ( dropboxApi != null ) { try { shareUrl = dropboxApi . share ( "/" + mContext . getString ( R . string . wings_dropbox__photo_folder ) ) . url ; } catch ( DropboxException e ) { } } return shareUrl ; }
Requests the share url of the linked folder .
11,263
private void storeAccountParams ( String accountName , String shareUrl , String accessToken ) { Editor editor = PreferenceManager . getDefaultSharedPreferences ( mContext ) . edit ( ) ; editor . putString ( mContext . getString ( R . string . wings_dropbox__account_name_key ) , accountName ) ; editor . putString ( mContext . getString ( R . string . wings_dropbox__share_url_key ) , shareUrl ) ; editor . putString ( mContext . getString ( R . string . wings_dropbox__access_token_key ) , accessToken ) ; editor . putBoolean ( mContext . getString ( R . string . wings_dropbox__link_key ) , true ) ; editor . apply ( ) ; }
Stores the account params in persisted storage .
11,264
private void removeAccountParams ( ) { Editor editor = PreferenceManager . getDefaultSharedPreferences ( mContext ) . edit ( ) ; editor . remove ( mContext . getString ( R . string . wings_dropbox__account_name_key ) ) ; editor . remove ( mContext . getString ( R . string . wings_dropbox__share_url_key ) ) ; editor . remove ( mContext . getString ( R . string . wings_dropbox__access_token_key ) ) ; editor . putBoolean ( mContext . getString ( R . string . wings_dropbox__link_key ) , false ) ; editor . apply ( ) ; }
Removes the account params from persisted storage .
11,265
private String getLinkedAccessToken ( ) { SharedPreferences preferences = PreferenceManager . getDefaultSharedPreferences ( mContext ) ; return preferences . getString ( mContext . getString ( R . string . wings_dropbox__access_token_key ) , null ) ; }
Gets the stored access token associated with the linked account .
11,266
private String getLinkedShareUrl ( ) { SharedPreferences preferences = PreferenceManager . getDefaultSharedPreferences ( mContext ) ; return preferences . getString ( mContext . getString ( R . string . wings_dropbox__share_url_key ) , null ) ; }
Gets the share url associated with the linked account .
11,267
public void checkConnection ( ) throws ConnectionException { IAPIConnector connector = populateHeaders ( new V1APIConnector ( getApplicationURL ( ) + MEMBER_CONNECT_PARAM , username , password , ApiClientInternals . getProxyProvider ( proxySettings ) ) ) ; try { connector . getData ( ) . close ( ) ; } catch ( Exception ex ) { throw new ConnectionException ( "Application not found at the URL: " + getApplicationURL ( ) , ex ) ; } }
Check server connection and authentication .
11,268
public void checkVersion ( String version ) throws ConnectionException { MetaModel meta = createMetaModel ( ) ; meta . getAssetType ( "Member" ) ; if ( ( version != null ) && ( version . length ( ) > 0 ) && ( ( meta . getVersion ( ) == null ) || ( meta . getVersion ( ) . compareTo ( new Version ( version ) ) < 0 ) ) ) { throw new ConnectionException ( MessageFormat . format ( "VersionOne Release {0} or above is required (found {1})." , version , meta . getVersion ( ) ) ) ; } }
Checking version of VersionOne .
11,269
public void checkAuthentication ( ) throws ConnectionException { IServices services = new Services ( createMetaModel ( ) , populateHeaders ( new V1APIConnector ( getApplicationURL ( ) + "rest-1.v1/" , username , password , ApiClientInternals . getProxyProvider ( proxySettings ) ) ) ) ; Oid loggedin ; try { loggedin = services . getLoggedIn ( ) ; } catch ( Exception ex ) { throw new ConnectionException ( "Unable to log in. Incorrect username or password." , ex ) ; } if ( loggedin . isNull ( ) ) { throw new ConnectionException ( "Unable to retrieve logged in member." ) ; } }
Checking authentication .
11,270
public void copyFrom ( Rule rule ) { setPolicy ( rule . getPolicy ( ) ) ; setCaptureStart ( rule . getCaptureStart ( ) ) ; setCaptureEnd ( rule . getCaptureEnd ( ) ) ; setPrivateComment ( rule . getPrivateComment ( ) ) ; setPublicComment ( rule . getPublicComment ( ) ) ; setRetrievalStart ( rule . getRetrievalStart ( ) ) ; setRetrievalEnd ( rule . getRetrievalEnd ( ) ) ; setSecondsSinceCapture ( rule . getSecondsSinceCapture ( ) ) ; setSurt ( rule . getSurt ( ) ) ; setWho ( rule . getWho ( ) ) ; setEnabled ( rule . getEnabled ( ) ) ; setExactMatch ( rule . isExactMatch ( ) ) ; }
Populate the rule data fields by copying them from a given rule .
11,271
public boolean matches ( String surt , Date captureDate , Date retrievalDate , String who2 ) { return ( who == null || who . length ( ) == 0 || who . equals ( who2 ) ) && matches ( surt , captureDate , retrievalDate ) ; }
Return true if the given request matches against this rule .
11,272
private void startOpenSessionRequest ( final Activity activity , final Fragment fragment ) { mLinkRequestState = STATE_OPEN_SESSION_REQUEST ; Session . StatusCallback statusCallback = new Session . StatusCallback ( ) { public void call ( Session session , SessionState state , Exception exception ) { if ( mLinkRequestState == STATE_OPEN_SESSION_REQUEST && state . isOpened ( ) ) { if ( ! startPublishPermissionsRequest ( activity , fragment ) ) { handleLinkError ( ) ; } } } } ; Session session = new Session ( activity ) ; Session . setActiveSession ( session ) ; List < String > readPermissions = new LinkedList < String > ( ) ; readPermissions . add ( PERMISSION_PUBLIC_PROFILE ) ; readPermissions . add ( PERMISSION_USER_PHOTOS ) ; OpenRequest openRequest ; if ( fragment == null ) { openRequest = new OpenRequest ( activity ) ; } else { openRequest = new OpenRequest ( fragment ) ; } openRequest . setLoginBehavior ( SessionLoginBehavior . SSO_ONLY ) ; openRequest . setPermissions ( readPermissions ) ; openRequest . setDefaultAudience ( SessionDefaultAudience . EVERYONE ) ; openRequest . setCallback ( statusCallback ) ; session . openForRead ( openRequest ) ; }
Opens a new session with read permissions .
11,273
private boolean isFacebookAppInstalled ( ) { boolean isInstalled = false ; try { mContext . getPackageManager ( ) . getApplicationInfo ( FACEBOOK_APP_PACKAGE , 0 ) ; isInstalled = true ; } catch ( PackageManager . NameNotFoundException e ) { } return isInstalled ; }
Checks if the Facebook native app is installed on the device .
11,274
private boolean link ( FacebookSettings settings ) { boolean isSuccessful = false ; if ( settings != null ) { storeSettings ( settings ) ; notifyLinkStateChanged ( new LinkEvent ( true ) ) ; isSuccessful = true ; } return isSuccessful ; }
Links an account .
11,275
private void showFacebookAppError ( ) { Toast . makeText ( mContext , mContext . getString ( R . string . wings_facebook__error_facebook_app ) , Toast . LENGTH_SHORT ) . show ( ) ; }
Displays the Facebook app error message .
11,276
private void storeSettings ( FacebookSettings settings ) { int destinationId = settings . getDestinationId ( ) ; String accountName = settings . getAccountName ( ) ; String albumName = settings . getAlbumName ( ) ; String albumGraphPath = settings . getAlbumGraphPath ( ) ; String pageAccessToken = settings . optPageAccessToken ( ) ; String photoPrivacy = settings . optPhotoPrivacy ( ) ; Editor editor = PreferenceManager . getDefaultSharedPreferences ( mContext ) . edit ( ) ; editor . putInt ( mContext . getString ( R . string . wings_facebook__destination_id_key ) , destinationId ) ; editor . putString ( mContext . getString ( R . string . wings_facebook__account_name_key ) , accountName ) ; editor . putString ( mContext . getString ( R . string . wings_facebook__album_name_key ) , albumName ) ; editor . putString ( mContext . getString ( R . string . wings_facebook__album_graph_path_key ) , albumGraphPath ) ; if ( ! TextUtils . isEmpty ( pageAccessToken ) ) { editor . putString ( mContext . getString ( R . string . wings_facebook__page_access_token_key ) , pageAccessToken ) ; } if ( ! TextUtils . isEmpty ( photoPrivacy ) ) { editor . putString ( mContext . getString ( R . string . wings_facebook__photo_privacy_key ) , photoPrivacy ) ; } editor . putBoolean ( mContext . getString ( R . string . wings_facebook__link_key ) , true ) ; editor . apply ( ) ; }
Stores the link settings in persisted storage .
11,277
private FacebookSettings fetchSettings ( ) { SharedPreferences preferences = PreferenceManager . getDefaultSharedPreferences ( mContext ) ; if ( ! preferences . getBoolean ( mContext . getString ( R . string . wings_facebook__link_key ) , false ) ) { return null ; } int destinationId = preferences . getInt ( mContext . getString ( R . string . wings_facebook__destination_id_key ) , DestinationId . UNLINKED ) ; String accountName = preferences . getString ( mContext . getString ( R . string . wings_facebook__account_name_key ) , null ) ; String albumName = preferences . getString ( mContext . getString ( R . string . wings_facebook__album_name_key ) , null ) ; String albumGraphPath = preferences . getString ( mContext . getString ( R . string . wings_facebook__album_graph_path_key ) , null ) ; String pageAccessToken = preferences . getString ( mContext . getString ( R . string . wings_facebook__page_access_token_key ) , null ) ; String photoPrivacy = preferences . getString ( mContext . getString ( R . string . wings_facebook__photo_privacy_key ) , null ) ; return FacebookSettings . newInstance ( destinationId , accountName , albumName , albumGraphPath , pageAccessToken , photoPrivacy ) ; }
Fetches the link settings from persisted storage .
11,278
private void removeSettings ( ) { Editor editor = PreferenceManager . getDefaultSharedPreferences ( mContext ) . edit ( ) ; editor . remove ( mContext . getString ( R . string . wings_facebook__destination_id_key ) ) ; editor . remove ( mContext . getString ( R . string . wings_facebook__account_name_key ) ) ; editor . remove ( mContext . getString ( R . string . wings_facebook__album_name_key ) ) ; editor . remove ( mContext . getString ( R . string . wings_facebook__album_graph_path_key ) ) ; editor . remove ( mContext . getString ( R . string . wings_facebook__page_access_token_key ) ) ; editor . remove ( mContext . getString ( R . string . wings_facebook__photo_privacy_key ) ) ; editor . putBoolean ( mContext . getString ( R . string . wings_facebook__link_key ) , false ) ; editor . apply ( ) ; }
Removes the link settings from persisted storage .
11,279
public Collection < Epic > getChildEpics ( EpicFilter filter ) { filter = ( filter != null ) ? filter : new EpicFilter ( ) ; filter . parent . clear ( ) ; filter . parent . add ( this ) ; return getInstance ( ) . get ( ) . epics ( filter ) ; }
Epics that are immediate children of this Epic .
11,280
public Collection < Story > getChildStories ( StoryFilter filter ) { filter = ( filter != null ) ? filter : new StoryFilter ( ) ; filter . epic . clear ( ) ; filter . epic . add ( this ) ; return getInstance ( ) . get ( ) . story ( filter ) ; }
Stories that are immediate children of this Epic .
11,281
public AceExperiment getExperiment ( String exname ) { if ( this . eidMap . containsKey ( exname ) ) { return this . experimentMap . get ( eidMap . get ( exname ) ) ; } else { return null ; } }
Return a Experiment by given experiment name .
11,282
public boolean add ( D item ) throws UnsupportedOperationException { readOnlyGuardCondition ( ) ; instance . addRelation ( entity , writeAttributeName , item ) ; entity . save ( ) ; return true ; }
Add item to collection .
11,283
public void clear ( ) { readOnlyGuardCondition ( ) ; for ( D item : this ) { instance . removeRelation ( entity , writeAttributeName , item ) ; } entity . save ( ) ; }
Removes all of the elements from this collection .
11,284
public RegressionSuite createRegressionSuite ( String name , Map < String , Object > attributes ) { return getInstance ( ) . create ( ) . regressionSuite ( name , this , attributes ) ; }
Create a new Regression Suite with title assigned with this Regression Plan .
11,285
public Collection < RegressionSuite > getRegressionSuites ( RegressionSuiteFilter filter ) { filter = ( filter != null ) ? filter : new RegressionSuiteFilter ( ) ; filter . regressionPlan . clear ( ) ; filter . regressionPlan . add ( this ) ; return getInstance ( ) . get ( ) . regressionSuites ( filter ) ; }
Projects associated with this TestSuite .
11,286
public void writeTo ( OutputStream output ) throws ApplicationUnavailableException { InputStream input = getInstance ( ) . getReader ( this ) ; try { V1Util . copyStream ( input , output ) ; } catch ( IOException e ) { throw new ApplicationUnavailableException ( e ) ; } finally { if ( input != null ) { try { input . close ( ) ; } catch ( IOException e ) { } } } }
Write this attachment s content to the output stream .
11,287
public void readFrom ( InputStream input ) throws ApplicationUnavailableException , AttachmentLengthExceededException { OutputStream output = null ; try { output = getInstance ( ) . getWriter ( this , getContentType ( ) ) ; V1Util . copyStream ( input , output ) ; getInstance ( ) . commitWriteStream ( this ) ; } catch ( IOException e ) { throw new ApplicationUnavailableException ( e ) ; } finally { if ( output != null ) { try { output . close ( ) ; } catch ( IOException e ) { } } } }
Read the attachment s content from the input stream . Set the ContentType and Filename properties before calling this method .
11,288
public String generateId ( ) throws IOException { HashCode currentHash = this . getRawComponentHash ( ) ; currentHash = AceFunctions . generateHCId ( currentHash . asBytes ( ) , this . ic . getRawComponentHash ( ) . asBytes ( ) ) ; for ( AceRecord r : this . ic . getSoilLayers ( ) ) { currentHash = AceFunctions . generateHCId ( currentHash . asBytes ( ) , r . getRawComponentHash ( ) . asBytes ( ) ) ; } for ( AceEvent e : this . events . asList ( ) ) { currentHash = AceFunctions . generateHCId ( currentHash . asBytes ( ) , e . getRawComponentHash ( ) . asBytes ( ) ) ; } currentHash = AceFunctions . generateHCId ( currentHash . asBytes ( ) , this . observed . getRawComponentHash ( ) . asBytes ( ) ) ; for ( AceRecord r : this . observed . getTimeseries ( ) ) { currentHash = AceFunctions . generateHCId ( currentHash . asBytes ( ) , r . getRawComponentHash ( ) . asBytes ( ) ) ; } return currentHash . toString ( ) ; }
able to trigger this method?
11,289
public void setDateFormatString ( String dfString ) { for ( int i = 0 ; i < 4 ; i ++ ) { ( ( JDateChooser ) components [ i ] ) . setDateFormatString ( dfString ) ; } }
Sets the date format string . E . g MMMMM d yyyy will result in July 21 2004 if this is the selected date and locale is English .
11,290
public void setLocale ( Locale locale ) { for ( int i = 0 ; i < 5 ; i ++ ) { components [ i ] . setLocale ( locale ) ; } }
Sets the locale of the first 4 JDateChoosers .
11,291
public void updateStatus ( ) { String hostaddr = null ; try { hostaddr = InetAddress . getByName ( ip ) . getHostAddress ( ) ; } catch ( UnknownHostException e ) { online = false ; latency = Long . MAX_VALUE ; return ; } int total = 0 ; long totalPing = 0 ; int times = 4 ; while ( total < times ) { total ++ ; long start = System . currentTimeMillis ( ) ; SocketAddress sockaddr = new InetSocketAddress ( hostaddr , port ) ; try ( Socket socket = new Socket ( ) ) { socket . connect ( sockaddr , 1000 ) ; } catch ( Exception e ) { online = false ; return ; } totalPing += ( System . currentTimeMillis ( ) - start ) ; } online = true ; latency = totalPing / total ; }
Update the proxy status
11,292
public void updateAnonymity ( ) throws IOException { ProxyBinResponse response = GhostMeHelper . getMyInformation ( this . getJavaNetProxy ( ) ) ; if ( ! response . getOrigin ( ) . equalsIgnoreCase ( this . getIp ( ) ) ) { anonymous = false ; return ; } if ( ! response . getHeaders ( ) . get ( "X-Forwarded-For" ) . equalsIgnoreCase ( this . getIp ( ) ) ) { anonymous = false ; return ; } if ( ! response . getHeaders ( ) . get ( "X-Real-Ip" ) . equalsIgnoreCase ( this . getIp ( ) ) ) { anonymous = false ; return ; } anonymous = true ; }
Update the anonymous status of the proxy
11,293
public final String encodeBytes ( byte [ ] bytes ) { logger . entry ( ) ; String base64String = Base64Utils . encode ( bytes ) ; logger . exit ( ) ; return base64String ; }
This method encodes a byte array into a base 64 string .
11,294
public final byte [ ] decodeString ( String base64String ) { logger . entry ( ) ; byte [ ] decodedBytes = Base64Utils . decode ( base64String ) ; logger . exit ( ) ; return decodedBytes ; }
This method decodes a base 64 string into its original bytes .
11,295
public final byte [ ] encryptString ( SecretKey sharedKey , String string ) { logger . entry ( ) ; try ( ByteArrayInputStream input = new ByteArrayInputStream ( string . getBytes ( "UTF-8" ) ) ; ByteArrayOutputStream output = new ByteArrayOutputStream ( ) ) { encryptStream ( sharedKey , input , output ) ; output . flush ( ) ; byte [ ] encryptedString = output . toByteArray ( ) ; logger . exit ( ) ; return encryptedString ; } catch ( IOException e ) { RuntimeException exception = new RuntimeException ( "An unexpected exception occured while trying to encrypt a string." , e ) ; logger . error ( exception . toString ( ) ) ; throw exception ; } }
This method encrypts a string using a shared key .
11,296
public final String decryptString ( SecretKey sharedKey , byte [ ] encryptedString ) { logger . entry ( ) ; try ( ByteArrayInputStream input = new ByteArrayInputStream ( encryptedString ) ; ByteArrayOutputStream output = new ByteArrayOutputStream ( ) ) { decryptStream ( sharedKey , input , output ) ; output . flush ( ) ; String string = output . toString ( "UTF-8" ) ; logger . exit ( ) ; return string ; } catch ( IOException e ) { RuntimeException exception = new RuntimeException ( "An unexpected exception occured while trying to decrypt a string." , e ) ; logger . error ( exception . toString ( ) ) ; throw exception ; } }
This method decrypts a string using a shared key .
11,297
public final void encryptStream ( SecretKey sharedKey , InputStream input , OutputStream output ) throws IOException { logger . entry ( ) ; CipherOutputStream cipherOutput = null ; byte [ ] buffer = new byte [ 2048 ] ; try { logger . debug ( "Creating a special output stream to do the work..." ) ; cipherOutput = encryptionOutputStream ( sharedKey , output ) ; logger . debug ( "Reading from the input and writing to the encrypting output stream..." ) ; int bytesRead ; while ( ( bytesRead = input . read ( buffer ) ) != - 1 ) { cipherOutput . write ( buffer , 0 , bytesRead ) ; } cipherOutput . flush ( ) ; } finally { logger . debug ( "Purging any plaintext hanging around in memory..." ) ; Arrays . fill ( buffer , ( byte ) 0 ) ; if ( cipherOutput != null ) cipherOutput . close ( ) ; } logger . exit ( ) ; }
This method encrypts a byte stream using a shared key .
11,298
public final void decryptStream ( SecretKey sharedKey , InputStream input , OutputStream output ) throws IOException { logger . entry ( ) ; CipherInputStream cipherInput = null ; try { logger . debug ( "Creating a special input stream to do the work..." ) ; cipherInput = decryptionInputStream ( sharedKey , input ) ; logger . debug ( "Reading bytes, decrypting them, and writing them out..." ) ; IOUtils . copy ( cipherInput , output ) ; output . flush ( ) ; } finally { if ( cipherInput != null ) cipherInput . close ( ) ; } logger . exit ( ) ; }
This method decrypts a byte stream from an encrypted byte stream .
11,299
public void cancel ( ) { if ( task != null && ! task . isCancelled ( ) && task . getStatus ( ) != AsyncTask . Status . FINISHED ) { task . cancel ( true ) ; } }
Cancel the task