idx
int64 0
165k
| question
stringlengths 73
5.81k
| target
stringlengths 5
918
|
---|---|---|
1,300 |
public OTMConnection acquireConnection ( PBKey pbKey ) { TransactionFactory txFactory = getTransactionFactory ( ) ; return txFactory . acquireConnection ( pbKey ) ; }
|
Obtain an OTMConnection for the given persistence broker key
|
1,301 |
public void sendMessageToAgents ( String [ ] agent_name , String msgtype , Object message_content , Connector connector ) { HashMap < String , Object > hm = new HashMap < String , Object > ( ) ; hm . put ( "performative" , msgtype ) ; hm . put ( SFipa . CONTENT , message_content ) ; IComponentIdentifier [ ] ici = new IComponentIdentifier [ agent_name . length ] ; for ( int i = 0 ; i < agent_name . length ; i ++ ) { ici [ i ] = ( IComponentIdentifier ) connector . getAgentID ( agent_name [ i ] ) ; } ( ( IMessageService ) connector . getMessageService ( ) ) . deliverMessage ( hm , "fipa" , ici ) ; }
|
This method sends the same message to many agents .
|
1,302 |
public void sendMessageToAgentsWithExtraProperties ( String [ ] agent_name , String msgtype , Object message_content , ArrayList < Object > properties , Connector connector ) { HashMap < String , Object > hm = new HashMap < String , Object > ( ) ; hm . put ( "performative" , msgtype ) ; hm . put ( SFipa . CONTENT , message_content ) ; for ( Object property : properties ) { hm . put ( ( String ) ( ( Tuple ) property ) . get ( 0 ) , ( ( Tuple ) property ) . get ( 1 ) ) ; } IComponentIdentifier [ ] ici = new IComponentIdentifier [ agent_name . length ] ; for ( int i = 0 ; i < agent_name . length ; i ++ ) { ici [ i ] = ( IComponentIdentifier ) connector . getAgentID ( agent_name [ i ] ) ; } ( ( IMessageService ) connector . getMessageService ( ) ) . deliverMessage ( hm , "fipa" , ici ) ; }
|
This method works as the one above adding some properties to the message
|
1,303 |
public void lock ( Object obj , int lockMode ) throws LockNotGrantedException { if ( log . isDebugEnabled ( ) ) log . debug ( "lock object was called on tx " + this + ", object is " + obj . toString ( ) ) ; checkOpen ( ) ; RuntimeObject rtObject = new RuntimeObject ( obj , this ) ; lockAndRegister ( rtObject , lockMode , isImplicitLocking ( ) , getRegistrationList ( ) ) ; }
|
Upgrade the lock on the given object to the given lock mode . The call has no effect if the object s current lock is already at or above that level of lock mode .
|
1,304 |
protected synchronized void doWriteObjects ( boolean isFlush ) throws TransactionAbortedException , LockNotGrantedException { if ( ! getBroker ( ) . isInTransaction ( ) ) { if ( log . isDebugEnabled ( ) ) log . debug ( "call beginTransaction() on PB instance" ) ; broker . beginTransaction ( ) ; } performTransactionAwareBeforeCommit ( ) ; objectEnvelopeTable . writeObjects ( isFlush ) ; namedRootsMap . performDeletion ( ) ; namedRootsMap . performInsert ( ) ; namedRootsMap . afterWriteCleanup ( ) ; }
|
Write objects to data store but don t release the locks . I don t know what we should do if we are in a checkpoint and we need to abort .
|
1,305 |
protected synchronized void doClose ( ) { try { LockManager lm = getImplementation ( ) . getLockManager ( ) ; Enumeration en = objectEnvelopeTable . elements ( ) ; while ( en . hasMoreElements ( ) ) { ObjectEnvelope oe = ( ObjectEnvelope ) en . nextElement ( ) ; lm . releaseLock ( this , oe . getIdentity ( ) , oe . getObject ( ) ) ; } for ( Iterator it = unmaterializedLocks . iterator ( ) ; it . hasNext ( ) ; ) { lm . releaseLock ( this , it . next ( ) ) ; } unRegisterFromAllIndirectionHandlers ( ) ; unRegisterFromAllCollectionProxies ( ) ; } finally { if ( log . isDebugEnabled ( ) ) log . debug ( "Close Transaction and release current PB " + broker + " on tx " + this ) ; implementation . getTxManager ( ) . deregisterTx ( this ) ; refresh ( ) ; } }
|
Close a transaction and do all the cleanup associated with it .
|
1,306 |
protected void refresh ( ) { if ( log . isDebugEnabled ( ) ) log . debug ( "Refresh this transaction for reuse: " + this ) ; try { objectEnvelopeTable . refresh ( ) ; } catch ( Exception e ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "error closing object envelope table : " + e . getMessage ( ) ) ; e . printStackTrace ( ) ; } } cleanupBroker ( ) ; broker = null ; clearRegistrationList ( ) ; unmaterializedLocks . clear ( ) ; txStatus = Status . STATUS_NO_TRANSACTION ; }
|
cleanup tx and prepare for reuse
|
1,307 |
public void abort ( ) { if ( txStatus == Status . STATUS_NO_TRANSACTION || txStatus == Status . STATUS_UNKNOWN || txStatus == Status . STATUS_ROLLEDBACK ) { log . info ( "Nothing to abort, tx is not active - status is " + TxUtil . getStatusString ( txStatus ) ) ; return ; } if ( txStatus != Status . STATUS_ACTIVE && txStatus != Status . STATUS_PREPARED && txStatus != Status . STATUS_MARKED_ROLLBACK ) { throw new IllegalStateException ( "Illegal state for abort call, state was '" + TxUtil . getStatusString ( txStatus ) + "'" ) ; } if ( log . isEnabledFor ( Logger . INFO ) ) { log . info ( "Abort transaction was called on tx " + this ) ; } try { try { doAbort ( ) ; } catch ( Exception e ) { log . error ( "Error while abort transaction, will be skipped" , e ) ; } this . implementation . getTxManager ( ) . abortExternalTx ( this ) ; try { if ( hasBroker ( ) && getBroker ( ) . isInTransaction ( ) ) { getBroker ( ) . abortTransaction ( ) ; } } catch ( Exception e ) { log . error ( "Error while do abort used broker instance, will be skipped" , e ) ; } } finally { txStatus = Status . STATUS_ROLLEDBACK ; doClose ( ) ; } }
|
Abort and close the transaction . Calling abort abandons all persistent object modifications and releases the associated locks . Aborting a transaction does not restore the state of modified transient objects
|
1,308 |
public Object getObjectByIdentity ( Identity id ) throws PersistenceBrokerException { checkOpen ( ) ; ObjectEnvelope envelope = objectEnvelopeTable . getByIdentity ( id ) ; if ( envelope != null ) { return ( envelope . needsDelete ( ) ? null : envelope . getObject ( ) ) ; } else { return getBroker ( ) . getObjectByIdentity ( id ) ; } }
|
Get object by identity . First lookup among objects registered in the transaction then in persistent storage .
|
1,309 |
private void lockAndRegisterReferences ( ClassDescriptor cld , Object sourceObject , int lockMode , List registeredObjects ) throws LockNotGrantedException { if ( implicitLocking ) { Iterator i = cld . getObjectReferenceDescriptors ( true ) . iterator ( ) ; while ( i . hasNext ( ) ) { ObjectReferenceDescriptor rds = ( ObjectReferenceDescriptor ) i . next ( ) ; Object refObj = rds . getPersistentField ( ) . get ( sourceObject ) ; if ( refObj != null ) { boolean isProxy = ProxyHelper . isProxy ( refObj ) ; RuntimeObject rt = isProxy ? new RuntimeObject ( refObj , this , false ) : new RuntimeObject ( refObj , this ) ; if ( ! registrationList . contains ( rt . getIdentity ( ) ) ) { lockAndRegister ( rt , lockMode , registeredObjects ) ; } } } } }
|
we only use the registrationList map if the object is not a proxy . During the reference locking we will materialize objects and they will enter the registered for lock map .
|
1,310 |
public void afterMaterialization ( IndirectionHandler handler , Object materializedObject ) { try { Identity oid = handler . getIdentity ( ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "deferred registration: " + oid ) ; if ( ! isOpen ( ) ) { log . error ( "Proxy object materialization outside of a running tx, obj=" + oid ) ; try { throw new Exception ( "Proxy object materialization outside of a running tx, obj=" + oid ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } ClassDescriptor cld = getBroker ( ) . getClassDescriptor ( materializedObject . getClass ( ) ) ; RuntimeObject rt = new RuntimeObject ( materializedObject , oid , cld , false , false ) ; lockAndRegister ( rt , Transaction . READ , isImplicitLocking ( ) , getRegistrationList ( ) ) ; } catch ( Throwable t ) { log . error ( "Register materialized object with this tx failed" , t ) ; throw new LockNotGrantedException ( t . getMessage ( ) ) ; } unregisterFromIndirectionHandler ( handler ) ; }
|
this callback is invoked after an Object is materialized within an IndirectionHandler . this callback allows to defer registration of objects until it s really neccessary .
|
1,311 |
public void afterLoading ( CollectionProxyDefaultImpl colProxy ) { if ( log . isDebugEnabled ( ) ) log . debug ( "loading a proxied collection a collection: " + colProxy ) ; Collection data = colProxy . getData ( ) ; for ( Iterator iterator = data . iterator ( ) ; iterator . hasNext ( ) ; ) { Object o = iterator . next ( ) ; if ( ! isOpen ( ) ) { log . error ( "Collection proxy materialization outside of a running tx, obj=" + o ) ; try { throw new Exception ( "Collection proxy materialization outside of a running tx, obj=" + o ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } else { Identity oid = getBroker ( ) . serviceIdentity ( ) . buildIdentity ( o ) ; ClassDescriptor cld = getBroker ( ) . getClassDescriptor ( ProxyHelper . getRealClass ( o ) ) ; RuntimeObject rt = new RuntimeObject ( o , oid , cld , false , ProxyHelper . isProxy ( o ) ) ; lockAndRegister ( rt , Transaction . READ , isImplicitLocking ( ) , getRegistrationList ( ) ) ; } } unregisterFromCollectionProxy ( colProxy ) ; }
|
Remove colProxy from list of pending collections and register its contents with the transaction .
|
1,312 |
protected boolean isTransient ( ClassDescriptor cld , Object obj , Identity oid ) { boolean isNew = oid != null && oid . isTransient ( ) ; if ( ! isNew ) { final PersistenceBroker pb = getBroker ( ) ; if ( cld == null ) { cld = pb . getClassDescriptor ( obj . getClass ( ) ) ; } isNew = pb . serviceBrokerHelper ( ) . hasNullPKField ( cld , obj ) ; if ( ! isNew ) { if ( oid == null ) { oid = pb . serviceIdentity ( ) . buildIdentity ( cld , obj ) ; } final ObjectEnvelope mod = objectEnvelopeTable . getByIdentity ( oid ) ; if ( mod != null ) { isNew = mod . needsInsert ( ) ; } else { isNew = pb . serviceObjectCache ( ) . lookup ( oid ) == null && ! pb . serviceBrokerHelper ( ) . doesExist ( cld , oid , obj ) ; } } } return isNew ; }
|
Detect new objects .
|
1,313 |
private License getLicense ( final String licenseId ) { License result = null ; final Set < DbLicense > matchingLicenses = licenseMatcher . getMatchingLicenses ( licenseId ) ; if ( matchingLicenses . isEmpty ( ) ) { result = DataModelFactory . createLicense ( "#" + licenseId + "# (to be identified)" , NOT_IDENTIFIED_YET , NOT_IDENTIFIED_YET , NOT_IDENTIFIED_YET , NOT_IDENTIFIED_YET ) ; result . setUnknown ( true ) ; } else { if ( matchingLicenses . size ( ) > 1 && LOG . isWarnEnabled ( ) ) { LOG . warn ( String . format ( "%s matches multiple licenses %s. " + "Please run the report showing multiple matching on licenses" , licenseId , matchingLicenses . toString ( ) ) ) ; } result = mapper . getLicense ( matchingLicenses . iterator ( ) . next ( ) ) ; } return result ; }
|
Returns a licenses regarding its Id and a fake on if no license exist with such an Id
|
1,314 |
private String [ ] getHeaders ( ) { final List < String > headers = new ArrayList < > ( ) ; if ( decorator . getShowSources ( ) ) { headers . add ( SOURCE_FIELD ) ; } if ( decorator . getShowSourcesVersion ( ) ) { headers . add ( SOURCE_VERSION_FIELD ) ; } if ( decorator . getShowTargets ( ) ) { headers . add ( TARGET_FIELD ) ; } if ( decorator . getShowTargetsDownloadUrl ( ) ) { headers . add ( DOWNLOAD_URL_FIELD ) ; } if ( decorator . getShowTargetsSize ( ) ) { headers . add ( SIZE_FIELD ) ; } if ( decorator . getShowScopes ( ) ) { headers . add ( SCOPE_FIELD ) ; } if ( decorator . getShowLicenses ( ) ) { headers . add ( LICENSE_FIELD ) ; } if ( decorator . getShowLicensesLongName ( ) ) { headers . add ( LICENSE_LONG_NAME_FIELD ) ; } if ( decorator . getShowLicensesUrl ( ) ) { headers . add ( LICENSE_URL_FIELD ) ; } if ( decorator . getShowLicensesComment ( ) ) { headers . add ( LICENSE_COMMENT_FIELD ) ; } return headers . toArray ( new String [ headers . size ( ) ] ) ; }
|
Init the headers of the table regarding the filters
|
1,315 |
public InputStream getStream ( String url , RasterLayer layer ) throws IOException { if ( layer instanceof ProxyLayerSupport ) { ProxyLayerSupport proxyLayer = ( ProxyLayerSupport ) layer ; if ( proxyLayer . isUseCache ( ) && null != cacheManagerService ) { Object cachedObject = cacheManagerService . get ( proxyLayer , CacheCategory . RASTER , url ) ; if ( null != cachedObject ) { testRecorder . record ( TEST_RECORDER_GROUP , TEST_RECORDER_GET_FROM_CACHE ) ; return new ByteArrayInputStream ( ( byte [ ] ) cachedObject ) ; } else { testRecorder . record ( TEST_RECORDER_GROUP , TEST_RECORDER_PUT_IN_CACHE ) ; InputStream stream = super . getStream ( url , proxyLayer ) ; ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ; int b ; while ( ( b = stream . read ( ) ) >= 0 ) { os . write ( b ) ; } cacheManagerService . put ( proxyLayer , CacheCategory . RASTER , url , os . toByteArray ( ) , getLayerEnvelope ( proxyLayer ) ) ; return new ByteArrayInputStream ( ( byte [ ] ) os . toByteArray ( ) ) ; } } } return super . getStream ( url , layer ) ; }
|
Get the contents from the request URL .
|
1,316 |
private Envelope getLayerEnvelope ( ProxyLayerSupport layer ) { Bbox bounds = layer . getLayerInfo ( ) . getMaxExtent ( ) ; return new Envelope ( bounds . getX ( ) , bounds . getMaxX ( ) , bounds . getY ( ) , bounds . getMaxY ( ) ) ; }
|
Return the max bounds of the layer as envelope .
|
1,317 |
private static String buildErrorMsg ( List < String > dependencies , String message ) { final StringBuilder buffer = new StringBuilder ( ) ; boolean isFirstElement = true ; for ( String dependency : dependencies ) { if ( ! isFirstElement ) { buffer . append ( ", " ) ; } buffer . append ( dependency ) ; isFirstElement = false ; } return String . format ( message , buffer . toString ( ) ) ; }
|
Get the error message with the dependencies appended
|
1,318 |
protected Query buildPrefetchQuery ( Collection ids ) { CollectionDescriptor cds = getCollectionDescriptor ( ) ; QueryByCriteria query = buildPrefetchQuery ( ids , cds . getForeignKeyFieldDescriptors ( getItemClassDescriptor ( ) ) ) ; if ( ! cds . getOrderBy ( ) . isEmpty ( ) ) { Iterator iter = cds . getOrderBy ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { query . addOrderBy ( ( FieldHelper ) iter . next ( ) ) ; } } return query ; }
|
Build the query to perform a batched read get orderBy settings from CollectionDescriptor
|
1,319 |
protected void associateBatched ( Collection owners , Collection children ) { CollectionDescriptor cds = getCollectionDescriptor ( ) ; PersistentField field = cds . getPersistentField ( ) ; PersistenceBroker pb = getBroker ( ) ; Class ownerTopLevelClass = pb . getTopLevelClass ( getOwnerClassDescriptor ( ) . getClassOfObject ( ) ) ; Class collectionClass = cds . getCollectionClass ( ) ; HashMap ownerIdsToLists = new HashMap ( owners . size ( ) ) ; IdentityFactory identityFactory = pb . serviceIdentity ( ) ; for ( Iterator it = owners . iterator ( ) ; it . hasNext ( ) ; ) { Object owner = it . next ( ) ; ownerIdsToLists . put ( identityFactory . buildIdentity ( getOwnerClassDescriptor ( ) , owner ) , new ArrayList ( ) ) ; } for ( Iterator it = children . iterator ( ) ; it . hasNext ( ) ; ) { Object child = it . next ( ) ; ClassDescriptor cld = getDescriptorRepository ( ) . getDescriptorFor ( ProxyHelper . getRealClass ( child ) ) ; Object [ ] fkValues = cds . getForeignKeyValues ( child , cld ) ; Identity ownerId = identityFactory . buildIdentity ( null , ownerTopLevelClass , fkValues ) ; List list = ( List ) ownerIdsToLists . get ( ownerId ) ; if ( list != null ) { list . add ( child ) ; } } for ( Iterator it = owners . iterator ( ) ; it . hasNext ( ) ; ) { Object result ; Object owner = it . next ( ) ; Identity ownerId = identityFactory . buildIdentity ( owner ) ; List list = ( List ) ownerIdsToLists . get ( ownerId ) ; if ( ( collectionClass == null ) && field . getType ( ) . isArray ( ) ) { int length = list . size ( ) ; Class itemtype = field . getType ( ) . getComponentType ( ) ; result = Array . newInstance ( itemtype , length ) ; for ( int j = 0 ; j < length ; j ++ ) { Array . set ( result , j , list . get ( j ) ) ; } } else { ManageableCollection col = createCollection ( cds , collectionClass ) ; for ( Iterator it2 = list . iterator ( ) ; it2 . hasNext ( ) ; ) { col . ojbAdd ( it2 . next ( ) ) ; } result = col ; } Object value = field . get ( owner ) ; if ( ( value instanceof CollectionProxyDefaultImpl ) && ( result instanceof Collection ) ) { ( ( CollectionProxyDefaultImpl ) value ) . setData ( ( Collection ) result ) ; } else { field . set ( owner , result ) ; } } }
|
associate the batched Children with their owner object loop over children
|
1,320 |
protected ManageableCollection createCollection ( CollectionDescriptor desc , Class collectionClass ) { Class fieldType = desc . getPersistentField ( ) . getType ( ) ; ManageableCollection col ; if ( collectionClass == null ) { if ( ManageableCollection . class . isAssignableFrom ( fieldType ) ) { try { col = ( ManageableCollection ) fieldType . newInstance ( ) ; } catch ( Exception e ) { throw new OJBRuntimeException ( "Cannot instantiate the default collection type " + fieldType . getName ( ) + " of collection " + desc . getAttributeName ( ) + " in type " + desc . getClassDescriptor ( ) . getClassNameOfObject ( ) ) ; } } else if ( fieldType . isAssignableFrom ( RemovalAwareCollection . class ) ) { col = new RemovalAwareCollection ( ) ; } else if ( fieldType . isAssignableFrom ( RemovalAwareList . class ) ) { col = new RemovalAwareList ( ) ; } else if ( fieldType . isAssignableFrom ( RemovalAwareSet . class ) ) { col = new RemovalAwareSet ( ) ; } else { throw new MetadataException ( "Cannot determine a default collection type for collection " + desc . getAttributeName ( ) + " in type " + desc . getClassDescriptor ( ) . getClassNameOfObject ( ) ) ; } } else { try { col = ( ManageableCollection ) collectionClass . newInstance ( ) ; } catch ( Exception e ) { throw new OJBRuntimeException ( "Cannot instantiate the collection class " + collectionClass . getName ( ) + " of collection " + desc . getAttributeName ( ) + " in type " + desc . getClassDescriptor ( ) . getClassNameOfObject ( ) ) ; } } return col ; }
|
Create a collection object of the given collection type . If none has been given OJB uses RemovalAwareList RemovalAwareSet or RemovalAwareCollection depending on the field type .
|
1,321 |
public void setFeatureModel ( FeatureModel featureModel ) throws LayerException { this . featureModel = featureModel ; if ( null != getLayerInfo ( ) ) { featureModel . setLayerInfo ( getLayerInfo ( ) ) ; } filterService . registerFeatureModel ( featureModel ) ; }
|
Set the featureModel .
|
1,322 |
public void update ( Object feature ) throws LayerException { Session session = getSessionFactory ( ) . getCurrentSession ( ) ; session . update ( feature ) ; }
|
Update a feature object in the Hibernate session .
|
1,323 |
private void enforceSrid ( Object feature ) throws LayerException { Geometry geom = getFeatureModel ( ) . getGeometry ( feature ) ; if ( null != geom ) { geom . setSRID ( srid ) ; getFeatureModel ( ) . setGeometry ( feature , geom ) ; } }
|
Enforces the correct srid on incoming features .
|
1,324 |
private Envelope getBoundsLocal ( Filter filter ) throws LayerException { try { Session session = getSessionFactory ( ) . getCurrentSession ( ) ; Criteria criteria = session . createCriteria ( getFeatureInfo ( ) . getDataSourceName ( ) ) ; CriteriaVisitor visitor = new CriteriaVisitor ( ( HibernateFeatureModel ) getFeatureModel ( ) , dateFormat ) ; Criterion c = ( Criterion ) filter . accept ( visitor , criteria ) ; if ( c != null ) { criteria . add ( c ) ; } criteria . setResultTransformer ( Criteria . DISTINCT_ROOT_ENTITY ) ; List < ? > features = criteria . list ( ) ; Envelope bounds = new Envelope ( ) ; for ( Object f : features ) { Envelope geomBounds = getFeatureModel ( ) . getGeometry ( f ) . getEnvelopeInternal ( ) ; if ( ! geomBounds . isNull ( ) ) { bounds . expandToInclude ( geomBounds ) ; } } return bounds ; } catch ( HibernateException he ) { throw new HibernateLayerException ( he , ExceptionCode . HIBERNATE_LOAD_FILTER_FAIL , getFeatureInfo ( ) . getDataSourceName ( ) , filter . toString ( ) ) ; } }
|
Bounds are calculated locally can use any filter but slower than native .
|
1,325 |
public Object getBean ( String name ) { Bean bean = beans . get ( name ) ; if ( null == bean ) { return null ; } return bean . object ; }
|
Get a bean value from the context .
|
1,326 |
public void setBean ( String name , Object object ) { Bean bean = beans . get ( name ) ; if ( null == bean ) { bean = new Bean ( ) ; beans . put ( name , bean ) ; } bean . object = object ; }
|
Set a bean in the context .
|
1,327 |
public Object remove ( String name ) { Bean bean = beans . get ( name ) ; if ( null != bean ) { beans . remove ( name ) ; bean . destructionCallback . run ( ) ; return bean . object ; } return null ; }
|
Remove a bean from the context calling the destruction callback if any .
|
1,328 |
public void registerDestructionCallback ( String name , Runnable callback ) { Bean bean = beans . get ( name ) ; if ( null == bean ) { bean = new Bean ( ) ; beans . put ( name , bean ) ; } bean . destructionCallback = callback ; }
|
Register the given callback as to be executed after request completion .
|
1,329 |
public void clear ( ) { for ( Bean bean : beans . values ( ) ) { if ( null != bean . destructionCallback ) { bean . destructionCallback . run ( ) ; } } beans . clear ( ) ; }
|
Clear all beans and call the destruction callback .
|
1,330 |
private String parseLayerId ( HttpServletRequest request ) { StringTokenizer tokenizer = new StringTokenizer ( request . getRequestURI ( ) , "/" ) ; String token = "" ; while ( tokenizer . hasMoreTokens ( ) ) { token = tokenizer . nextToken ( ) ; } return token ; }
|
Get the layer ID out of the request URL .
|
1,331 |
private WmsLayer getLayer ( String layerId ) { RasterLayer layer = configurationService . getRasterLayer ( layerId ) ; if ( layer instanceof WmsLayer ) { return ( WmsLayer ) layer ; } return null ; }
|
Given a layer ID search for the WMS layer .
|
1,332 |
private byte [ ] createErrorImage ( int width , int height , Exception e ) throws IOException { String error = e . getMessage ( ) ; if ( null == error ) { Writer result = new StringWriter ( ) ; PrintWriter printWriter = new PrintWriter ( result ) ; e . printStackTrace ( printWriter ) ; error = result . toString ( ) ; } BufferedImage image = new BufferedImage ( width , height , BufferedImage . TYPE_4BYTE_ABGR ) ; Graphics2D g = ( Graphics2D ) image . getGraphics ( ) ; g . setColor ( Color . RED ) ; g . drawString ( error , ERROR_MESSAGE_X , height / 2 ) ; ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; ImageIO . write ( image , "PNG" , out ) ; out . flush ( ) ; byte [ ] result = out . toByteArray ( ) ; out . close ( ) ; return result ; }
|
Create an error image should an error occur while fetching a WMS map .
|
1,333 |
public static String formatConnectionEstablishmentMessage ( final String connectionName , final String host , final String connectionReason ) { return CON_ESTABLISHMENT_FORMAT . format ( new Object [ ] { connectionName , host , connectionReason } ) ; }
|
Helper method for formatting connection establishment messages .
|
1,334 |
public static String formatConnectionTerminationMessage ( final String connectionName , final String host , final String connectionReason , final String terminationReason ) { return CON_TERMINATION_FORMAT . format ( new Object [ ] { connectionName , host , connectionReason , terminationReason } ) ; }
|
Helper method for formatting connection termination messages .
|
1,335 |
public String findPlatformFor ( String jdbcSubProtocol , String jdbcDriver ) { String platform = ( String ) jdbcSubProtocolToPlatform . get ( jdbcSubProtocol ) ; if ( platform == null ) { platform = ( String ) jdbcDriverToPlatform . get ( jdbcDriver ) ; } return platform ; }
|
Derives the OJB platform to use for a database that is connected via a url using the specified subprotocol and where the specified jdbc driver is used .
|
1,336 |
public static void validate ( final License license ) { if ( license . getName ( ) == null || license . getName ( ) . isEmpty ( ) ) { throw new WebApplicationException ( Response . status ( Response . Status . BAD_REQUEST ) . entity ( "License name should not be empty!" ) . build ( ) ) ; } if ( license . getLongName ( ) == null || license . getLongName ( ) . isEmpty ( ) ) { throw new WebApplicationException ( Response . status ( Response . Status . BAD_REQUEST ) . entity ( "License long name should not be empty!" ) . build ( ) ) ; } if ( license . getRegexp ( ) != null && ! license . getRegexp ( ) . isEmpty ( ) ) { try { Pattern . compile ( license . getRegexp ( ) ) ; } catch ( PatternSyntaxException e ) { throw new WebApplicationException ( Response . status ( Response . Status . BAD_REQUEST ) . entity ( "License regexp does not compile!" ) . build ( ) ) ; } Pattern regex = Pattern . compile ( "[&%//]" ) ; if ( regex . matcher ( license . getRegexp ( ) ) . find ( ) ) { throw new WebApplicationException ( Response . status ( Response . Status . BAD_REQUEST ) . entity ( "License regexp does not compile!" ) . build ( ) ) ; } } }
|
Checks if the provided license is valid and could be stored into the database
|
1,337 |
public static void validate ( final Module module ) { if ( null == module ) { throw new WebApplicationException ( Response . status ( Response . Status . BAD_REQUEST ) . entity ( "Module cannot be null!" ) . build ( ) ) ; } if ( module . getName ( ) == null || module . getName ( ) . isEmpty ( ) ) { throw new WebApplicationException ( Response . status ( Response . Status . BAD_REQUEST ) . entity ( "Module name cannot be null or empty!" ) . build ( ) ) ; } if ( module . getVersion ( ) == null || module . getVersion ( ) . isEmpty ( ) ) { throw new WebApplicationException ( Response . status ( Response . Status . BAD_REQUEST ) . entity ( "Module version cannot be null or empty!" ) . build ( ) ) ; } for ( final Artifact artifact : DataUtils . getAllArtifacts ( module ) ) { validate ( artifact ) ; } for ( final Dependency dependency : DataUtils . getAllDependencies ( module ) ) { validate ( dependency . getTarget ( ) ) ; } }
|
Checks if the provided module is valid and could be stored into the database
|
1,338 |
public static void validate ( final Organization organization ) { if ( organization . getName ( ) == null || organization . getName ( ) . isEmpty ( ) ) { throw new WebApplicationException ( Response . status ( Response . Status . BAD_REQUEST ) . entity ( "Organization name cannot be null or empty!" ) . build ( ) ) ; } }
|
Checks if the provided organization is valid and could be stored into the database
|
1,339 |
public static void validate ( final ArtifactQuery artifactQuery ) { final Pattern invalidChars = Pattern . compile ( "[^A-Fa-f0-9]" ) ; if ( artifactQuery . getUser ( ) == null || artifactQuery . getUser ( ) . isEmpty ( ) ) { throw new WebApplicationException ( Response . status ( Response . Status . BAD_REQUEST ) . entity ( "Mandatory field [user] missing" ) . build ( ) ) ; } if ( artifactQuery . getStage ( ) != 0 && artifactQuery . getStage ( ) != 1 ) { throw new WebApplicationException ( Response . status ( Response . Status . BAD_REQUEST ) . entity ( "Invalid [stage] value (supported 0 | 1)" ) . build ( ) ) ; } if ( artifactQuery . getName ( ) == null || artifactQuery . getName ( ) . isEmpty ( ) ) { throw new WebApplicationException ( Response . status ( Response . Status . BAD_REQUEST ) . entity ( "Mandatory field [name] missing, it should be the file name" ) . build ( ) ) ; } if ( artifactQuery . getSha256 ( ) == null || artifactQuery . getSha256 ( ) . isEmpty ( ) ) { throw new WebApplicationException ( Response . status ( Response . Status . BAD_REQUEST ) . entity ( "Mandatory field [sha256] missing" ) . build ( ) ) ; } if ( artifactQuery . getSha256 ( ) . length ( ) < 64 || invalidChars . matcher ( artifactQuery . getSha256 ( ) ) . find ( ) ) { throw new WebApplicationException ( Response . status ( Response . Status . BAD_REQUEST ) . entity ( "Invalid file checksum value" ) . build ( ) ) ; } if ( artifactQuery . getType ( ) == null || artifactQuery . getType ( ) . isEmpty ( ) ) { throw new WebApplicationException ( Response . status ( Response . Status . BAD_REQUEST ) . entity ( "Mandatory field [type] missing" ) . build ( ) ) ; } }
|
Checks if the provided artifactQuery is valid
|
1,340 |
protected long getUniqueLong ( FieldDescriptor field ) throws SequenceManagerException { long result ; String sequenceName = calculateSequenceName ( field ) ; try { result = buildNextSequence ( field . getClassDescriptor ( ) , sequenceName ) ; } catch ( Throwable e ) { try { log . info ( "Create DB sequence key '" + sequenceName + "'" ) ; createSequence ( field . getClassDescriptor ( ) , sequenceName ) ; } catch ( Exception e1 ) { throw new SequenceManagerException ( SystemUtils . LINE_SEPARATOR + "Could not grab next id, failed with " + SystemUtils . LINE_SEPARATOR + e . getMessage ( ) + SystemUtils . LINE_SEPARATOR + "Creation of new sequence failed with " + SystemUtils . LINE_SEPARATOR + e1 . getMessage ( ) + SystemUtils . LINE_SEPARATOR , e1 ) ; } try { result = buildNextSequence ( field . getClassDescriptor ( ) , sequenceName ) ; } catch ( Throwable e1 ) { throw new SequenceManagerException ( "Could not grab next id, sequence seems to exist" , e ) ; } } return result ; }
|
returns a unique long value for class clazz and field fieldName . the returned number is unique accross all tables in the extent of clazz .
|
1,341 |
protected Collection provideStateManagers ( Collection pojos ) { PersistenceCapable pc ; int [ ] fieldNums ; Iterator iter = pojos . iterator ( ) ; Collection result = new ArrayList ( ) ; while ( iter . hasNext ( ) ) { pc = ( PersistenceCapable ) iter . next ( ) ; Identity oid = new Identity ( pc , broker ) ; StateManagerInternal smi = pmi . getStateManager ( oid , pc . getClass ( ) ) ; JDOClass jdoClass = Helper . getJDOClass ( pc . getClass ( ) ) ; fieldNums = jdoClass . getManagedFieldNumbers ( ) ; FieldManager fm = new OjbFieldManager ( pc , broker ) ; smi . replaceFields ( fieldNums , fm ) ; smi . retrieve ( ) ; Object instance = smi . getObject ( ) ; result . add ( instance ) ; } return result ; }
|
This methods enhances the objects loaded by a broker query with a JDO StateManager an brings them under JDO control .
|
1,342 |
public final Object copy ( final Object toCopy , PersistenceBroker broker ) { return clone ( toCopy , IdentityMapFactory . getIdentityMap ( ) , new HashMap ( ) ) ; }
|
makes a deep clone of the object using reflection .
|
1,343 |
private static void setFields ( final Object from , final Object to , final Field [ ] fields , final boolean accessible , final Map objMap , final Map metadataMap ) { for ( int f = 0 , fieldsLength = fields . length ; f < fieldsLength ; ++ f ) { final Field field = fields [ f ] ; final int modifiers = field . getModifiers ( ) ; if ( ( Modifier . STATIC & modifiers ) != 0 ) continue ; if ( ( Modifier . FINAL & modifiers ) != 0 ) throw new ObjectCopyException ( "cannot set final field [" + field . getName ( ) + "] of class [" + from . getClass ( ) . getName ( ) + "]" ) ; if ( ! accessible && ( ( Modifier . PUBLIC & modifiers ) == 0 ) ) { try { field . setAccessible ( true ) ; } catch ( SecurityException e ) { throw new ObjectCopyException ( "cannot access field [" + field . getName ( ) + "] of class [" + from . getClass ( ) . getName ( ) + "]: " + e . toString ( ) , e ) ; } } try { cloneAndSetFieldValue ( field , from , to , objMap , metadataMap ) ; } catch ( Exception e ) { throw new ObjectCopyException ( "cannot set field [" + field . getName ( ) + "] of class [" + from . getClass ( ) . getName ( ) + "]: " + e . toString ( ) , e ) ; } } }
|
copy all fields from the from object to the to object .
|
1,344 |
public void registerComponent ( java . awt . Component c ) { unregisterComponent ( c ) ; if ( recognizerAbstractClass == null ) { hmDragGestureRecognizers . put ( c , dragSource . createDefaultDragGestureRecognizer ( c , dragWorker . getAcceptableActions ( c ) , dgListener ) ) ; } else { hmDragGestureRecognizers . put ( c , dragSource . createDragGestureRecognizer ( recognizerAbstractClass , c , dragWorker . getAcceptableActions ( c ) , dgListener ) ) ; } }
|
add a Component to this Worker . After the call dragging is enabled for this Component .
|
1,345 |
public void unregisterComponent ( java . awt . Component c ) { java . awt . dnd . DragGestureRecognizer recognizer = ( java . awt . dnd . DragGestureRecognizer ) this . hmDragGestureRecognizers . remove ( c ) ; if ( recognizer != null ) recognizer . setComponent ( null ) ; }
|
remove drag support from the given Component .
|
1,346 |
protected Object doInvoke ( Object proxy , Method methodToBeInvoked , Object [ ] args ) throws Throwable { Method m = getRealSubject ( ) . getClass ( ) . getMethod ( methodToBeInvoked . getName ( ) , methodToBeInvoked . getParameterTypes ( ) ) ; return m . invoke ( getRealSubject ( ) , args ) ; }
|
this method will be invoked after methodToBeInvoked is invoked
|
1,347 |
public void addIterator ( OJBIterator iterator ) { if ( iterator != null ) { if ( iterator . hasNext ( ) ) { setNextIterator ( ) ; m_rsIterators . add ( iterator ) ; } } }
|
use this method to construct the ChainingIterator iterator by iterator .
|
1,348 |
public boolean absolute ( int row ) throws PersistenceBrokerException { if ( row == 0 ) { return true ; } if ( row == 1 ) { m_activeIteratorIndex = 0 ; m_activeIterator = ( OJBIterator ) m_rsIterators . get ( m_activeIteratorIndex ) ; m_activeIterator . absolute ( 1 ) ; return true ; } if ( row == - 1 ) { m_activeIteratorIndex = m_rsIterators . size ( ) ; m_activeIterator = ( OJBIterator ) m_rsIterators . get ( m_activeIteratorIndex ) ; m_activeIterator . absolute ( - 1 ) ; return true ; } boolean movedToAbsolute = false ; boolean retval = false ; setNextIterator ( ) ; if ( row > 0 ) { int sizeCount = 0 ; Iterator it = m_rsIterators . iterator ( ) ; OJBIterator temp = null ; while ( it . hasNext ( ) && ! movedToAbsolute ) { temp = ( OJBIterator ) it . next ( ) ; if ( temp . size ( ) < row ) { sizeCount += temp . size ( ) ; } else { m_currentCursorPosition = row - sizeCount ; retval = temp . absolute ( m_currentCursorPosition ) ; movedToAbsolute = true ; } } } else if ( row < 0 ) { int sizeCount = 0 ; OJBIterator temp = null ; for ( int i = m_rsIterators . size ( ) ; ( ( i >= 0 ) && ! movedToAbsolute ) ; i -- ) { temp = ( OJBIterator ) m_rsIterators . get ( i ) ; if ( temp . size ( ) < row ) { sizeCount += temp . size ( ) ; } else { m_currentCursorPosition = row + sizeCount ; retval = temp . absolute ( m_currentCursorPosition ) ; movedToAbsolute = true ; } } } return retval ; }
|
the absolute and relative calls are the trickiest parts . We have to move across cursor boundaries potentially .
|
1,349 |
public void releaseDbResources ( ) { Iterator it = m_rsIterators . iterator ( ) ; while ( it . hasNext ( ) ) { ( ( OJBIterator ) it . next ( ) ) . releaseDbResources ( ) ; } }
|
delegate to each contained OJBIterator and release its resources .
|
1,350 |
private boolean setNextIterator ( ) { boolean retval = false ; if ( m_activeIterator == null ) { if ( m_rsIterators . size ( ) > 0 ) { m_activeIteratorIndex = 0 ; m_currentCursorPosition = 0 ; m_activeIterator = ( OJBIterator ) m_rsIterators . get ( m_activeIteratorIndex ) ; } } else if ( ! m_activeIterator . hasNext ( ) ) { if ( m_rsIterators . size ( ) > ( m_activeIteratorIndex + 1 ) ) { m_activeIteratorIndex ++ ; m_currentCursorPosition = 0 ; m_activeIterator = ( OJBIterator ) m_rsIterators . get ( m_activeIteratorIndex ) ; retval = true ; } } return retval ; }
|
Convenience routine to move to the next iterator if needed .
|
1,351 |
public boolean containsIteratorForTable ( String aTable ) { boolean result = false ; if ( m_rsIterators != null ) { for ( int i = 0 ; i < m_rsIterators . size ( ) ; i ++ ) { OJBIterator it = ( OJBIterator ) m_rsIterators . get ( i ) ; if ( it instanceof RsIterator ) { if ( ( ( RsIterator ) it ) . getClassDescriptor ( ) . getFullTableName ( ) . equals ( aTable ) ) { result = true ; break ; } } else if ( it instanceof ChainingIterator ) { result = ( ( ChainingIterator ) it ) . containsIteratorForTable ( aTable ) ; } } } return result ; }
|
Answer true if an Iterator for a Table is already available
|
1,352 |
public Class getSearchClass ( ) { Object obj = getExampleObject ( ) ; if ( obj instanceof Identity ) { return ( ( Identity ) obj ) . getObjectsTopLevelClass ( ) ; } else { return obj . getClass ( ) ; } }
|
Answer the search class . This is the class of the example object or the class represented by Identity .
|
1,353 |
private < T > T getBeanOrNull ( String name , Class < T > requiredType ) { if ( name == null || ! applicationContext . containsBean ( name ) ) { return null ; } else { try { return applicationContext . getBean ( name , requiredType ) ; } catch ( BeansException be ) { log . error ( "Error during getBeanOrNull, not rethrown, " + be . getMessage ( ) , be ) ; return null ; } } }
|
Get a bean from the application context . Returns null if the bean does not exist .
|
1,354 |
public void restoreSecurityContext ( CacheContext context ) { SavedAuthorization cached = context . get ( CacheContext . SECURITY_CONTEXT_KEY , SavedAuthorization . class ) ; if ( cached != null ) { log . debug ( "Restoring security context {}" , cached ) ; securityManager . restoreSecurityContext ( cached ) ; } else { securityManager . clearSecurityContext ( ) ; } }
|
Puts the cached security context in the thread local .
|
1,355 |
private void sortFileList ( ) { if ( this . size ( ) > 1 ) { Collections . sort ( this . fileList , new Comparator ( ) { public final int compare ( final Object o1 , final Object o2 ) { final File f1 = ( File ) o1 ; final File f2 = ( File ) o2 ; final Object [ ] f1TimeAndCount = backupSuffixHelper . backupTimeAndCount ( f1 . getName ( ) , baseFile ) ; final Object [ ] f2TimeAndCount = backupSuffixHelper . backupTimeAndCount ( f2 . getName ( ) , baseFile ) ; final long f1TimeSuffix = ( ( Long ) f1TimeAndCount [ 0 ] ) . longValue ( ) ; final long f2TimeSuffix = ( ( Long ) f2TimeAndCount [ 0 ] ) . longValue ( ) ; if ( ( 0L == f1TimeSuffix ) && ( 0L == f2TimeSuffix ) ) { final long f1Time = f1 . lastModified ( ) ; final long f2Time = f2 . lastModified ( ) ; if ( f1Time < f2Time ) { return - 1 ; } if ( f1Time > f2Time ) { return 1 ; } return 0 ; } if ( f1TimeSuffix < f2TimeSuffix ) { return - 1 ; } if ( f1TimeSuffix > f2TimeSuffix ) { return 1 ; } final int f1Count = ( ( Integer ) f1TimeAndCount [ 1 ] ) . intValue ( ) ; final int f2Count = ( ( Integer ) f2TimeAndCount [ 1 ] ) . intValue ( ) ; if ( f1Count < f2Count ) { return - 1 ; } if ( f1Count > f2Count ) { return 1 ; } if ( f1Count == f2Count ) { if ( fileHelper . isCompressed ( f1 ) ) { return - 1 ; } if ( fileHelper . isCompressed ( f2 ) ) { return 1 ; } } return 0 ; } } ) ; } }
|
Sort by time bucket then backup count and by compression state .
|
1,356 |
private ClassDescriptor getRealClassDescriptor ( ClassDescriptor aCld , Object anObj ) { ClassDescriptor result ; if ( aCld . getClassOfObject ( ) == ProxyHelper . getRealClass ( anObj ) ) { result = aCld ; } else { result = aCld . getRepository ( ) . getDescriptorFor ( anObj . getClass ( ) ) ; } return result ; }
|
Answer the real ClassDescriptor for anObj ie . aCld may be an Interface of anObj so the cld for anObj is returned
|
1,357 |
public ValueContainer [ ] getKeyValues ( ClassDescriptor cld , Object objectOrProxy , boolean convertToSql ) throws PersistenceBrokerException { IndirectionHandler handler = ProxyHelper . getIndirectionHandler ( objectOrProxy ) ; if ( handler != null ) { return getKeyValues ( cld , handler . getIdentity ( ) , convertToSql ) ; } else { ClassDescriptor realCld = getRealClassDescriptor ( cld , objectOrProxy ) ; return getValuesForObject ( realCld . getPkFields ( ) , objectOrProxy , convertToSql ) ; } }
|
Returns an Array with an Objects PK VALUES if convertToSql is true any associated java - to - sql conversions are applied . If the Object is a Proxy or a VirtualProxy NO conversion is necessary .
|
1,358 |
public ValueContainer [ ] getKeyValues ( ClassDescriptor cld , Identity oid ) throws PersistenceBrokerException { return getKeyValues ( cld , oid , true ) ; }
|
Return primary key values of given Identity object .
|
1,359 |
public ValueContainer [ ] getKeyValues ( ClassDescriptor cld , Identity oid , boolean convertToSql ) throws PersistenceBrokerException { FieldDescriptor [ ] pkFields = cld . getPkFields ( ) ; ValueContainer [ ] result = new ValueContainer [ pkFields . length ] ; Object [ ] pkValues = oid . getPrimaryKeyValues ( ) ; try { for ( int i = 0 ; i < result . length ; i ++ ) { FieldDescriptor fd = pkFields [ i ] ; Object cv = pkValues [ i ] ; if ( convertToSql ) { cv = fd . getFieldConversion ( ) . javaToSql ( cv ) ; } result [ i ] = new ValueContainer ( cv , fd . getJdbcType ( ) ) ; } } catch ( Exception e ) { throw new PersistenceBrokerException ( "Can't generate primary key values for given Identity " + oid , e ) ; } return result ; }
|
Return key Values of an Identity
|
1,360 |
public ValueContainer [ ] getKeyValues ( ClassDescriptor cld , Object objectOrProxy ) throws PersistenceBrokerException { return getKeyValues ( cld , objectOrProxy , true ) ; }
|
returns an Array with an Objects PK VALUES with any java - to - sql FieldConversion applied . If the Object is a Proxy or a VirtualProxy NO conversion is necessary .
|
1,361 |
public boolean hasNullPKField ( ClassDescriptor cld , Object obj ) { FieldDescriptor [ ] fields = cld . getPkFields ( ) ; boolean hasNull = false ; IndirectionHandler handler = ProxyHelper . getIndirectionHandler ( obj ) ; if ( handler == null || handler . alreadyMaterialized ( ) ) { if ( handler != null ) obj = handler . getRealSubject ( ) ; FieldDescriptor fld ; for ( int i = 0 ; i < fields . length ; i ++ ) { fld = fields [ i ] ; hasNull = representsNull ( fld , fld . getPersistentField ( ) . get ( obj ) ) ; if ( hasNull ) break ; } } return hasNull ; }
|
Detect if the given object has a PK field represents a null value .
|
1,362 |
public ValueContainer [ ] getValuesForObject ( FieldDescriptor [ ] fields , Object obj , boolean convertToSql , boolean assignAutoincrement ) throws PersistenceBrokerException { ValueContainer [ ] result = new ValueContainer [ fields . length ] ; for ( int i = 0 ; i < fields . length ; i ++ ) { FieldDescriptor fd = fields [ i ] ; Object cv = fd . getPersistentField ( ) . get ( obj ) ; if ( assignAutoincrement && fd . isAutoIncrement ( ) && representsNull ( fd , cv ) ) { cv = setAutoIncrementValue ( fd , obj ) ; } if ( convertToSql ) { cv = fd . getFieldConversion ( ) . javaToSql ( cv ) ; } result [ i ] = new ValueContainer ( cv , fd . getJdbcType ( ) ) ; } return result ; }
|
Get the values of the fields for an obj Autoincrement values are automatically set .
|
1,363 |
public boolean assertValidPkForDelete ( ClassDescriptor cld , Object obj ) { if ( ! ProxyHelper . isProxy ( obj ) ) { FieldDescriptor fieldDescriptors [ ] = cld . getPkFields ( ) ; int fieldDescriptorSize = fieldDescriptors . length ; for ( int i = 0 ; i < fieldDescriptorSize ; i ++ ) { FieldDescriptor fd = fieldDescriptors [ i ] ; Object pkValue = fd . getPersistentField ( ) . get ( obj ) ; if ( representsNull ( fd , pkValue ) ) { return false ; } } } return true ; }
|
returns true if the primary key fields are valid for delete else false . PK fields are valid if each of them contains a valid non - null value
|
1,364 |
public Query getCountQuery ( Query aQuery ) { if ( aQuery instanceof QueryBySQL ) { return getQueryBySqlCount ( ( QueryBySQL ) aQuery ) ; } else if ( aQuery instanceof ReportQueryByCriteria ) { return getReportQueryByCriteriaCount ( ( ReportQueryByCriteria ) aQuery ) ; } else { return getQueryByCriteriaCount ( ( QueryByCriteria ) aQuery ) ; } }
|
Build a Count - Query based on aQuery
|
1,365 |
private Query getQueryBySqlCount ( QueryBySQL aQuery ) { String countSql = aQuery . getSql ( ) ; int fromPos = countSql . toUpperCase ( ) . indexOf ( " FROM " ) ; if ( fromPos >= 0 ) { countSql = "select count(*)" + countSql . substring ( fromPos ) ; } int orderPos = countSql . toUpperCase ( ) . indexOf ( " ORDER BY " ) ; if ( orderPos >= 0 ) { countSql = countSql . substring ( 0 , orderPos ) ; } return new QueryBySQL ( aQuery . getSearchClass ( ) , countSql ) ; }
|
Create a Count - Query for QueryBySQL
|
1,366 |
private Query getQueryByCriteriaCount ( QueryByCriteria aQuery ) { Class searchClass = aQuery . getSearchClass ( ) ; ReportQueryByCriteria countQuery = null ; Criteria countCrit = null ; String [ ] columns = new String [ 1 ] ; if ( aQuery . getCriteria ( ) != null ) { countCrit = aQuery . getCriteria ( ) . copy ( false , false , false ) ; } if ( aQuery . isDistinct ( ) ) { FieldDescriptor [ ] pkFields = m_broker . getClassDescriptor ( searchClass ) . getPkFields ( ) ; String [ ] keyColumns = new String [ pkFields . length ] ; if ( pkFields . length > 1 ) { for ( int idx = 0 ; idx < pkFields . length ; idx ++ ) { keyColumns [ idx ] = pkFields [ idx ] . getColumnName ( ) ; } } else { for ( int idx = 0 ; idx < pkFields . length ; idx ++ ) { keyColumns [ idx ] = pkFields [ idx ] . getAttributeName ( ) ; } } columns [ 0 ] = "count(distinct " + getPlatform ( ) . concatenate ( keyColumns ) + ")" ; } else { columns [ 0 ] = "count(*)" ; } if ( aQuery instanceof MtoNQuery ) { MtoNQuery mnQuery = ( MtoNQuery ) aQuery ; ReportQueryByMtoNCriteria mnReportQuery = new ReportQueryByMtoNCriteria ( searchClass , columns , countCrit ) ; mnReportQuery . setIndirectionTable ( mnQuery . getIndirectionTable ( ) ) ; countQuery = mnReportQuery ; } else { countQuery = new ReportQueryByCriteria ( searchClass , columns , countCrit ) ; } for ( Iterator outerJoinPath = aQuery . getOuterJoinPaths ( ) . iterator ( ) ; outerJoinPath . hasNext ( ) ; ) { String path = ( String ) outerJoinPath . next ( ) ; if ( aQuery . isPathOuterJoin ( path ) ) { countQuery . setPathOuterJoin ( path ) ; } } List orderBy = aQuery . getOrderBy ( ) ; if ( ( orderBy != null ) && ! orderBy . isEmpty ( ) ) { String [ ] joinAttributes = new String [ orderBy . size ( ) ] ; for ( int idx = 0 ; idx < orderBy . size ( ) ; idx ++ ) { joinAttributes [ idx ] = ( ( FieldHelper ) orderBy . get ( idx ) ) . name ; } countQuery . setJoinAttributes ( joinAttributes ) ; } return countQuery ; }
|
Create a Count - Query for QueryByCriteria
|
1,367 |
private Query getReportQueryByCriteriaCount ( ReportQueryByCriteria aQuery ) { ReportQueryByCriteria countQuery = ( ReportQueryByCriteria ) getQueryByCriteriaCount ( aQuery ) ; countQuery . setJoinAttributes ( aQuery . getAttributes ( ) ) ; Iterator iter = aQuery . getGroupBy ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { countQuery . addGroupBy ( ( FieldHelper ) iter . next ( ) ) ; } return countQuery ; }
|
Create a Count - Query for ReportQueryByCriteria
|
1,368 |
public boolean unlink ( Object source , String attributeName , Object target ) { return linkOrUnlink ( false , source , attributeName , false ) ; }
|
Unlink the specified reference object . More info see OJB doc .
|
1,369 |
public void unlink ( Object obj , ObjectReferenceDescriptor ord , boolean insert ) { linkOrUnlink ( false , obj , ord , insert ) ; }
|
Unlink the specified reference from this object . More info see OJB doc .
|
1,370 |
protected boolean _load ( ) { java . sql . ResultSet rs = null ; try { synchronized ( getDbMeta ( ) ) { getDbMetaTreeModel ( ) . setStatusBarMessage ( "Reading schemas for catalog " + this . getAttribute ( ATT_CATALOG_NAME ) ) ; rs = getDbMeta ( ) . getSchemas ( ) ; final java . util . ArrayList alNew = new java . util . ArrayList ( ) ; int count = 0 ; while ( rs . next ( ) ) { getDbMetaTreeModel ( ) . setStatusBarMessage ( "Creating schema " + getCatalogName ( ) + "." + rs . getString ( "TABLE_SCHEM" ) ) ; alNew . add ( new DBMetaSchemaNode ( getDbMeta ( ) , getDbMetaTreeModel ( ) , DBMetaCatalogNode . this , rs . getString ( "TABLE_SCHEM" ) ) ) ; count ++ ; } if ( count == 0 ) alNew . add ( new DBMetaSchemaNode ( getDbMeta ( ) , getDbMetaTreeModel ( ) , DBMetaCatalogNode . this , null ) ) ; alChildren = alNew ; javax . swing . SwingUtilities . invokeLater ( new Runnable ( ) { public void run ( ) { getDbMetaTreeModel ( ) . nodeStructureChanged ( DBMetaCatalogNode . this ) ; } } ) ; rs . close ( ) ; } } catch ( java . sql . SQLException sqlEx ) { getDbMetaTreeModel ( ) . reportSqlError ( "Error retrieving schemas" , sqlEx ) ; try { if ( rs != null ) rs . close ( ) ; } catch ( java . sql . SQLException sqlEx2 ) { this . getDbMetaTreeModel ( ) . reportSqlError ( "Error retrieving schemas" , sqlEx2 ) ; } return false ; } return true ; }
|
Loads the schemas associated to this catalog .
|
1,371 |
public void removeDescriptor ( Object validKey ) { PBKey pbKey ; if ( validKey instanceof PBKey ) { pbKey = ( PBKey ) validKey ; } else if ( validKey instanceof JdbcConnectionDescriptor ) { pbKey = ( ( JdbcConnectionDescriptor ) validKey ) . getPBKey ( ) ; } else { throw new MetadataException ( "Could not remove descriptor, given object was no vaild key: " + validKey ) ; } Object removed = null ; synchronized ( jcdMap ) { removed = jcdMap . remove ( pbKey ) ; jcdAliasToPBKeyMap . remove ( pbKey . getAlias ( ) ) ; } log . info ( "Remove descriptor: " + removed ) ; }
|
Remove a descriptor .
|
1,372 |
private int findIndexForName ( String [ ] fieldNames , String searchName ) { for ( int i = 0 ; i < fieldNames . length ; i ++ ) { if ( searchName . equals ( fieldNames [ i ] ) ) { return i ; } } throw new PersistenceBrokerException ( "Can't find field name '" + searchName + "' in given array of field names" ) ; }
|
Find the index of the specified name in field name array .
|
1,373 |
private boolean isOrdered ( FieldDescriptor [ ] flds , String [ ] pkFieldNames ) { if ( ( flds . length > 1 && pkFieldNames == null ) || flds . length != pkFieldNames . length ) { throw new PersistenceBrokerException ( "pkFieldName length does not match number of defined PK fields." + " Expected number of PK fields is " + flds . length + ", given number was " + ( pkFieldNames != null ? pkFieldNames . length : 0 ) ) ; } boolean result = true ; for ( int i = 0 ; i < flds . length ; i ++ ) { FieldDescriptor fld = flds [ i ] ; result = result && fld . getPersistentField ( ) . getName ( ) . equals ( pkFieldNames [ i ] ) ; } return result ; }
|
Checks length and compare order of field names with declared PK fields in metadata .
|
1,374 |
private PersistenceBrokerException createException ( final Exception ex , String message , final Object objectToIdentify , Class topLevelClass , Class realClass , Object [ ] pks ) { final String eol = SystemUtils . LINE_SEPARATOR ; StringBuffer msg = new StringBuffer ( ) ; if ( message == null ) { msg . append ( "Unexpected error: " ) ; } else { msg . append ( message ) . append ( " :" ) ; } if ( topLevelClass != null ) msg . append ( eol ) . append ( "objectTopLevelClass=" ) . append ( topLevelClass . getName ( ) ) ; if ( realClass != null ) msg . append ( eol ) . append ( "objectRealClass=" ) . append ( realClass . getName ( ) ) ; if ( pks != null ) msg . append ( eol ) . append ( "pkValues=" ) . append ( ArrayUtils . toString ( pks ) ) ; if ( objectToIdentify != null ) msg . append ( eol ) . append ( "object to identify: " ) . append ( objectToIdentify ) ; if ( ex != null ) { Throwable rootCause = ExceptionUtils . getRootCause ( ex ) ; if ( rootCause != null ) { msg . append ( eol ) . append ( "The root stack trace is ) ; String rootStack = ExceptionUtils . getStackTrace ( rootCause ) ; msg . append ( eol ) . append ( rootStack ) ; } return new PersistenceBrokerException ( msg . toString ( ) , ex ) ; } else { return new PersistenceBrokerException ( msg . toString ( ) ) ; } }
|
Helper method which supports creation of proper error messages .
|
1,375 |
private void addEdgesForVertex ( Vertex vertex ) { ClassDescriptor cld = vertex . getEnvelope ( ) . getClassDescriptor ( ) ; Iterator rdsIter = cld . getObjectReferenceDescriptors ( true ) . iterator ( ) ; while ( rdsIter . hasNext ( ) ) { ObjectReferenceDescriptor rds = ( ObjectReferenceDescriptor ) rdsIter . next ( ) ; addObjectReferenceEdges ( vertex , rds ) ; } Iterator cdsIter = cld . getCollectionDescriptors ( true ) . iterator ( ) ; while ( cdsIter . hasNext ( ) ) { CollectionDescriptor cds = ( CollectionDescriptor ) cdsIter . next ( ) ; addCollectionEdges ( vertex , cds ) ; } }
|
Adds all edges for a given object envelope vertex . All edges are added to the edgeList map .
|
1,376 |
private void addObjectReferenceEdges ( Vertex vertex , ObjectReferenceDescriptor rds ) { Object refObject = rds . getPersistentField ( ) . get ( vertex . getEnvelope ( ) . getRealObject ( ) ) ; Class refClass = rds . getItemClass ( ) ; for ( int i = 0 ; i < vertices . length ; i ++ ) { Edge edge = null ; Vertex refVertex = vertices [ i ] ; ObjectEnvelope refEnvelope = refVertex . getEnvelope ( ) ; if ( refObject == refEnvelope . getRealObject ( ) ) { edge = buildConcrete11Edge ( vertex , refVertex , rds . hasConstraint ( ) ) ; } else if ( refClass . isInstance ( refVertex . getEnvelope ( ) . getRealObject ( ) ) ) { edge = buildPotential11Edge ( vertex , refVertex , rds . hasConstraint ( ) ) ; } if ( edge != null ) { if ( ! edgeList . contains ( edge ) ) { edgeList . add ( edge ) ; } else { edge . increaseWeightTo ( edge . getWeight ( ) ) ; } } } }
|
Finds edges based to a specific object reference descriptor and adds them to the edge map .
|
1,377 |
private static boolean containsObject ( Object searchFor , Object [ ] searchIn ) { for ( int i = 0 ; i < searchIn . length ; i ++ ) { if ( searchFor == searchIn [ i ] ) { return true ; } } return false ; }
|
Helper method that searches an object array for the occurence of a specific object based on reference equality
|
1,378 |
protected static Map < String , String > getHeadersAsMap ( ResponseEntity response ) { Map < String , List < String > > headers = new HashMap < > ( response . getHeaders ( ) ) ; Map < String , String > map = new HashMap < > ( ) ; for ( Map . Entry < String , List < String > > header : headers . entrySet ( ) ) { String headerValue = Joiner . on ( "," ) . join ( header . getValue ( ) ) ; map . put ( header . getKey ( ) , headerValue ) ; } return map ; }
|
Flat the map of list of string to map of strings with theoriginal values seperated by comma
|
1,379 |
private void init ( ) { jdbcProperties = new Properties ( ) ; dbcpProperties = new Properties ( ) ; setFetchSize ( 0 ) ; this . setTestOnBorrow ( true ) ; this . setTestOnReturn ( false ) ; this . setTestWhileIdle ( false ) ; this . setLogAbandoned ( false ) ; this . setRemoveAbandoned ( false ) ; }
|
Set some initial values .
|
1,380 |
public void addAttribute ( String attributeName , String attributeValue ) { if ( attributeName != null && attributeName . startsWith ( JDBC_PROPERTY_NAME_PREFIX ) ) { final String jdbcPropertyName = attributeName . substring ( JDBC_PROPERTY_NAME_LENGTH ) ; jdbcProperties . setProperty ( jdbcPropertyName , attributeValue ) ; } else if ( attributeName != null && attributeName . startsWith ( DBCP_PROPERTY_NAME_PREFIX ) ) { final String dbcpPropertyName = attributeName . substring ( DBCP_PROPERTY_NAME_LENGTH ) ; dbcpProperties . setProperty ( dbcpPropertyName , attributeValue ) ; } else { super . addAttribute ( attributeName , attributeValue ) ; } }
|
Sets a custom configuration attribute .
|
1,381 |
private void userInfoInit ( ) { boolean first = true ; userId = null ; userLocale = null ; userName = null ; userOrganization = null ; userDivision = null ; if ( null != authentications ) { for ( Authentication auth : authentications ) { userId = combine ( userId , auth . getUserId ( ) ) ; userName = combine ( userName , auth . getUserName ( ) ) ; if ( first ) { userLocale = auth . getUserLocale ( ) ; first = false ; } else { if ( null != auth . getUserLocale ( ) && ( null == userLocale || ! userLocale . equals ( auth . getUserLocale ( ) ) ) ) { userLocale = null ; } } userOrganization = combine ( userOrganization , auth . getUserOrganization ( ) ) ; userDivision = combine ( userDivision , auth . getUserDivision ( ) ) ; } } Map < String , List < String > > idParts = new HashMap < String , List < String > > ( ) ; if ( null != authentications ) { for ( Authentication auth : authentications ) { List < String > auths = new ArrayList < String > ( ) ; for ( BaseAuthorization ba : auth . getAuthorizations ( ) ) { auths . add ( ba . getId ( ) ) ; } Collections . sort ( auths ) ; idParts . put ( auth . getSecurityServiceId ( ) , auths ) ; } } StringBuilder sb = new StringBuilder ( ) ; List < String > sortedKeys = new ArrayList < String > ( idParts . keySet ( ) ) ; Collections . sort ( sortedKeys ) ; for ( String key : sortedKeys ) { if ( sb . length ( ) > 0 ) { sb . append ( '|' ) ; } List < String > auths = idParts . get ( key ) ; first = true ; for ( String ak : auths ) { if ( first ) { first = false ; } else { sb . append ( '|' ) ; } sb . append ( ak ) ; } sb . append ( '@' ) ; sb . append ( key ) ; } id = sb . toString ( ) ; }
|
Calculate UserInfo strings .
|
1,382 |
public void restoreSecurityContext ( SavedAuthorization savedAuthorization ) { List < Authentication > auths = new ArrayList < Authentication > ( ) ; if ( null != savedAuthorization ) { for ( SavedAuthentication sa : savedAuthorization . getAuthentications ( ) ) { Authentication auth = new Authentication ( ) ; auth . setSecurityServiceId ( sa . getSecurityServiceId ( ) ) ; auth . setAuthorizations ( sa . getAuthorizations ( ) ) ; auths . add ( auth ) ; } } setAuthentications ( null , auths ) ; userInfoInit ( ) ; }
|
Restore authentications from persisted state .
|
1,383 |
public void work ( RepositoryHandler repoHandler , DbProduct product ) { if ( ! product . getDeliveries ( ) . isEmpty ( ) ) { product . getDeliveries ( ) . forEach ( delivery -> { final Set < Artifact > artifacts = new HashSet < > ( ) ; final DataFetchingUtils utils = new DataFetchingUtils ( ) ; final DependencyHandler depHandler = new DependencyHandler ( repoHandler ) ; final Set < String > deliveryDependencies = utils . getDeliveryDependencies ( repoHandler , depHandler , delivery ) ; final Set < String > fullGAVCSet = deliveryDependencies . stream ( ) . filter ( DataUtils :: isFullGAVC ) . collect ( Collectors . toSet ( ) ) ; final Set < String > shortIdentiferSet = deliveryDependencies . stream ( ) . filter ( entry -> ! DataUtils . isFullGAVC ( entry ) ) . collect ( Collectors . toSet ( ) ) ; processDependencySet ( repoHandler , shortIdentiferSet , batch -> String . format ( BATCH_TEMPLATE_REGEX , StringUtils . join ( batch , '|' ) ) , 1 , artifacts :: add ) ; processDependencySet ( repoHandler , fullGAVCSet , batch -> QueryUtils . quoteIds ( batch , BATCH_TEMPLATE ) , 10 , artifacts :: add ) ; if ( ! artifacts . isEmpty ( ) ) { delivery . setAllArtifactDependencies ( new ArrayList < > ( artifacts ) ) ; } } ) ; repoHandler . store ( product ) ; } }
|
refresh all deliveries dependencies for a particular product
|
1,384 |
private ClassDescriptor [ ] getMultiJoinedClassDescriptors ( ClassDescriptor cld ) { DescriptorRepository repository = cld . getRepository ( ) ; Class [ ] multiJoinedClasses = repository . getSubClassesMultipleJoinedTables ( cld , true ) ; ClassDescriptor [ ] result = new ClassDescriptor [ multiJoinedClasses . length ] ; for ( int i = 0 ; i < multiJoinedClasses . length ; i ++ ) { result [ i ] = repository . getDescriptorFor ( multiJoinedClasses [ i ] ) ; } return result ; }
|
Get MultiJoined ClassDescriptors
|
1,385 |
private void appendClazzColumnForSelect ( StringBuffer buf ) { ClassDescriptor cld = getSearchClassDescriptor ( ) ; ClassDescriptor [ ] clds = getMultiJoinedClassDescriptors ( cld ) ; if ( clds . length == 0 ) { return ; } buf . append ( ",CASE" ) ; for ( int i = clds . length ; i > 0 ; i -- ) { buf . append ( " WHEN " ) ; ClassDescriptor subCld = clds [ i - 1 ] ; FieldDescriptor [ ] fieldDescriptors = subCld . getPkFields ( ) ; TableAlias alias = getTableAliasForClassDescriptor ( subCld ) ; for ( int j = 0 ; j < fieldDescriptors . length ; j ++ ) { FieldDescriptor field = fieldDescriptors [ j ] ; if ( j > 0 ) { buf . append ( " AND " ) ; } appendColumn ( alias , field , buf ) ; buf . append ( " IS NOT NULL" ) ; } buf . append ( " THEN '" ) . append ( subCld . getClassNameOfObject ( ) ) . append ( "'" ) ; } buf . append ( " ELSE '" ) . append ( cld . getClassNameOfObject ( ) ) . append ( "'" ) ; buf . append ( " END AS " + SqlHelper . OJB_CLASS_COLUMN ) ; }
|
Create the OJB_CLAZZ pseudo column based on CASE WHEN . This column defines the Class to be instantiated .
|
1,386 |
Object lookup ( String key ) throws ObjectNameNotFoundException { Object result = null ; NamedEntry entry = localLookup ( key ) ; if ( entry == null ) { try { PersistenceBroker broker = tx . getBroker ( ) ; Identity oid = broker . serviceIdentity ( ) . buildIdentity ( NamedEntry . class , key ) ; entry = ( NamedEntry ) broker . getObjectByIdentity ( oid ) ; } catch ( Exception e ) { log . error ( "Can't materialize bound object for key '" + key + "'" , e ) ; } } if ( entry == null ) { log . info ( "No object found for key '" + key + "'" ) ; } else { Object obj = entry . getObject ( ) ; if ( obj instanceof Identity ) { Identity objectIdentity = ( Identity ) obj ; result = tx . getBroker ( ) . getObjectByIdentity ( objectIdentity ) ; RuntimeObject rt = new RuntimeObject ( result , objectIdentity , tx , false ) ; tx . lockAndRegister ( rt , Transaction . READ , tx . getRegistrationList ( ) ) ; } else { result = obj ; } } if ( result == null ) throw new ObjectNameNotFoundException ( "Can't find named object for name '" + key + "'" ) ; return result ; }
|
Return a named object associated with the specified key .
|
1,387 |
void unbind ( String key ) { NamedEntry entry = new NamedEntry ( key , null , false ) ; localUnbind ( key ) ; addForDeletion ( entry ) ; }
|
Remove a named object
|
1,388 |
public DescriptorRepository readDescriptorRepository ( String fileName ) { try { RepositoryPersistor persistor = new RepositoryPersistor ( ) ; return persistor . readDescriptorRepository ( fileName ) ; } catch ( Exception e ) { throw new MetadataException ( "Can not read repository " + fileName , e ) ; } }
|
Read ClassDescriptors from the given repository file .
|
1,389 |
public DescriptorRepository readDescriptorRepository ( InputStream inst ) { try { RepositoryPersistor persistor = new RepositoryPersistor ( ) ; return persistor . readDescriptorRepository ( inst ) ; } catch ( Exception e ) { throw new MetadataException ( "Can not read repository " + inst , e ) ; } }
|
Read ClassDescriptors from the given InputStream .
|
1,390 |
public ConnectionRepository readConnectionRepository ( String fileName ) { try { RepositoryPersistor persistor = new RepositoryPersistor ( ) ; return persistor . readConnectionRepository ( fileName ) ; } catch ( Exception e ) { throw new MetadataException ( "Can not read repository " + fileName , e ) ; } }
|
Read JdbcConnectionDescriptors from the given repository file .
|
1,391 |
public ConnectionRepository readConnectionRepository ( InputStream inst ) { try { RepositoryPersistor persistor = new RepositoryPersistor ( ) ; return persistor . readConnectionRepository ( inst ) ; } catch ( Exception e ) { throw new MetadataException ( "Can not read repository from " + inst , e ) ; } }
|
Read JdbcConnectionDescriptors from this InputStream .
|
1,392 |
public void addProfile ( Object key , DescriptorRepository repository ) { if ( metadataProfiles . contains ( key ) ) { throw new MetadataException ( "Duplicate profile key. Key '" + key + "' already exists." ) ; } metadataProfiles . put ( key , repository ) ; }
|
Add a metadata profile .
|
1,393 |
public void loadProfile ( Object key ) { if ( ! isEnablePerThreadChanges ( ) ) { throw new MetadataException ( "Can not load profile with disabled per thread mode" ) ; } DescriptorRepository rep = ( DescriptorRepository ) metadataProfiles . get ( key ) ; if ( rep == null ) { throw new MetadataException ( "Can not find profile for key '" + key + "'" ) ; } currentProfileKey . set ( key ) ; setDescriptor ( rep ) ; }
|
Load the given metadata profile for the current thread .
|
1,394 |
private PBKey buildDefaultKey ( ) { List descriptors = connectionRepository ( ) . getAllDescriptor ( ) ; JdbcConnectionDescriptor descriptor ; PBKey result = null ; for ( Iterator iterator = descriptors . iterator ( ) ; iterator . hasNext ( ) ; ) { descriptor = ( JdbcConnectionDescriptor ) iterator . next ( ) ; if ( descriptor . isDefaultConnection ( ) ) { if ( result != null ) { log . error ( "Found additional connection descriptor with enabled 'default-connection' " + descriptor . getPBKey ( ) + ". This is NOT allowed. Will use the first found descriptor " + result + " as default connection" ) ; } else { result = descriptor . getPBKey ( ) ; } } } if ( result == null ) { log . info ( "No 'default-connection' attribute set in jdbc-connection-descriptors," + " thus it's currently not possible to use 'defaultPersistenceBroker()' " + " convenience method to lookup PersistenceBroker instances. But it's possible" + " to enable this at runtime using 'setDefaultKey' method." ) ; } return result ; }
|
Try to build an default PBKey for convenience PB create method .
|
1,395 |
private Object toReference ( int type , Object referent , int hash ) { switch ( type ) { case HARD : return referent ; case SOFT : return new SoftRef ( hash , referent , queue ) ; case WEAK : return new WeakRef ( hash , referent , queue ) ; default : throw new Error ( ) ; } }
|
Constructs a reference of the given type to the given referent . The reference is registered with the queue for later purging .
|
1,396 |
private Entry getEntry ( Object key ) { if ( key == null ) return null ; int hash = hashCode ( key ) ; int index = indexFor ( hash ) ; for ( Entry entry = table [ index ] ; entry != null ; entry = entry . next ) { if ( ( entry . hash == hash ) && equals ( key , entry . getKey ( ) ) ) { return entry ; } } return null ; }
|
Returns the entry associated with the given key .
|
1,397 |
private int indexFor ( int hash ) { hash += ~ ( hash << 15 ) ; hash ^= ( hash >>> 10 ) ; hash += ( hash << 3 ) ; hash ^= ( hash >>> 6 ) ; hash += ~ ( hash << 11 ) ; hash ^= ( hash >>> 16 ) ; return hash & ( table . length - 1 ) ; }
|
Converts the given hash code into an index into the hash table .
|
1,398 |
public Object get ( Object key ) { purge ( ) ; Entry entry = getEntry ( key ) ; if ( entry == null ) return null ; return entry . getValue ( ) ; }
|
Returns the value associated with the given key if any .
|
1,399 |
public Object remove ( Object key ) { if ( key == null ) return null ; purge ( ) ; int hash = hashCode ( key ) ; int index = indexFor ( hash ) ; Entry previous = null ; Entry entry = table [ index ] ; while ( entry != null ) { if ( ( hash == entry . hash ) && equals ( key , entry . getKey ( ) ) ) { if ( previous == null ) table [ index ] = entry . next ; else previous . next = entry . next ; this . size -- ; modCount ++ ; return entry . getValue ( ) ; } previous = entry ; entry = entry . next ; } return null ; }
|
Removes the key and its associated value from this map .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.