idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
500
protected boolean checkPackageLocators ( String classPackageName ) { if ( packageLocators != null && ! disablePackageLocatorsScanning && classPackageName . length ( ) > 0 && ( packageLocatorsBasePackage == null || classPackageName . startsWith ( packageLocatorsBasePackage ) ) ) { for ( String packageLocator : packageLocators ) { String [ ] splitted = classPackageName . split ( "\\." ) ; if ( es . cenobit . struts2 . json . util . StringUtils . contains ( splitted , packageLocator , false ) ) return true ; } } return false ; }
Checks if class package match provided list of package locators
501
private static List < Segment > parseSegments ( String origPathStr ) { String pathStr = origPathStr ; if ( ! pathStr . startsWith ( "/" ) ) { pathStr = pathStr + "/" ; } List < Segment > result = new ArrayList < > ( ) ; for ( String segmentStr : PATH_SPLITTER . split ( pathStr ) ) { Matcher m = SEGMENT_PATTERN . matcher ( segmentStr ) ; if ( ! m . matches ( ) ) { throw new IllegalArgumentException ( "Bad aql path: " + origPathStr ) ; } Segment segment = new Segment ( ) ; segment . attribute = m . group ( 1 ) ; segment . nodeId = m . groupCount ( ) >= 3 ? m . group ( 3 ) : null ; result . add ( segment ) ; } return result ; }
currently does not support paths with name constrains
502
okhttp3 . Response get ( String url , Map < String , Object > params ) throws RequestException , LocalOperationException { String fullUrl = getFullUrl ( url ) ; okhttp3 . Request request = new okhttp3 . Request . Builder ( ) . url ( addUrlParams ( fullUrl , toPayload ( params ) ) ) . addHeader ( "Transloadit-Client" , version ) . build ( ) ; try { return httpClient . newCall ( request ) . execute ( ) ; } catch ( IOException e ) { throw new RequestException ( e ) ; } }
Makes http GET request .
503
okhttp3 . Response delete ( String url , Map < String , Object > params ) throws RequestException , LocalOperationException { okhttp3 . Request request = new okhttp3 . Request . Builder ( ) . url ( getFullUrl ( url ) ) . delete ( getBody ( toPayload ( params ) , null ) ) . addHeader ( "Transloadit-Client" , version ) . build ( ) ; try { return httpClient . newCall ( request ) . execute ( ) ; } catch ( IOException e ) { throw new RequestException ( e ) ; } }
Makes http DELETE request
504
private String getFullUrl ( String url ) { return url . startsWith ( "https://" ) || url . startsWith ( "http://" ) ? url : transloadit . getHostUrl ( ) + url ; }
Converts url path to the Transloadit full url . Returns the url passed if it is already full .
505
private Map < String , String > toPayload ( Map < String , Object > data ) throws LocalOperationException { Map < String , Object > dataClone = new HashMap < String , Object > ( data ) ; dataClone . put ( "auth" , getAuthData ( ) ) ; Map < String , String > payload = new HashMap < String , String > ( ) ; payload . put ( "params" , jsonifyData ( dataClone ) ) ; if ( transloadit . shouldSignRequest ) { payload . put ( "signature" , getSignature ( jsonifyData ( dataClone ) ) ) ; } return payload ; }
Returns data tree structured as Transloadit expects it .
506
private String jsonifyData ( Map < String , ? extends Object > data ) { JSONObject jsonData = new JSONObject ( data ) ; return jsonData . toString ( ) ; }
converts Map of data to json string
507
private static String convertISO88591toUTF8 ( String value ) { try { return new String ( value . getBytes ( CharEncoding . ISO_8859_1 ) , CharEncoding . UTF_8 ) ; } catch ( UnsupportedEncodingException ex ) { return value ; } }
Converts a string from ISO - 8559 - 1 encoding to UTF - 8 .
508
public Result getResult ( ) throws Exception { Result returnResult = result ; while ( returnResult instanceof ActionChainResult ) { ActionProxy aProxy = ( ( ActionChainResult ) returnResult ) . getProxy ( ) ; if ( aProxy != null ) { Result proxyResult = aProxy . getInvocation ( ) . getResult ( ) ; if ( ( proxyResult != null ) && ( aProxy . getExecuteResult ( ) ) ) { returnResult = proxyResult ; } else { break ; } } else { break ; } } return returnResult ; }
If the DefaultActionInvocation has been executed before and the Result is an instance of ActionChainResult this method will walk down the chain of ActionChainResults until it finds a non - chain result which will be returned . If the DefaultActionInvocation s result has not been executed before the Result instance will be created and populated with the result params .
509
private void executeResult ( ) throws Exception { result = createResult ( ) ; String timerKey = "executeResult: " + getResultCode ( ) ; try { UtilTimerStack . push ( timerKey ) ; if ( result != null ) { result . execute ( this ) ; } else if ( resultCode != null && ! Action . NONE . equals ( resultCode ) ) { throw new ConfigurationException ( "No result defined for action " + getAction ( ) . getClass ( ) . getName ( ) + " and result " + getResultCode ( ) , proxy . getConfig ( ) ) ; } else { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "No result returned for action " + getAction ( ) . getClass ( ) . getName ( ) + " at " + proxy . getConfig ( ) . getLocation ( ) ) ; } } } finally { UtilTimerStack . pop ( timerKey ) ; } }
Uses getResult to get the final Result and executes it
510
protected < C > C convert ( Object object , Class < C > targetClass ) { return this . mapper . convertValue ( object , targetClass ) ; }
convert object into another class using the JSON mapper
511
protected final void sendObjectToSocket ( Object objectToSend , WriteCallback cb ) { Session sess = this . getSession ( ) ; if ( sess != null ) { String json ; try { json = this . mapper . writeValueAsString ( objectToSend ) ; } catch ( JsonProcessingException e ) { throw new RuntimeException ( "Failed to serialize object" , e ) ; } sess . getRemote ( ) . sendString ( json , cb ) ; } }
send object to client and serialize it using JSON
512
public List < String > deviceTypes ( ) { Integer count = json ( ) . size ( DEVICE_FAMILIES ) ; List < String > deviceTypes = new ArrayList < String > ( count ) ; for ( int i = 0 ; i < count ; i ++ ) { String familyNumber = json ( ) . stringValue ( DEVICE_FAMILIES , i ) ; if ( familyNumber . equals ( "1" ) ) deviceTypes . add ( "iPhone" ) ; if ( familyNumber . equals ( "2" ) ) deviceTypes . add ( "iPad" ) ; } return deviceTypes ; }
The list of device types on which this application can run .
513
public static boolean hasAnnotation ( Method method , Class < ? extends Annotation > annotation ) { return ! searchForAnnotation ( method , annotation ) . isEmpty ( ) ; }
Checks if there is an annotation of the given type on this method or on type level for all interfaces and superclasses
514
public static < T extends Annotation > List < T > searchForAnnotation ( Method method , Class < T > annotation ) { if ( method == null ) { return Lists . newArrayList ( ) ; } return searchClasses ( method , annotation , method . getDeclaringClass ( ) ) ; }
Searches for all annotations of the given type on this method or on type level for all interfaces and superclasses
515
public void addStep ( String name , String robot , Map < String , Object > options ) { steps . addStep ( name , robot , options ) ; }
Adds a step to the steps .
516
void merge ( Archetype flatParent , Archetype specialized ) { expandAttributeNodes ( specialized . getDefinition ( ) ) ; flattenCObject ( RmPath . ROOT , null , flatParent . getDefinition ( ) , specialized . getDefinition ( ) ) ; mergeOntologies ( flatParent . getTerminology ( ) , specialized . getTerminology ( ) ) ; if ( flatParent . getAnnotations ( ) != null ) { if ( specialized . getAnnotations ( ) == null ) { specialized . setAnnotations ( new ResourceAnnotations ( ) ) ; } annotationsMerger . merge ( flatParent . getAnnotations ( ) . getItems ( ) , specialized . getAnnotations ( ) . getItems ( ) ) ; } }
Merges a specialized archetype with its parent . Merge will be done in - place on the specialized parameter .
517
public static void addTTLIndex ( DBCollection collection , String field , int ttl ) { if ( ttl <= 0 ) { throw new IllegalArgumentException ( "TTL must be positive" ) ; } collection . createIndex ( new BasicDBObject ( field , 1 ) , new BasicDBObject ( "expireAfterSeconds" , ttl ) ) ; }
adds a TTL index to the given collection . The TTL must be a positive integer .
518
public static void addIndex ( DBCollection collection , String field , boolean asc , boolean background ) { int dir = ( asc ) ? 1 : - 1 ; collection . createIndex ( new BasicDBObject ( field , dir ) , new BasicDBObject ( "background" , background ) ) ; }
Add an index on the given collection and field
519
void checkRmModelConformance ( ) { final AmVisitor < AmObject , AmConstraintContext > visitor = AmVisitors . preorder ( new ConformanceVisitor ( ) ) ; ArchetypeWalker . walkConstraints ( visitor , archetype , new AmConstraintContext ( ) ) ; }
Check if information model entity referenced by archetype has right name or type
520
public static ResourceKey key ( Enum < ? > value ) { return new ResourceKey ( value . getClass ( ) . getName ( ) , value . name ( ) ) ; }
Creates a resource key for given enumeration value . By convention resource bundle for enumerations has the name of enumeration class and value identifier is the same as enumeration value name .
521
public static ResourceKey key ( Class < ? > clazz , String id ) { return new ResourceKey ( clazz . getName ( ) , id ) ; }
Creates a resource key with given id for bundle specified by given class .
522
public static ResourceKey key ( Class < ? > clazz , Enum < ? > value ) { return new ResourceKey ( clazz . getName ( ) , value . name ( ) ) ; }
Creates a resource key with id defined as enumeration value name and bundle specified by given class .
523
public static ResourceKey key ( Enum < ? > enumValue , String key ) { return new ResourceKey ( enumValue . getClass ( ) . getName ( ) , enumValue . name ( ) ) . child ( key ) ; }
Creates a resource key defined as a child of key defined by enumeration value .
524
public void set ( int i , double value ) { switch ( i ) { case 0 : { x = value ; break ; } case 1 : { y = value ; break ; } case 2 : { z = value ; break ; } default : { throw new ArrayIndexOutOfBoundsException ( i ) ; } } }
Sets a single element of this vector . Elements 0 1 and 2 correspond to x y and z .
525
public void set ( Vector3d v1 ) { x = v1 . x ; y = v1 . y ; z = v1 . z ; }
Sets the values of this vector to those of v1 .
526
public void add ( Vector3d v1 , Vector3d v2 ) { x = v1 . x + v2 . x ; y = v1 . y + v2 . y ; z = v1 . z + v2 . z ; }
Adds vector v1 to v2 and places the result in this vector .
527
public void add ( Vector3d v1 ) { x += v1 . x ; y += v1 . y ; z += v1 . z ; }
Adds this vector to v1 and places the result in this vector .
528
public void sub ( Vector3d v1 , Vector3d v2 ) { x = v1 . x - v2 . x ; y = v1 . y - v2 . y ; z = v1 . z - v2 . z ; }
Subtracts vector v1 from v2 and places the result in this vector .
529
public void sub ( Vector3d v1 ) { x -= v1 . x ; y -= v1 . y ; z -= v1 . z ; }
Subtracts v1 from this vector and places the result in this vector .
530
public double distance ( Vector3d v ) { double dx = x - v . x ; double dy = y - v . y ; double dz = z - v . z ; return Math . sqrt ( dx * dx + dy * dy + dz * dz ) ; }
Returns the Euclidean distance between this vector and vector v .
531
public double distanceSquared ( Vector3d v ) { double dx = x - v . x ; double dy = y - v . y ; double dz = z - v . z ; return dx * dx + dy * dy + dz * dz ; }
Returns the squared of the Euclidean distance between this vector and vector v .
532
public double dot ( Vector3d v1 ) { return x * v1 . x + y * v1 . y + z * v1 . z ; }
Returns the dot product of this vector and v1 .
533
public void normalize ( ) { double lenSqr = x * x + y * y + z * z ; double err = lenSqr - 1 ; if ( err > ( 2 * DOUBLE_PREC ) || err < - ( 2 * DOUBLE_PREC ) ) { double len = Math . sqrt ( lenSqr ) ; x /= len ; y /= len ; z /= len ; } }
Normalizes this vector in place .
534
public void cross ( Vector3d v1 , Vector3d v2 ) { double tmpx = v1 . y * v2 . z - v1 . z * v2 . y ; double tmpy = v1 . z * v2 . x - v1 . x * v2 . z ; double tmpz = v1 . x * v2 . y - v1 . y * v2 . x ; x = tmpx ; y = tmpy ; z = tmpz ; }
Computes the cross product of v1 and v2 and places the result in this vector .
535
protected void setRandom ( double lower , double upper , Random generator ) { double range = upper - lower ; x = generator . nextDouble ( ) * range + lower ; y = generator . nextDouble ( ) * range + lower ; z = generator . nextDouble ( ) * range + lower ; }
Sets the elements of this vector to uniformly distributed random values in a specified range using a supplied random number generator .
536
public LuaScriptBlock endBlockReturn ( LuaValue value ) { add ( new LuaAstReturnStatement ( argument ( value ) ) ) ; return new LuaScriptBlock ( script ) ; }
End the script block adding a return value statement
537
public static LuaCondition isNull ( LuaValue value ) { LuaAstExpression expression ; if ( value instanceof LuaLocal ) { expression = new LuaAstLocal ( ( ( LuaLocal ) value ) . getName ( ) ) ; } else { throw new IllegalArgumentException ( "Unexpected value type: " + value . getClass ( ) . getName ( ) ) ; } return new LuaCondition ( new LuaAstNot ( expression ) ) ; }
IS NULL predicate
538
public String getVertexString ( ) { if ( tail ( ) != null ) { return "" + tail ( ) . index + "-" + head ( ) . index ; } else { return "?-" + head ( ) . index ; } }
Produces a string identifying this half - edge by the point index values of its tail and head vertices .
539
public static Face createTriangle ( Vertex v0 , Vertex v1 , Vertex v2 , double minArea ) { Face face = new Face ( ) ; HalfEdge he0 = new HalfEdge ( v0 , face ) ; HalfEdge he1 = new HalfEdge ( v1 , face ) ; HalfEdge he2 = new HalfEdge ( v2 , face ) ; he0 . prev = he2 ; he0 . next = he1 ; he1 . prev = he0 ; he1 . next = he2 ; he2 . prev = he1 ; he2 . next = he0 ; face . he0 = he0 ; face . computeNormalAndCentroid ( minArea ) ; return face ; }
Constructs a triangule Face from vertices v0 v1 and v2 .
540
public double distanceToPlane ( Point3d p ) { return normal . x * p . x + normal . y * p . y + normal . z * p . z - planeOffset ; }
Computes the distance from a point p to the plane of this face .
541
public HalfEdge getEdge ( int i ) { HalfEdge he = he0 ; while ( i > 0 ) { he = he . next ; i -- ; } while ( i < 0 ) { he = he . prev ; i ++ ; } return he ; }
Gets the i - th half - edge associated with the face .
542
public double areaSquared ( HalfEdge hedge0 , HalfEdge hedge1 ) { Point3d p0 = hedge0 . tail ( ) . pnt ; Point3d p1 = hedge0 . head ( ) . pnt ; Point3d p2 = hedge1 . head ( ) . pnt ; double dx1 = p1 . x - p0 . x ; double dy1 = p1 . y - p0 . y ; double dz1 = p1 . z - p0 . z ; double dx2 = p2 . x - p0 . x ; double dy2 = p2 . y - p0 . y ; double dz2 = p2 . z - p0 . z ; double x = dy1 * dz2 - dz1 * dy2 ; double y = dz1 * dx2 - dx1 * dz2 ; double z = dx1 * dy2 - dy1 * dx2 ; return x * x + y * y + z * z ; }
return the squared area of the triangle defined by the half edge hedge0 and the point at the head of hedge1 .
543
protected < T > T fromJsonString ( String json , Class < T > clazz ) { return _gsonParser . fromJson ( json , clazz ) ; }
Convert JsonString to Object of Clazz
544
public LuaScript endScript ( LuaScriptConfig config ) { if ( ! endsWithReturnStatement ( ) ) { add ( new LuaAstReturnStatement ( ) ) ; } String scriptText = buildScriptText ( ) ; return new BasicLuaScript ( scriptText , config ) ; }
End building the script
545
public LuaScript endScriptReturn ( LuaValue value , LuaScriptConfig config ) { add ( new LuaAstReturnStatement ( argument ( value ) ) ) ; String scriptText = buildScriptText ( ) ; return new BasicLuaScript ( scriptText , config ) ; }
End building the script adding a return value statement
546
public LuaPreparedScript endPreparedScript ( LuaScriptConfig config ) { if ( ! endsWithReturnStatement ( ) ) { add ( new LuaAstReturnStatement ( ) ) ; } String scriptText = buildScriptText ( ) ; ArrayList < LuaKeyArgument > keyList = new ArrayList < > ( keyArg2AstArg . keySet ( ) ) ; ArrayList < LuaValueArgument > argvList = new ArrayList < > ( valueArg2AstArg . keySet ( ) ) ; if ( config . isThreadSafe ( ) ) { return new ThreadSafeLuaPreparedScript ( scriptText , keyList , argvList , config ) ; } else { return new BasicLuaPreparedScript ( scriptText , keyList , argvList , config ) ; } }
End building the prepared script
547
public LuaPreparedScript endPreparedScriptReturn ( LuaValue value , LuaScriptConfig config ) { add ( new LuaAstReturnStatement ( argument ( value ) ) ) ; return endPreparedScript ( config ) ; }
End building the prepared script adding a return value statement
548
private synchronized static Cluster getCluster ( URI baseUrl , String [ ] personalities ) throws IOException { final Entry < URI , Set < String > > key = Maps . immutableEntry ( baseUrl , ( Set < String > ) ImmutableSet . copyOf ( personalities ) ) ; Cluster result = CLUSTERS . get ( key ) ; if ( result != null ) { return result ; } result = new Cluster ( EmbeddedPostgreSQL . start ( ) ) ; final DBI dbi = new DBI ( result . getPg ( ) . getTemplateDatabase ( ) ) ; final Migratory migratory = new Migratory ( new MigratoryConfig ( ) { } , dbi , dbi ) ; migratory . addLocator ( new DatabasePreparerLocator ( migratory , baseUrl ) ) ; final MigrationPlan plan = new MigrationPlan ( ) ; int priority = 100 ; for ( final String personality : personalities ) { plan . addMigration ( personality , Integer . MAX_VALUE , priority -- ) ; } migratory . dbMigrate ( plan ) ; result . start ( ) ; CLUSTERS . put ( key , result ) ; return result ; }
Each schema set has its own database cluster . The template1 database has the schema preloaded so that each test case need only create a new database and not re - invoke Migratory .
549
public ImmutableMap < String , String > getConfigurationTweak ( String dbModuleName ) { final DbInfo db = cluster . getNextDb ( ) ; return ImmutableMap . of ( "ness.db." + dbModuleName + ".uri" , getJdbcUri ( db ) , "ness.db." + dbModuleName + ".ds.user" , db . user ) ; }
Return configuration tweaks in a format appropriate for ness - jdbc DatabaseModule .
550
public long remove ( final String ... fields ) { return doWithJedis ( new JedisCallable < Long > ( ) { public Long call ( Jedis jedis ) { return jedis . hdel ( getKey ( ) , fields ) ; } } ) ; }
Remove multiple fields from the map
551
public Double score ( final String member ) { return doWithJedis ( new JedisCallable < Double > ( ) { public Double call ( Jedis jedis ) { return jedis . zscore ( getKey ( ) , member ) ; } } ) ; }
Return the score of the specified element of the sorted set at key .
552
public boolean add ( final String member , final double score ) { return doWithJedis ( new JedisCallable < Boolean > ( ) { public Boolean call ( Jedis jedis ) { return jedis . zadd ( getKey ( ) , score , member ) > 0 ; } } ) ; }
Add an element assigned with its score
553
public long addAll ( final Map < String , Double > scoredMember ) { return doWithJedis ( new JedisCallable < Long > ( ) { public Long call ( Jedis jedis ) { return jedis . zadd ( getKey ( ) , scoredMember ) ; } } ) ; }
Adds to this set all of the elements in the specified map of members and their score .
554
public Set < String > rangeByRank ( final long start , final long end ) { return doWithJedis ( new JedisCallable < Set < String > > ( ) { public Set < String > call ( Jedis jedis ) { return jedis . zrange ( getKey ( ) , start , end ) ; } } ) ; }
Returns the specified range of elements in the sorted set . The elements are considered to be ordered from the lowest to the highest score . Lexicographical order is used for elements with equal score . Both start and stop are zero - based inclusive indexes . They can also be negative numbers indicating offsets from the end of the sorted set with - 1 being the last element of the sorted set .
555
public Set < String > rangeByRankReverse ( final long start , final long end ) { return doWithJedis ( new JedisCallable < Set < String > > ( ) { public Set < String > call ( Jedis jedis ) { return jedis . zrevrange ( getKey ( ) , start , end ) ; } } ) ; }
Returns the specified range of elements in the sorted set . The elements are considered to be ordered from the highest to the lowest score . Descending lexicographical order is used for elements with equal score . Both start and stop are zero - based inclusive indexes . They can also be negative numbers indicating offsets from the end of the sorted set with - 1 being the last element of the sorted set .
556
public long countByLex ( final LexRange lexRange ) { return doWithJedis ( new JedisCallable < Long > ( ) { public Long call ( Jedis jedis ) { return jedis . zlexcount ( getKey ( ) , lexRange . from ( ) , lexRange . to ( ) ) ; } } ) ; }
When all the elements in a sorted set are inserted with the same score in order to force lexicographical ordering this command returns the number of elements in the sorted set with a value in the given range .
557
public Set < String > rangeByLex ( final LexRange lexRange ) { return doWithJedis ( new JedisCallable < Set < String > > ( ) { public Set < String > call ( Jedis jedis ) { if ( lexRange . hasLimit ( ) ) { return jedis . zrangeByLex ( getKey ( ) , lexRange . from ( ) , lexRange . to ( ) , lexRange . offset ( ) , lexRange . count ( ) ) ; } else { return jedis . zrangeByLex ( getKey ( ) , lexRange . from ( ) , lexRange . to ( ) ) ; } } } ) ; }
When all the elements in a sorted set are inserted with the same score in order to force lexicographical ordering this command returns all the elements in the sorted set with a value in the given range . If the elements in the sorted set have different scores the returned elements are unspecified .
558
public Set < String > rangeByLexReverse ( final LexRange lexRange ) { return doWithJedis ( new JedisCallable < Set < String > > ( ) { public Set < String > call ( Jedis jedis ) { if ( lexRange . hasLimit ( ) ) { return jedis . zrevrangeByLex ( getKey ( ) , lexRange . fromReverse ( ) , lexRange . toReverse ( ) , lexRange . offset ( ) , lexRange . count ( ) ) ; } else { return jedis . zrevrangeByLex ( getKey ( ) , lexRange . fromReverse ( ) , lexRange . toReverse ( ) ) ; } } } ) ; }
When all the elements in a sorted set are inserted with the same score in order to force lexicographical ordering this command returns all the elements in the sorted set with a value in the given range .
559
public long removeRangeByLex ( final LexRange lexRange ) { return doWithJedis ( new JedisCallable < Long > ( ) { public Long call ( Jedis jedis ) { return jedis . zremrangeByLex ( getKey ( ) , lexRange . from ( ) , lexRange . to ( ) ) ; } } ) ; }
When all the elements in a sorted set are inserted with the same score in order to force lexicographical ordering this command removes all elements in the sorted set between the lexicographical range specified .
560
public Set < String > rangeByScoreReverse ( final ScoreRange scoreRange ) { return doWithJedis ( new JedisCallable < Set < String > > ( ) { public Set < String > call ( Jedis jedis ) { if ( scoreRange . hasLimit ( ) ) { return jedis . zrevrangeByScore ( getKey ( ) , scoreRange . fromReverse ( ) , scoreRange . toReverse ( ) , scoreRange . offset ( ) , scoreRange . count ( ) ) ; } else { return jedis . zrevrangeByScore ( getKey ( ) , scoreRange . fromReverse ( ) , scoreRange . toReverse ( ) ) ; } } } ) ; }
Returns all the elements in the sorted set with a score in the given range . In contrary to the default ordering of sorted sets for this command the elements are considered to be ordered from high to low scores . The elements having the same score are returned in reverse lexicographical order .
561
public long removeRangeByScore ( final ScoreRange scoreRange ) { return doWithJedis ( new JedisCallable < Long > ( ) { public Long call ( Jedis jedis ) { return jedis . zremrangeByScore ( getKey ( ) , scoreRange . from ( ) , scoreRange . to ( ) ) ; } } ) ; }
Removes all elements in the sorted set with a score in the given range .
562
public void build ( double [ ] coords , int nump ) throws IllegalArgumentException { if ( nump < 4 ) { throw new IllegalArgumentException ( "Less than four input points specified" ) ; } if ( coords . length / 3 < nump ) { throw new IllegalArgumentException ( "Coordinate array too small for specified number of points" ) ; } initBuffers ( nump ) ; setPoints ( coords , nump ) ; buildHull ( ) ; }
Constructs the convex hull of a set of points whose coordinates are given by an array of doubles .
563
public void build ( Point3d [ ] points , int nump ) throws IllegalArgumentException { if ( nump < 4 ) { throw new IllegalArgumentException ( "Less than four input points specified" ) ; } if ( points . length < nump ) { throw new IllegalArgumentException ( "Point array too small for specified number of points" ) ; } initBuffers ( nump ) ; setPoints ( points , nump ) ; buildHull ( ) ; }
Constructs the convex hull of a set of points .
564
public Point3d [ ] getVertices ( ) { Point3d [ ] vtxs = new Point3d [ numVertices ] ; for ( int i = 0 ; i < numVertices ; i ++ ) { vtxs [ i ] = pointBuffer [ vertexPointIndices [ i ] ] . pnt ; } return vtxs ; }
Returns the vertex points in this hull .
565
public int getVertices ( double [ ] coords ) { for ( int i = 0 ; i < numVertices ; i ++ ) { Point3d pnt = pointBuffer [ vertexPointIndices [ i ] ] . pnt ; coords [ i * 3 + 0 ] = pnt . x ; coords [ i * 3 + 1 ] = pnt . y ; coords [ i * 3 + 2 ] = pnt . z ; } return numVertices ; }
Returns the coordinates of the vertex points of this hull .
566
public int [ ] getVertexPointIndices ( ) { int [ ] indices = new int [ numVertices ] ; for ( int i = 0 ; i < numVertices ; i ++ ) { indices [ i ] = vertexPointIndices [ i ] ; } return indices ; }
Returns an array specifing the index of each hull vertex with respect to the original input points .
567
public long addAll ( final String ... members ) { return doWithJedis ( new JedisCallable < Long > ( ) { public Long call ( Jedis jedis ) { return jedis . sadd ( getKey ( ) , members ) ; } } ) ; }
Adds to this set all of the elements in the specified members array
568
public long removeAll ( final String ... members ) { return doWithJedis ( new JedisCallable < Long > ( ) { public Long call ( Jedis jedis ) { return jedis . srem ( getKey ( ) , members ) ; } } ) ; }
Removes from this set all of its elements that are contained in the specified members array
569
public String pop ( ) { return doWithJedis ( new JedisCallable < String > ( ) { public String call ( Jedis jedis ) { return jedis . spop ( getKey ( ) ) ; } } ) ; }
Removes and returns a random element from the set .
570
protected Object [ ] idsOf ( final List < ? > idsOrValues ) { final Object [ ] ids = idsOrValues . toArray ( ) ; int length = 0 ; for ( int i = 0 ; i < ids . length ; ) { final Object p = ids [ i ++ ] ; if ( p instanceof HasId ) { final String id = ( ( HasId ) p ) . getId ( ) ; if ( ! StringUtils . isEmpty ( id ) ) { ids [ length ++ ] = id ; } } else if ( p instanceof String ) { final String id = p . toString ( ) ; if ( ! StringUtils . isEmpty ( id ) ) { ids [ length ++ ] = id ; } } else if ( p != null ) { throw new StoreException ( "Invalid id or value of type " + p ) ; } } if ( length == 0 ) { return null ; } if ( length != ids . length ) { final Object [ ] tmp = new Object [ length ] ; System . arraycopy ( ids , 0 , tmp , 0 , length ) ; return tmp ; } return ids ; }
Returns an array of non - empty ids from the given list of ids or values .
571
public long indexOf ( final String element ) { return doWithJedis ( new JedisCallable < Long > ( ) { public Long call ( Jedis jedis ) { return doIndexOf ( jedis , element ) ; } } ) ; }
Find the index of the first matching element in the list
572
public String get ( final long index ) { return doWithJedis ( new JedisCallable < String > ( ) { public String call ( Jedis jedis ) { return jedis . lindex ( getKey ( ) , index ) ; } } ) ; }
Get the element value in the list by index
573
public List < String > subList ( final long fromIndex , final long toIndex ) { return doWithJedis ( new JedisCallable < List < String > > ( ) { public List < String > call ( Jedis jedis ) { return jedis . lrange ( getKey ( ) , fromIndex , toIndex ) ; } } ) ; }
Get a sub - list of this list
574
private void ensureNext ( ) { if ( resultIndex < scanResult . getResult ( ) . size ( ) ) { return ; } if ( ! FIRST_CURSOR . equals ( scanResult . getStringCursor ( ) ) ) { scanResult = scan ( scanResult . getStringCursor ( ) , scanParams ) ; resultIndex = 0 ; ensureNext ( ) ; } }
Make sure the result index points to the next available key in the scan result if exists .
575
public void addAll ( Vertex vtx ) { if ( head == null ) { head = vtx ; } else { tail . next = vtx ; } vtx . prev = tail ; while ( vtx . next != null ) { vtx = vtx . next ; } tail = vtx ; }
Adds a chain of vertices to the end of this list .
576
public void delete ( Vertex vtx ) { if ( vtx . prev == null ) { head = vtx . next ; } else { vtx . prev . next = vtx . next ; } if ( vtx . next == null ) { tail = vtx . prev ; } else { vtx . next . prev = vtx . prev ; } }
Deletes a vertex from this list .
577
public void delete ( Vertex vtx1 , Vertex vtx2 ) { if ( vtx1 . prev == null ) { head = vtx2 . next ; } else { vtx1 . prev . next = vtx2 . next ; } if ( vtx2 . next == null ) { tail = vtx1 . prev ; } else { vtx2 . next . prev = vtx1 . prev ; } }
Deletes a chain of vertices from this list .
578
public void insertBefore ( Vertex vtx , Vertex next ) { vtx . prev = next . prev ; if ( next . prev == null ) { head = vtx ; } else { next . prev . next = vtx ; } vtx . next = next ; next . prev = vtx ; }
Inserts a vertex into this list before another specificed vertex .
579
private static void freeTempLOB ( ClobWrapper clob , BlobWrapper blob ) { try { if ( clob != null ) { if ( clob . isOpen ( ) ) { clob . close ( ) ; } clob . freeTemporary ( ) ; } if ( blob != null ) { if ( blob . isOpen ( ) ) { blob . close ( ) ; } blob . freeTemporary ( ) ; } } catch ( Exception e ) { logger . error ( "Error during temporary LOB release" , e ) ; } }
Frees the temporary LOBs when an exception is raised in the application or when the LOBs are no longer needed . If the LOBs are not freed the space used by these LOBs are not reclaimed .
580
public void check ( CollectionDescriptorDef collDef , String checkLevel ) throws ConstraintException { ensureElementClassRef ( collDef , checkLevel ) ; checkInheritedForeignkey ( collDef , checkLevel ) ; ensureCollectionClass ( collDef , checkLevel ) ; checkProxyPrefetchingLimit ( collDef , checkLevel ) ; checkOrderby ( collDef , checkLevel ) ; checkQueryCustomizer ( collDef , checkLevel ) ; }
Checks the given collection descriptor .
581
private void ensureElementClassRef ( CollectionDescriptorDef collDef , String checkLevel ) throws ConstraintException { if ( CHECKLEVEL_NONE . equals ( checkLevel ) ) { return ; } String arrayElementClassName = collDef . getProperty ( PropertyHelper . OJB_PROPERTY_ARRAY_ELEMENT_CLASS_REF ) ; if ( ! collDef . hasProperty ( PropertyHelper . OJB_PROPERTY_ELEMENT_CLASS_REF ) ) { if ( arrayElementClassName != null ) { collDef . setProperty ( PropertyHelper . OJB_PROPERTY_ELEMENT_CLASS_REF , arrayElementClassName ) ; } else { throw new ConstraintException ( "Collection " + collDef . getName ( ) + " in class " + collDef . getOwner ( ) . getName ( ) + " does not specify its element class" ) ; } } ModelDef model = ( ModelDef ) collDef . getOwner ( ) . getOwner ( ) ; String elementClassName = collDef . getProperty ( PropertyHelper . OJB_PROPERTY_ELEMENT_CLASS_REF ) ; ClassDescriptorDef elementClassDef = model . getClass ( elementClassName ) ; if ( elementClassDef == null ) { throw new ConstraintException ( "Collection " + collDef . getName ( ) + " in class " + collDef . getOwner ( ) . getName ( ) + " references an unknown class " + elementClassName ) ; } if ( ! elementClassDef . getBooleanProperty ( PropertyHelper . OJB_PROPERTY_OJB_PERSISTENT , false ) ) { throw new ConstraintException ( "The element class " + elementClassName + " of the collection " + collDef . getName ( ) + " in class " + collDef . getOwner ( ) . getName ( ) + " is not persistent" ) ; } if ( CHECKLEVEL_STRICT . equals ( checkLevel ) && ( arrayElementClassName != null ) ) { try { InheritanceHelper helper = new InheritanceHelper ( ) ; if ( ! helper . isSameOrSubTypeOf ( elementClassDef , arrayElementClassName , true ) ) { throw new ConstraintException ( "The element class " + elementClassName + " of the collection " + collDef . getName ( ) + " in class " + collDef . getOwner ( ) . getName ( ) + " is not the same or a subtype of the array base type " + arrayElementClassName ) ; } } catch ( ClassNotFoundException ex ) { throw new ConstraintException ( "Could not find the class " + ex . getMessage ( ) + " on the classpath while checking the collection " + collDef . getName ( ) + " in class " + collDef . getOwner ( ) . getName ( ) ) ; } } collDef . setProperty ( PropertyHelper . OJB_PROPERTY_ELEMENT_CLASS_REF , elementClassDef . getName ( ) ) ; }
Ensures that the given collection descriptor has a valid element - class - ref property .
582
private void ensureCollectionClass ( CollectionDescriptorDef collDef , String checkLevel ) throws ConstraintException { if ( CHECKLEVEL_NONE . equals ( checkLevel ) ) { return ; } if ( collDef . hasProperty ( PropertyHelper . OJB_PROPERTY_ARRAY_ELEMENT_CLASS_REF ) ) { if ( collDef . hasProperty ( PropertyHelper . OJB_PROPERTY_COLLECTION_CLASS ) ) { throw new ConstraintException ( "Collection " + collDef . getName ( ) + " in class " + collDef . getOwner ( ) . getName ( ) + " is an array but does specify collection-class" ) ; } else { return ; } } if ( CHECKLEVEL_STRICT . equals ( checkLevel ) ) { InheritanceHelper helper = new InheritanceHelper ( ) ; ModelDef model = ( ModelDef ) collDef . getOwner ( ) . getOwner ( ) ; String specifiedClass = collDef . getProperty ( PropertyHelper . OJB_PROPERTY_COLLECTION_CLASS ) ; String variableType = collDef . getProperty ( PropertyHelper . OJB_PROPERTY_VARIABLE_TYPE ) ; try { if ( specifiedClass != null ) { if ( ! helper . isSameOrSubTypeOf ( specifiedClass , variableType ) ) { throw new ConstraintException ( "The type " + specifiedClass + " specified as collection-class of the collection " + collDef . getName ( ) + " in class " + collDef . getOwner ( ) . getName ( ) + " is not a sub type of the variable type " + variableType ) ; } if ( ! helper . isSameOrSubTypeOf ( specifiedClass , MANAGEABLE_COLLECTION_INTERFACE ) ) { throw new ConstraintException ( "The type " + specifiedClass + " specified as collection-class of the collection " + collDef . getName ( ) + " in class " + collDef . getOwner ( ) . getName ( ) + " does not implement " + MANAGEABLE_COLLECTION_INTERFACE ) ; } } else { if ( helper . isSameOrSubTypeOf ( variableType , MANAGEABLE_COLLECTION_INTERFACE ) ) { collDef . setProperty ( PropertyHelper . OJB_PROPERTY_COLLECTION_CLASS , variableType ) ; } else if ( ! helper . isSameOrSubTypeOf ( variableType , JAVA_COLLECTION_INTERFACE ) ) { throw new ConstraintException ( "The collection " + collDef . getName ( ) + " in class " + collDef . getOwner ( ) . getName ( ) + " needs the collection-class attribute as its variable type does not implement " + JAVA_COLLECTION_INTERFACE ) ; } } } catch ( ClassNotFoundException ex ) { throw new ConstraintException ( "Could not find the class " + ex . getMessage ( ) + " on the classpath while checking the collection " + collDef . getName ( ) + " in class " + collDef . getOwner ( ) . getName ( ) ) ; } } }
Ensures that the given collection descriptor has the collection - class property if necessary .
583
private void checkOrderby ( CollectionDescriptorDef collDef , String checkLevel ) throws ConstraintException { if ( CHECKLEVEL_NONE . equals ( checkLevel ) ) { return ; } String orderbySpec = collDef . getProperty ( PropertyHelper . OJB_PROPERTY_ORDERBY ) ; if ( ( orderbySpec == null ) || ( orderbySpec . length ( ) == 0 ) ) { return ; } ClassDescriptorDef ownerClass = ( ClassDescriptorDef ) collDef . getOwner ( ) ; String elementClassName = collDef . getProperty ( PropertyHelper . OJB_PROPERTY_ELEMENT_CLASS_REF ) . replace ( '$' , '.' ) ; ClassDescriptorDef elementClass = ( ( ModelDef ) ownerClass . getOwner ( ) ) . getClass ( elementClassName ) ; FieldDescriptorDef fieldDef ; String token ; String fieldName ; String ordering ; int pos ; for ( CommaListIterator it = new CommaListIterator ( orderbySpec ) ; it . hasNext ( ) ; ) { token = it . getNext ( ) ; pos = token . indexOf ( '=' ) ; if ( pos == - 1 ) { fieldName = token ; ordering = null ; } else { fieldName = token . substring ( 0 , pos ) ; ordering = token . substring ( pos + 1 ) ; } fieldDef = elementClass . getField ( fieldName ) ; if ( fieldDef == null ) { throw new ConstraintException ( "The field " + fieldName + " specified in the orderby attribute of the collection " + collDef . getName ( ) + " in class " + ownerClass . getName ( ) + " hasn't been found in the element class " + elementClass . getName ( ) ) ; } if ( ( ordering != null ) && ( ordering . length ( ) > 0 ) && ! "ASC" . equals ( ordering ) && ! "DESC" . equals ( ordering ) ) { throw new ConstraintException ( "The ordering " + ordering + " specified in the orderby attribute of the collection " + collDef . getName ( ) + " in class " + ownerClass . getName ( ) + " is invalid" ) ; } } }
Checks the orderby attribute .
584
private void checkQueryCustomizer ( CollectionDescriptorDef collDef , String checkLevel ) throws ConstraintException { if ( ! CHECKLEVEL_STRICT . equals ( checkLevel ) ) { return ; } String queryCustomizerName = collDef . getProperty ( PropertyHelper . OJB_PROPERTY_QUERY_CUSTOMIZER ) ; if ( queryCustomizerName == null ) { return ; } try { InheritanceHelper helper = new InheritanceHelper ( ) ; if ( ! helper . isSameOrSubTypeOf ( queryCustomizerName , QUERY_CUSTOMIZER_INTERFACE ) ) { throw new ConstraintException ( "The class " + queryCustomizerName + " specified as query-customizer of collection " + collDef . getName ( ) + " in class " + collDef . getOwner ( ) . getName ( ) + " does not implement the interface " + QUERY_CUSTOMIZER_INTERFACE ) ; } } catch ( ClassNotFoundException ex ) { throw new ConstraintException ( "The class " + ex . getMessage ( ) + " specified as query-customizer of collection " + collDef . getName ( ) + " in class " + collDef . getOwner ( ) . getName ( ) + " was not found on the classpath" ) ; } }
Checks the query - customizer setting of the given collection descriptor .
585
public static Class getClass ( String className , boolean initialize ) throws ClassNotFoundException { return Class . forName ( className , initialize , getClassLoader ( ) ) ; }
Retrieves the class object for the given qualified class name .
586
public static Object newInstance ( Class target , Class [ ] types , Object [ ] args ) throws InstantiationException , IllegalAccessException , IllegalArgumentException , InvocationTargetException , NoSuchMethodException , SecurityException { return newInstance ( target , types , args , false ) ; }
Returns a new instance of the given class using the constructor with the specified parameter types .
587
public static Field getField ( Class clazz , String fieldName ) { try { return clazz . getField ( fieldName ) ; } catch ( Exception ignored ) { } return null ; }
Determines the field via reflection look - up .
588
public static Object newInstance ( String className ) throws InstantiationException , IllegalAccessException , ClassNotFoundException { return newInstance ( getClass ( className ) ) ; }
Returns a new instance of the class with the given qualified name using the default or or a no - arg constructor .
589
public static Object newInstance ( String className , Class [ ] types , Object [ ] args ) throws InstantiationException , IllegalAccessException , IllegalArgumentException , InvocationTargetException , NoSuchMethodException , SecurityException , ClassNotFoundException { return newInstance ( getClass ( className ) , types , args ) ; }
Returns a new instance of the class with the given qualified name using the constructor with the specified signature .
590
public static Object newInstance ( Class target , Class type , Object arg ) throws InstantiationException , IllegalAccessException , IllegalArgumentException , InvocationTargetException , NoSuchMethodException , SecurityException { return newInstance ( target , new Class [ ] { type } , new Object [ ] { arg } ) ; }
Returns a new instance of the given class using the constructor with the specified parameter .
591
public static Object newInstance ( String className , Class type , Object arg ) throws InstantiationException , IllegalAccessException , IllegalArgumentException , InvocationTargetException , NoSuchMethodException , SecurityException , ClassNotFoundException { return newInstance ( className , new Class [ ] { type } , new Object [ ] { arg } ) ; }
Returns a new instance of the class with the given qualified name using the constructor with the specified parameter .
592
public static Object buildNewObjectInstance ( ClassDescriptor cld ) { Object result = null ; if ( ( cld . getFactoryClass ( ) == null ) || ( cld . getFactoryMethod ( ) == null ) ) { try { Constructor con = cld . getZeroArgumentConstructor ( ) ; if ( con == null ) { throw new ClassNotPersistenceCapableException ( "A zero argument constructor was not provided! Class was '" + cld . getClassNameOfObject ( ) + "'" ) ; } result = ConstructorHelper . instantiate ( con ) ; } catch ( InstantiationException e ) { throw new ClassNotPersistenceCapableException ( "Can't instantiate class '" + cld . getClassNameOfObject ( ) + "'" ) ; } } else { try { Method method = cld . getFactoryMethod ( ) ; if ( Modifier . isStatic ( method . getModifiers ( ) ) ) { result = method . invoke ( null , null ) ; } else { Object factoryInstance = cld . getFactoryClass ( ) . newInstance ( ) ; result = method . invoke ( factoryInstance , null ) ; } } catch ( Exception ex ) { throw new PersistenceBrokerException ( "Unable to build object instance of class '" + cld . getClassNameOfObject ( ) + "' from factory:" + cld . getFactoryClass ( ) + "." + cld . getFactoryMethod ( ) , ex ) ; } } return result ; }
Builds a new instance for the class represented by the given class descriptor .
593
private GraphicsDocument createFeatureDocument ( StringWriter writer ) throws RenderException { if ( TileMetadata . PARAM_SVG_RENDERER . equalsIgnoreCase ( renderer ) ) { DefaultSvgDocument document = new DefaultSvgDocument ( writer , false ) ; document . setMaximumFractionDigits ( MAXIMUM_FRACTION_DIGITS ) ; document . registerWriter ( InternalFeatureImpl . class , new SvgFeatureWriter ( getTransformer ( ) ) ) ; document . registerWriter ( InternalTileImpl . class , new SvgTileWriter ( ) ) ; return document ; } else if ( TileMetadata . PARAM_VML_RENDERER . equalsIgnoreCase ( renderer ) ) { DefaultVmlDocument document = new DefaultVmlDocument ( writer ) ; int coordWidth = tile . getScreenWidth ( ) ; int coordHeight = tile . getScreenHeight ( ) ; document . registerWriter ( InternalFeatureImpl . class , new VmlFeatureWriter ( getTransformer ( ) , coordWidth , coordHeight ) ) ; document . registerWriter ( InternalTileImpl . class , new VmlTileWriter ( coordWidth , coordHeight ) ) ; document . setMaximumFractionDigits ( MAXIMUM_FRACTION_DIGITS ) ; return document ; } else { throw new RenderException ( ExceptionCode . RENDERER_TYPE_NOT_SUPPORTED , renderer ) ; } }
Create a document that parses the tile s featureFragment using GraphicsWriter classes .
594
private GraphicsDocument createLabelDocument ( StringWriter writer , LabelStyleInfo labelStyleInfo ) throws RenderException { if ( TileMetadata . PARAM_SVG_RENDERER . equalsIgnoreCase ( renderer ) ) { DefaultSvgDocument document = new DefaultSvgDocument ( writer , false ) ; document . setMaximumFractionDigits ( MAXIMUM_FRACTION_DIGITS ) ; document . registerWriter ( InternalTileImpl . class , new SvgLabelTileWriter ( getTransformer ( ) , labelStyleInfo , geoService , textService ) ) ; return document ; } else if ( TileMetadata . PARAM_VML_RENDERER . equalsIgnoreCase ( renderer ) ) { DefaultVmlDocument document = new DefaultVmlDocument ( writer ) ; int coordWidth = tile . getScreenWidth ( ) ; int coordHeight = tile . getScreenHeight ( ) ; document . registerWriter ( InternalFeatureImpl . class , new VmlFeatureWriter ( getTransformer ( ) , coordWidth , coordHeight ) ) ; document . registerWriter ( InternalTileImpl . class , new VmlLabelTileWriter ( coordWidth , coordHeight , getTransformer ( ) , labelStyleInfo , geoService , textService ) ) ; document . setMaximumFractionDigits ( MAXIMUM_FRACTION_DIGITS ) ; return document ; } else { throw new RenderException ( ExceptionCode . RENDERER_TYPE_NOT_SUPPORTED , renderer ) ; } }
Create a document that parses the tile s labelFragment using GraphicsWriter classes .
595
private GeometryCoordinateSequenceTransformer getTransformer ( ) { if ( unitToPixel == null ) { unitToPixel = new GeometryCoordinateSequenceTransformer ( ) ; unitToPixel . setMathTransform ( ProjectiveTransform . create ( new AffineTransform ( scale , 0 , 0 , - scale , - scale * panOrigin . x , scale * panOrigin . y ) ) ) ; } return unitToPixel ; }
Get transformer to use .
596
private void doExecute ( Connection conn ) throws SQLException { PreparedStatement stmt ; int size ; size = _methods . size ( ) ; if ( size == 0 ) { return ; } stmt = conn . prepareStatement ( _sql ) ; try { m_platform . afterStatementCreate ( stmt ) ; } catch ( PlatformException e ) { if ( e . getCause ( ) instanceof SQLException ) { throw ( SQLException ) e . getCause ( ) ; } else { throw new SQLException ( e . getMessage ( ) ) ; } } try { m_platform . beforeBatch ( stmt ) ; } catch ( PlatformException e ) { if ( e . getCause ( ) instanceof SQLException ) { throw ( SQLException ) e . getCause ( ) ; } else { throw new SQLException ( e . getMessage ( ) ) ; } } try { for ( int i = 0 ; i < size ; i ++ ) { Method method = ( Method ) _methods . get ( i ) ; try { if ( method . equals ( ADD_BATCH ) ) { m_platform . addBatch ( stmt ) ; } else { method . invoke ( stmt , ( Object [ ] ) _params . get ( i ) ) ; } } catch ( IllegalArgumentException ex ) { StringBuffer buffer = generateExceptionMessage ( i , stmt , ex ) ; throw new SQLException ( buffer . toString ( ) ) ; } catch ( IllegalAccessException ex ) { StringBuffer buffer = generateExceptionMessage ( i , stmt , ex ) ; throw new SQLException ( buffer . toString ( ) ) ; } catch ( InvocationTargetException ex ) { Throwable th = ex . getTargetException ( ) ; if ( th == null ) { th = ex ; } if ( th instanceof SQLException ) { throw ( ( SQLException ) th ) ; } else { throw new SQLException ( th . toString ( ) ) ; } } catch ( PlatformException e ) { throw new SQLException ( e . toString ( ) ) ; } } try { m_platform . executeBatch ( stmt ) ; } catch ( PlatformException e ) { if ( e . getCause ( ) instanceof SQLException ) { throw ( SQLException ) e . getCause ( ) ; } else { throw new SQLException ( e . getMessage ( ) ) ; } } } finally { stmt . close ( ) ; _methods . clear ( ) ; _params . clear ( ) ; } }
This method performs database modification at the very and of transaction .
597
public Object getBeliefValue ( String agent_name , final String belief_name , Connector connector ) { ( ( IExternalAccess ) connector . getAgentsExternalAccess ( agent_name ) ) . scheduleStep ( new IComponentStep < Integer > ( ) { public IFuture < Integer > execute ( IInternalAccess ia ) { IBDIInternalAccess bia = ( IBDIInternalAccess ) ia ; belief_value = bia . getBeliefbase ( ) . getBelief ( belief_name ) . getFact ( ) ; return null ; } } ) . get ( new ThreadSuspendable ( ) ) ; return belief_value ; }
This method takes the value of an agent s belief through its external access
598
public void setBeliefValue ( String agent_name , final String belief_name , final Object new_value , Connector connector ) { ( ( IExternalAccess ) connector . getAgentsExternalAccess ( agent_name ) ) . scheduleStep ( new IComponentStep < Integer > ( ) { public IFuture < Integer > execute ( IInternalAccess ia ) { IBDIInternalAccess bia = ( IBDIInternalAccess ) ia ; bia . getBeliefbase ( ) . getBelief ( belief_name ) . setFact ( new_value ) ; return null ; } } ) . get ( new ThreadSuspendable ( ) ) ; }
This method changes the value of an agent s belief through its external access
599
public IPlan [ ] getAgentPlans ( final String agent_name , Connector connector ) { ( ( IExternalAccess ) connector . getAgentsExternalAccess ( agent_name ) ) . scheduleStep ( new IComponentStep < Plan > ( ) { public IFuture < Plan > execute ( IInternalAccess ia ) { IBDIInternalAccess bia = ( IBDIInternalAccess ) ia ; plans = bia . getPlanbase ( ) . getPlans ( ) ; return null ; } } ) . get ( new ThreadSuspendable ( ) ) ; return plans ; }
This method prints plan information of an agent through its external access . It can be used to check the correct behaviour of the agent .