idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
145,800
static PatchingResult executeTasks ( final IdentityPatchContext context , final IdentityPatchContext . FinalizeCallback callback ) throws Exception { final List < PreparedTask > tasks = new ArrayList < PreparedTask > ( ) ; final List < ContentItem > conflicts = new ArrayList < ContentItem > ( ) ; // Identity prepareTasks ( context . getIdentityEntry ( ) , context , tasks , conflicts ) ; // Layers for ( final IdentityPatchContext . PatchEntry layer : context . getLayers ( ) ) { prepareTasks ( layer , context , tasks , conflicts ) ; } // AddOns for ( final IdentityPatchContext . PatchEntry addOn : context . getAddOns ( ) ) { prepareTasks ( addOn , context , tasks , conflicts ) ; } // If there were problems report them if ( ! conflicts . isEmpty ( ) ) { throw PatchLogger . ROOT_LOGGER . conflictsDetected ( conflicts ) ; } // Execute the tasks for ( final PreparedTask task : tasks ) { // Unless it's excluded by the user final ContentItem item = task . getContentItem ( ) ; if ( item != null && context . isExcluded ( item ) ) { continue ; } // Run the task task . execute ( ) ; } return context . finalize ( callback ) ; }
Execute all recorded tasks .
279
6
145,801
static void prepareTasks ( final IdentityPatchContext . PatchEntry entry , final IdentityPatchContext context , final List < PreparedTask > tasks , final List < ContentItem > conflicts ) throws PatchingException { for ( final PatchingTasks . ContentTaskDefinition definition : entry . getTaskDefinitions ( ) ) { final PatchingTask task = createTask ( definition , context , entry ) ; if ( ! task . isRelevant ( entry ) ) { continue ; } try { // backup and validate content if ( ! task . prepare ( entry ) || definition . hasConflicts ( ) ) { // Unless it a content item was manually ignored (or excluded) final ContentItem item = task . getContentItem ( ) ; if ( ! context . isIgnored ( item ) ) { conflicts . add ( item ) ; } } tasks . add ( new PreparedTask ( task , entry ) ) ; } catch ( IOException e ) { throw new PatchingException ( e ) ; } } }
Prepare all tasks .
207
5
145,802
static PatchingTask createTask ( final PatchingTasks . ContentTaskDefinition definition , final PatchContentProvider provider , final IdentityPatchContext . PatchEntry context ) { final PatchContentLoader contentLoader = provider . getLoader ( definition . getTarget ( ) . getPatchId ( ) ) ; final PatchingTaskDescription description = PatchingTaskDescription . create ( definition , contentLoader ) ; return PatchingTask . Factory . create ( description , context ) ; }
Create the patching task based on the definition .
95
10
145,803
static void checkUpgradeConditions ( final UpgradeCondition condition , final InstallationManager . MutablePatchingTarget target ) throws PatchingException { // See if the prerequisites are met for ( final String required : condition . getRequires ( ) ) { if ( ! target . isApplied ( required ) ) { throw PatchLogger . ROOT_LOGGER . requiresPatch ( required ) ; } } // Check for incompatibilities for ( final String incompatible : condition . getIncompatibleWith ( ) ) { if ( target . isApplied ( incompatible ) ) { throw PatchLogger . ROOT_LOGGER . incompatiblePatch ( incompatible ) ; } } }
Check whether the patch can be applied to a given target .
136
12
145,804
public static List < DomainControllerData > domainControllerDataFromByteBuffer ( byte [ ] buffer ) throws Exception { List < DomainControllerData > retval = new ArrayList < DomainControllerData > ( ) ; if ( buffer == null ) { return retval ; } ByteArrayInputStream in_stream = new ByteArrayInputStream ( buffer ) ; DataInputStream in = new DataInputStream ( in_stream ) ; String content = SEPARATOR ; while ( SEPARATOR . equals ( content ) ) { DomainControllerData data = new DomainControllerData ( ) ; data . readFrom ( in ) ; retval . add ( data ) ; try { content = readString ( in ) ; } catch ( EOFException ex ) { content = null ; } } in . close ( ) ; return retval ; }
Get the domain controller data from the given byte buffer .
170
11
145,805
public static byte [ ] domainControllerDataToByteBuffer ( List < DomainControllerData > data ) throws Exception { final ByteArrayOutputStream out_stream = new ByteArrayOutputStream ( 512 ) ; byte [ ] result ; try ( DataOutputStream out = new DataOutputStream ( out_stream ) ) { Iterator < DomainControllerData > iter = data . iterator ( ) ; while ( iter . hasNext ( ) ) { DomainControllerData dcData = iter . next ( ) ; dcData . writeTo ( out ) ; if ( iter . hasNext ( ) ) { S3Util . writeString ( SEPARATOR , out ) ; } } result = out_stream . toByteArray ( ) ; } return result ; }
Write the domain controller data to a byte buffer .
154
10
145,806
private boolean canSuccessorProceed ( ) { if ( predecessor != null && ! predecessor . canSuccessorProceed ( ) ) { return false ; } synchronized ( this ) { while ( responseCount < groups . size ( ) ) { try { wait ( ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; return false ; } } return ! failed ; } }
Check from another ConcurrentGroupServerUpdatePolicy whose plans are meant to execute once this policy s plans are successfully completed .
86
24
145,807
public void recordServerGroupResult ( final String serverGroup , final boolean failed ) { synchronized ( this ) { if ( groups . contains ( serverGroup ) ) { responseCount ++ ; if ( failed ) { this . failed = true ; } DomainControllerLogger . HOST_CONTROLLER_LOGGER . tracef ( "Recorded group result for '%s': failed = %s" , serverGroup , failed ) ; notifyAll ( ) ; } else { throw DomainControllerLogger . HOST_CONTROLLER_LOGGER . unknownServerGroup ( serverGroup ) ; } } }
Records the result of updating a server group .
128
10
145,808
@ SuppressWarnings ( "deprecation" ) protected ModelNode executeReadOnlyOperation ( final ModelNode operation , final OperationMessageHandler handler , final OperationTransactionControl control , final OperationStepHandler prepareStep , final int operationId ) { final AbstractOperationContext delegateContext = getDelegateContext ( operationId ) ; CurrentOperationIdHolder . setCurrentOperationID ( operationId ) ; try { return executeReadOnlyOperation ( operation , delegateContext . getManagementModel ( ) , control , prepareStep , delegateContext ) ; } finally { CurrentOperationIdHolder . setCurrentOperationID ( null ) ; } }
Executes an operation on the controller latching onto an existing transaction
129
13
145,809
public synchronized void addShutdownListener ( ShutdownListener listener ) { if ( state == CLOSED ) { listener . handleCompleted ( ) ; } else { listeners . add ( listener ) ; } }
Add a shutdown listener which gets called when all requests completed on shutdown .
40
14
145,810
protected synchronized void handleCompleted ( ) { latch . countDown ( ) ; for ( final ShutdownListener listener : listeners ) { listener . handleCompleted ( ) ; } listeners . clear ( ) ; }
Notify all shutdown listeners that the shutdown completed .
40
10
145,811
public boolean hasDeploymentSubsystemModel ( final String subsystemName ) { final Resource root = deploymentUnit . getAttachment ( DEPLOYMENT_RESOURCE ) ; final PathElement subsystem = PathElement . pathElement ( SUBSYSTEM , subsystemName ) ; return root . hasChild ( subsystem ) ; }
Checks to see if a subsystem resource has already been registered for the deployment .
65
16
145,812
public ModelNode getDeploymentSubsystemModel ( final String subsystemName ) { assert subsystemName != null : "The subsystemName cannot be null" ; return getDeploymentSubModel ( subsystemName , PathAddress . EMPTY_ADDRESS , null , deploymentUnit ) ; }
Get the subsystem deployment model root .
58
7
145,813
public ModelNode registerDeploymentSubsystemResource ( final String subsystemName , final Resource resource ) { assert subsystemName != null : "The subsystemName cannot be null" ; assert resource != null : "The resource cannot be null" ; return registerDeploymentSubResource ( subsystemName , PathAddress . EMPTY_ADDRESS , resource ) ; }
Registers the resource to the parent deployment resource . The model returned is that of the resource parameter .
72
20
145,814
static Resource getOrCreateSubDeployment ( final String deploymentName , final DeploymentUnit parent ) { final Resource root = parent . getAttachment ( DEPLOYMENT_RESOURCE ) ; return getOrCreate ( root , PathElement . pathElement ( SUBDEPLOYMENT , deploymentName ) ) ; }
Gets or creates the a resource for the sub - deployment on the parent deployments resource .
65
18
145,815
static void cleanup ( final Resource resource ) { synchronized ( resource ) { for ( final Resource . ResourceEntry entry : resource . getChildren ( SUBSYSTEM ) ) { resource . removeChild ( entry . getPathElement ( ) ) ; } for ( final Resource . ResourceEntry entry : resource . getChildren ( SUBDEPLOYMENT ) ) { resource . removeChild ( entry . getPathElement ( ) ) ; } } }
Cleans up the subsystem children for the deployment and each sub - deployment resource .
89
16
145,816
Path resolveBaseDir ( final String name , final String dirName ) { final String currentDir = SecurityActions . getPropertyPrivileged ( name ) ; if ( currentDir == null ) { return jbossHomeDir . resolve ( dirName ) ; } return Paths . get ( currentDir ) ; }
Resolves the base directory . If the system property is set that value will be used . Otherwise the path is resolved from the home directory .
64
28
145,817
static Path resolvePath ( final Path base , final String ... paths ) { return Paths . get ( base . toString ( ) , paths ) ; }
Resolves a path relative to the base path .
32
10
145,818
static Map < String , Set < String > > getChildAddresses ( final OperationContext context , final PathAddress addr , final ImmutableManagementResourceRegistration registry , Resource resource , final String validChildType ) { Map < String , Set < String > > result = new HashMap <> ( ) ; Predicate < String > validChildTypeFilter = childType -> ( validChildType == null ) || validChildType . equals ( childType ) ; if ( resource != null ) { for ( String childType : registry . getChildNames ( PathAddress . EMPTY_ADDRESS ) ) { if ( validChildTypeFilter . test ( childType ) ) { List < String > list = new ArrayList <> ( ) ; for ( String child : resource . getChildrenNames ( childType ) ) { if ( registry . getSubModel ( PathAddress . pathAddress ( PathElement . pathElement ( childType , child ) ) ) != null ) { list . add ( child ) ; } } result . put ( childType , new LinkedHashSet <> ( list ) ) ; } } } Set < PathElement > paths = registry . getChildAddresses ( PathAddress . EMPTY_ADDRESS ) ; for ( PathElement path : paths ) { String childType = path . getKey ( ) ; if ( validChildTypeFilter . test ( childType ) ) { Set < String > children = result . get ( childType ) ; if ( children == null ) { // WFLY-3306 Ensure we have an entry for any valid child type children = new LinkedHashSet <> ( ) ; result . put ( childType , children ) ; } ImmutableManagementResourceRegistration childRegistration = registry . getSubModel ( PathAddress . pathAddress ( path ) ) ; if ( childRegistration != null ) { AliasEntry aliasEntry = childRegistration . getAliasEntry ( ) ; if ( aliasEntry != null ) { PathAddress childAddr = addr . append ( path ) ; PathAddress target = aliasEntry . convertToTargetAddress ( childAddr , AliasContext . create ( childAddr , context ) ) ; assert ! childAddr . equals ( target ) : "Alias was not translated" ; PathAddress targetParent = target . getParent ( ) ; Resource parentResource = context . readResourceFromRoot ( targetParent , false ) ; if ( parentResource != null ) { PathElement targetElement = target . getLastElement ( ) ; if ( targetElement . isWildcard ( ) ) { children . addAll ( parentResource . getChildrenNames ( targetElement . getKey ( ) ) ) ; } else if ( parentResource . hasChild ( targetElement ) ) { children . add ( path . getValue ( ) ) ; } } } if ( ! path . isWildcard ( ) && childRegistration . isRemote ( ) ) { children . add ( path . getValue ( ) ) ; } } } } return result ; }
Gets the addresses of the child resources under the given resource .
620
13
145,819
public DiscreteInterval plus ( DiscreteInterval other ) { return new DiscreteInterval ( this . min + other . min , this . max + other . max ) ; }
Returns an interval representing the addition of the given interval with this one .
39
14
145,820
public DiscreteInterval minus ( DiscreteInterval other ) { return new DiscreteInterval ( this . min - other . max , this . max - other . min ) ; }
Returns an interval representing the subtraction of the given interval from this one .
39
15
145,821
public Set < Method > findAnnotatedMethods ( String scanBase , Class < ? extends Annotation > annotationClass ) { Set < BeanDefinition > filteredComponents = findCandidateBeans ( scanBase , annotationClass ) ; return extractAnnotatedMethods ( filteredComponents , annotationClass ) ; }
Find all methods on classes under scanBase that are annotated with annotationClass .
64
16
145,822
public void reset ( ) { state = BreakerState . CLOSED ; isHardTrip = false ; byPass = false ; isAttemptLive = false ; notifyBreakerStateChange ( getStatus ( ) ) ; }
Manually set the breaker to be reset and ready for use . This is only useful after a manual trip otherwise the breaker will trip automatically again if the service is still unavailable . Just like a real breaker . WOOT!!!
45
45
145,823
public WebMBeanAdapter createWebMBeanAdapter ( String mBeanName , String encoding ) throws JMException , UnsupportedEncodingException { return new WebMBeanAdapter ( mBeanServer , mBeanName , encoding ) ; }
Create a WebMBeanAdaptor for a specified MBean name .
54
16
145,824
public void mark ( ) { final long currentTimeMillis = clock . currentTimeMillis ( ) ; synchronized ( queue ) { if ( queue . size ( ) == capacity ) { /* * we're all filled up already, let's dequeue the oldest * timestamp to make room for this new one. */ queue . removeFirst ( ) ; } queue . addLast ( currentTimeMillis ) ; } }
Record a new event .
85
5
145,825
public int tally ( ) { long currentTimeMillis = clock . currentTimeMillis ( ) ; // calculates time for which we remove any errors before final long removeTimesBeforeMillis = currentTimeMillis - windowMillis ; synchronized ( queue ) { // drain out any expired timestamps but don't drain past empty while ( ! queue . isEmpty ( ) && queue . peek ( ) < removeTimesBeforeMillis ) { queue . removeFirst ( ) ; } return queue . size ( ) ; } }
Returns a count of in - window events .
107
9
145,826
public void setCapacity ( int capacity ) { if ( capacity <= 0 ) { throw new IllegalArgumentException ( "capacity must be greater than 0" ) ; } synchronized ( queue ) { // If the capacity was reduced, we remove oldest elements until the // queue fits inside the specified capacity if ( capacity < this . capacity ) { while ( queue . size ( ) > capacity ) { queue . removeFirst ( ) ; } } } this . capacity = capacity ; }
Specifies the maximum capacity of the counter .
97
9
145,827
@ Around ( "@annotation(retryableAnnotation)" ) public Object call ( final ProceedingJoinPoint pjp , Retryable retryableAnnotation ) throws Throwable { final int maxTries = retryableAnnotation . maxTries ( ) ; final int retryDelayMillies = retryableAnnotation . retryDelayMillis ( ) ; final Class < ? extends Throwable > [ ] retryOn = retryableAnnotation . retryOn ( ) ; final boolean doubleDelay = retryableAnnotation . doubleDelay ( ) ; final boolean throwCauseException = retryableAnnotation . throwCauseException ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Have @Retryable method wrapping call on method {} of target object {}" , new Object [ ] { pjp . getSignature ( ) . getName ( ) , pjp . getTarget ( ) } ) ; } ServiceRetrier serviceRetrier = new ServiceRetrier ( retryDelayMillies , maxTries , doubleDelay , throwCauseException , retryOn ) ; return serviceRetrier . invoke ( new Callable < Object > ( ) { public Object call ( ) throws Exception { try { return pjp . proceed ( ) ; } catch ( Exception e ) { throw e ; } catch ( Error e ) { throw e ; } catch ( Throwable t ) { throw new RuntimeException ( t ) ; } } } ) ; }
Runs a method call with retries .
318
9
145,828
public Map < String , MBeanAttributeInfo > getAttributeMetadata ( ) { MBeanAttributeInfo [ ] attributeList = mBeanInfo . getAttributes ( ) ; Map < String , MBeanAttributeInfo > attributeMap = new TreeMap < String , MBeanAttributeInfo > ( ) ; for ( MBeanAttributeInfo attribute : attributeList ) { attributeMap . put ( attribute . getName ( ) , attribute ) ; } return attributeMap ; }
Get the Attribute metadata for an MBean by name .
100
13
145,829
public Map < String , MBeanOperationInfo > getOperationMetadata ( ) { MBeanOperationInfo [ ] operations = mBeanInfo . getOperations ( ) ; Map < String , MBeanOperationInfo > operationMap = new TreeMap < String , MBeanOperationInfo > ( ) ; for ( MBeanOperationInfo operation : operations ) { operationMap . put ( operation . getName ( ) , operation ) ; } return operationMap ; }
Get the Operation metadata for an MBean by name .
99
12
145,830
public MBeanOperationInfo getOperationInfo ( String operationName ) throws OperationNotFoundException , UnsupportedEncodingException { String decodedOperationName = sanitizer . urlDecode ( operationName , encoding ) ; Map < String , MBeanOperationInfo > operationMap = getOperationMetadata ( ) ; if ( operationMap . containsKey ( decodedOperationName ) ) { return operationMap . get ( decodedOperationName ) ; } throw new OperationNotFoundException ( "Could not find operation " + operationName + " on MBean " + objectName . getCanonicalName ( ) ) ; }
Get the Operation metadata for a single operation on an MBean by name .
131
16
145,831
public Map < String , Object > getAttributeValues ( ) throws AttributeNotFoundException , InstanceNotFoundException , ReflectionException { HashSet < String > attributeSet = new HashSet < String > ( ) ; for ( MBeanAttributeInfo attributeInfo : mBeanInfo . getAttributes ( ) ) { attributeSet . add ( attributeInfo . getName ( ) ) ; } AttributeList attributeList = mBeanServer . getAttributes ( objectName , attributeSet . toArray ( new String [ attributeSet . size ( ) ] ) ) ; Map < String , Object > attributeValueMap = new TreeMap < String , Object > ( ) ; for ( Attribute attribute : attributeList . asList ( ) ) { attributeValueMap . put ( attribute . getName ( ) , sanitizer . escapeValue ( attribute . getValue ( ) ) ) ; } return attributeValueMap ; }
Get all the attribute values for an MBean by name . The values are HTML escaped .
190
19
145,832
public String getAttributeValue ( String attributeName ) throws JMException , UnsupportedEncodingException { String decodedAttributeName = sanitizer . urlDecode ( attributeName , encoding ) ; return sanitizer . escapeValue ( mBeanServer . getAttribute ( objectName , decodedAttributeName ) ) ; }
Get the value for a single attribute on an MBean by name .
67
15
145,833
public String invokeOperation ( String operationName , Map < String , String [ ] > parameterMap ) throws JMException , UnsupportedEncodingException { MBeanOperationInfo operationInfo = getOperationInfo ( operationName ) ; MBeanOperationInvoker invoker = createMBeanOperationInvoker ( mBeanServer , objectName , operationInfo ) ; return sanitizer . escapeValue ( invoker . invokeOperation ( parameterMap ) ) ; }
Invoke an operation on an MBean by name . Note that only basic data types are supported for parameter values .
95
24
145,834
String urlDecode ( String name , String encoding ) throws UnsupportedEncodingException { return URLDecoder . decode ( name , encoding ) ; }
Convert a URL Encoded name back to the original form .
31
13
145,835
String escapeValue ( Object value ) { return HtmlUtils . htmlEscape ( value != null ? value . toString ( ) : "<null>" ) ; }
Escape a value to be HTML friendly .
35
9
145,836
private void registerProxyCreator ( Node source , BeanDefinitionHolder holder , ParserContext context ) { String beanName = holder . getBeanName ( ) ; String proxyName = beanName + "Proxy" ; String interceptorName = beanName + "PerformanceMonitorInterceptor" ; BeanDefinitionBuilder initializer = BeanDefinitionBuilder . rootBeanDefinition ( BeanNameAutoProxyCreator . class ) ; initializer . addPropertyValue ( "beanNames" , beanName ) ; initializer . addPropertyValue ( "interceptorNames" , interceptorName ) ; BeanDefinitionRegistry registry = context . getRegistry ( ) ; registry . registerBeanDefinition ( proxyName , initializer . getBeanDefinition ( ) ) ; }
Registers a BeanNameAutoProxyCreator class that wraps the bean being monitored . The proxy is associated with the PerformanceMonitorInterceptor for the bean which is created when parsing the methods attribute from the springconfiguration xml file .
156
46
145,837
private Integer getIntegerPropertyOverrideValue ( String name , String key ) { if ( properties != null ) { String propertyName = getPropertyName ( name , key ) ; String propertyOverrideValue = properties . getProperty ( propertyName ) ; if ( propertyOverrideValue != null ) { try { return Integer . parseInt ( propertyOverrideValue ) ; } catch ( NumberFormatException e ) { logger . error ( "Could not parse property override key={}, value={}" , key , propertyOverrideValue ) ; } } } return null ; }
Get an integer property override value .
111
7
145,838
private boolean shouldWrapMethodCall ( String methodName ) { if ( methodList == null ) { return true ; // Wrap all by default } if ( methodList . contains ( methodName ) ) { return true ; //Wrap a specific method } // If I get to this point, I should not wrap the call. return false ; }
Checks if the method being invoked should be wrapped by a service . It looks the method name up in the methodList . If its in the list then the method should be wrapped . If the list is null then all methods are wrapped .
71
48
145,839
public Object invokeOperation ( Map < String , String [ ] > parameterMap ) throws JMException { MBeanParameterInfo [ ] parameterInfoArray = operationInfo . getSignature ( ) ; Object [ ] values = new Object [ parameterInfoArray . length ] ; String [ ] types = new String [ parameterInfoArray . length ] ; MBeanValueConverter valueConverter = createMBeanValueConverter ( parameterMap ) ; for ( int parameterNum = 0 ; parameterNum < parameterInfoArray . length ; parameterNum ++ ) { MBeanParameterInfo parameterInfo = parameterInfoArray [ parameterNum ] ; String type = parameterInfo . getType ( ) ; types [ parameterNum ] = type ; values [ parameterNum ] = valueConverter . convertParameterValue ( parameterInfo . getName ( ) , type ) ; } return mBeanServer . invoke ( objectName , operationInfo . getName ( ) , values , types ) ; }
Invoke the operation .
204
5
145,840
private void registerInterceptor ( Node source , String beanName , BeanDefinitionRegistry registry ) { List < String > methodList = buildMethodList ( source ) ; BeanDefinitionBuilder initializer = BeanDefinitionBuilder . rootBeanDefinition ( SingleServiceWrapperInterceptor . class ) ; initializer . addPropertyValue ( "methods" , methodList ) ; String perfMonitorName = beanName + "PerformanceMonitor" ; initializer . addPropertyReference ( "serviceWrapper" , perfMonitorName ) ; String interceptorName = beanName + "PerformanceMonitorInterceptor" ; registry . registerBeanDefinition ( interceptorName , initializer . getBeanDefinition ( ) ) ; }
Register a new SingleServiceWrapperInterceptor for the bean being wrapped associate it with the PerformanceMonitor and tell it which methods to intercept .
144
28
145,841
public List < String > parseMethodList ( String methods ) { String [ ] methodArray = StringUtils . delimitedListToStringArray ( methods , "," ) ; List < String > methodList = new ArrayList < String > ( ) ; for ( String methodName : methodArray ) { methodList . add ( methodName . trim ( ) ) ; } return methodList ; }
Parse a comma - delimited list of method names into a List of strings . Whitespace is ignored .
81
22
145,842
private void registerPerformanceMonitor ( String beanName , BeanDefinitionRegistry registry ) { String perfMonitorName = beanName + "PerformanceMonitor" ; if ( ! registry . containsBeanDefinition ( perfMonitorName ) ) { BeanDefinitionBuilder initializer = BeanDefinitionBuilder . rootBeanDefinition ( PerformanceMonitorBean . class ) ; registry . registerBeanDefinition ( perfMonitorName , initializer . getBeanDefinition ( ) ) ; } }
Register a new PerformanceMonitor with Spring if it does not already exist .
93
14
145,843
public static void forceDelete ( final Path path ) throws IOException { if ( ! java . nio . file . Files . isDirectory ( path ) ) { java . nio . file . Files . delete ( path ) ; } else { java . nio . file . Files . walkFileTree ( path , DeleteDirVisitor . getInstance ( ) ) ; } }
Deletes a path from the filesystem
78
7
145,844
public PreparedStatementCreator count ( final Dialect dialect ) { return new PreparedStatementCreator ( ) { public PreparedStatement createPreparedStatement ( Connection con ) throws SQLException { return getPreparedStatementCreator ( ) . setSql ( dialect . createCountSelect ( builder . toString ( ) ) ) . createPreparedStatement ( con ) ; } } ; }
Returns a PreparedStatementCreator that returns a count of the rows that this creator would return .
83
20
145,845
public PreparedStatementCreator page ( final Dialect dialect , final int limit , final int offset ) { return new PreparedStatementCreator ( ) { public PreparedStatement createPreparedStatement ( Connection con ) throws SQLException { return getPreparedStatementCreator ( ) . setSql ( dialect . createPageSelect ( builder . toString ( ) , limit , offset ) ) . createPreparedStatement ( con ) ; } } ; }
Returns a PreparedStatementCreator that returns a page of the underlying result set .
95
17
145,846
private static String toColumnName ( String fieldName ) { int lastDot = fieldName . indexOf ( ' ' ) ; if ( lastDot > - 1 ) { return fieldName . substring ( lastDot + 1 ) ; } else { return fieldName ; } }
Returns the portion of the field name after the last dot as field names may actually be paths .
60
19
145,847
public static Predicate anyBitsSet ( final String expr , final long bits ) { return new Predicate ( ) { private String param ; public void init ( AbstractSqlCreator creator ) { param = creator . allocateParameter ( ) ; creator . setParameter ( param , bits ) ; } public String toSql ( ) { return String . format ( "(%s & :%s) > 0" , expr , param ) ; } } ; }
Adds a clause that checks whether ANY set bits in a bitmask are present in a numeric expression .
95
20
145,848
public static Predicate is ( final String sql ) { return new Predicate ( ) { public String toSql ( ) { return sql ; } public void init ( AbstractSqlCreator creator ) { } } ; }
Returns a predicate that takes no parameters . The given SQL expression is used directly .
46
16
145,849
private static Predicate join ( final String joinWord , final List < Predicate > preds ) { return new Predicate ( ) { public void init ( AbstractSqlCreator creator ) { for ( Predicate p : preds ) { p . init ( creator ) ; } } public String toSql ( ) { StringBuilder sb = new StringBuilder ( ) . append ( "(" ) ; boolean first = true ; for ( Predicate p : preds ) { if ( ! first ) { sb . append ( " " ) . append ( joinWord ) . append ( " " ) ; } sb . append ( p . toSql ( ) ) ; first = false ; } return sb . append ( ")" ) . toString ( ) ; } } ; }
Factory for and and or predicates .
165
8
145,850
public Mapping < T > addFields ( ) { if ( idColumn == null ) { throw new RuntimeException ( "Map ID column before adding class fields" ) ; } for ( Field f : ReflectionUtils . getDeclaredFieldsInHierarchy ( clazz ) ) { if ( ! Modifier . isStatic ( f . getModifiers ( ) ) && ! isFieldMapped ( f . getName ( ) ) && ! ignoredFields . contains ( f . getName ( ) ) ) { addColumn ( f . getName ( ) ) ; } } return this ; }
Adds mappings for each declared field in the mapped class . Any fields already mapped by addColumn are skipped .
127
22
145,851
protected T createInstance ( ) { try { Constructor < T > ctor = clazz . getDeclaredConstructor ( ) ; ctor . setAccessible ( true ) ; return ctor . newInstance ( ) ; } catch ( InstantiationException e ) { throw new RuntimeException ( e ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } catch ( SecurityException e ) { throw new RuntimeException ( e ) ; } catch ( NoSuchMethodException e ) { throw new RuntimeException ( e ) ; } catch ( IllegalArgumentException e ) { throw new RuntimeException ( e ) ; } catch ( InvocationTargetException e ) { throw new RuntimeException ( e ) ; } }
Creates instance of the entity class . This method is called to create the object instances when returning query results .
153
22
145,852
public void deleteById ( Object id ) { int count = beginDelete ( ) . whereEquals ( idColumn . getColumnName ( ) , id ) . delete ( ) ; if ( count == 0 ) { throw new RowNotFoundException ( table , id ) ; } }
Deletes an entity by its primary key .
58
9
145,853
public T findById ( Object id ) throws RowNotFoundException , TooManyRowsException { return findWhere ( eq ( idColumn . getColumnName ( ) , id ) ) . getSingleResult ( ) ; }
Finds an entity given its primary key .
46
9
145,854
public T insert ( T entity ) { if ( ! hasPrimaryKey ( entity ) ) { throw new RuntimeException ( String . format ( "Tried to insert entity of type %s with null or zero primary key" , entity . getClass ( ) . getSimpleName ( ) ) ) ; } InsertCreator insert = new InsertCreator ( table ) ; insert . setValue ( idColumn . getColumnName ( ) , getPrimaryKey ( entity ) ) ; if ( versionColumn != null ) { insert . setValue ( versionColumn . getColumnName ( ) , 0 ) ; } for ( Column column : columns ) { if ( ! column . isReadOnly ( ) ) { insert . setValue ( column . getColumnName ( ) , getFieldValueAsColumn ( entity , column ) ) ; } } new JdbcTemplate ( ormConfig . getDataSource ( ) ) . update ( insert ) ; if ( versionColumn != null ) { ReflectionUtils . setFieldValue ( entity , versionColumn . getFieldName ( ) , 0 ) ; } return entity ; }
Insert entity object . The caller must first initialize the primary key field .
228
14
145,855
private boolean hasPrimaryKey ( T entity ) { Object pk = getPrimaryKey ( entity ) ; if ( pk == null ) { return false ; } else { if ( pk instanceof Number && ( ( Number ) pk ) . longValue ( ) == 0 ) { return false ; } } return true ; }
Returns true if this entity s primary key is not null and for numeric fields is non - zero .
68
20
145,856
public T update ( T entity ) throws RowNotFoundException , OptimisticLockException { if ( ! hasPrimaryKey ( entity ) ) { throw new RuntimeException ( String . format ( "Tried to update entity of type %s without a primary key" , entity . getClass ( ) . getSimpleName ( ) ) ) ; } UpdateCreator update = new UpdateCreator ( table ) ; update . whereEquals ( idColumn . getColumnName ( ) , getPrimaryKey ( entity ) ) ; if ( versionColumn != null ) { update . set ( versionColumn . getColumnName ( ) + " = " + versionColumn . getColumnName ( ) + " + 1" ) ; update . whereEquals ( versionColumn . getColumnName ( ) , getVersion ( entity ) ) ; } for ( Column column : columns ) { if ( ! column . isReadOnly ( ) ) { update . setValue ( column . getColumnName ( ) , getFieldValueAsColumn ( entity , column ) ) ; } } int rows = new JdbcTemplate ( ormConfig . getDataSource ( ) ) . update ( update ) ; if ( rows == 1 ) { if ( versionColumn != null ) { ReflectionUtils . setFieldValue ( entity , versionColumn . getFieldName ( ) , getVersion ( entity ) + 1 ) ; } return entity ; } else if ( rows > 1 ) { throw new RuntimeException ( String . format ( "Updating table %s with id %s updated %d rows. There must be a mapping problem. Is column %s really the primary key?" , table , getPrimaryKey ( entity ) , rows , idColumn ) ) ; } else { // // Updated zero rows. This could be because our ID is wrong, or // because our object is out-of date. Let's try querying just by ID. // SelectCreator selectById = new SelectCreator ( ) . column ( "count(*)" ) . from ( table ) . whereEquals ( idColumn . getColumnName ( ) , getPrimaryKey ( entity ) ) ; rows = new JdbcTemplate ( ormConfig . getDataSource ( ) ) . query ( selectById , new ResultSetExtractor < Integer > ( ) { @ Override public Integer extractData ( ResultSet rs ) throws SQLException , DataAccessException { rs . next ( ) ; return rs . getInt ( 1 ) ; } } ) ; if ( rows == 0 ) { throw new RowNotFoundException ( table , getPrimaryKey ( entity ) ) ; } else { throw new OptimisticLockException ( table , getPrimaryKey ( entity ) ) ; } } }
Updates value of entity in the table .
564
9
145,857
public AbstractSqlCreator setParameter ( String name , Object value ) { ppsc . setParameter ( name , value ) ; return this ; }
Sets a parameter for the creator .
31
8
145,858
public InsertBuilder set ( String column , String value ) { columns . add ( column ) ; values . add ( value ) ; return this ; }
Inserts a column name value pair into the SQL .
30
11
145,859
public SelectBuilder orderBy ( String name , boolean ascending ) { if ( ascending ) { orderBys . add ( name + " asc" ) ; } else { orderBys . add ( name + " desc" ) ; } return this ; }
Adds an ORDER BY item with a direction indicator .
52
10
145,860
public List < String > split ( String s ) { List < String > result = new ArrayList < String > ( ) ; if ( s == null ) { return result ; } boolean seenEscape = false ; // Used to detect if the last char was a separator, // in which case we append an empty string boolean seenSeparator = false ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { seenSeparator = false ; char c = s . charAt ( i ) ; if ( seenEscape ) { if ( c == escapeChar || c == separator ) { sb . append ( c ) ; } else { sb . append ( escapeChar ) . append ( c ) ; } seenEscape = false ; } else { if ( c == escapeChar ) { seenEscape = true ; } else if ( c == separator ) { if ( sb . length ( ) == 0 && convertEmptyToNull ) { result . add ( null ) ; } else { result . add ( sb . toString ( ) ) ; } sb . setLength ( 0 ) ; seenSeparator = true ; } else { sb . append ( c ) ; } } } // Clean up if ( seenEscape ) { sb . append ( escapeChar ) ; } if ( sb . length ( ) > 0 || seenSeparator ) { if ( sb . length ( ) == 0 && convertEmptyToNull ) { result . add ( null ) ; } else { result . add ( sb . toString ( ) ) ; } } return result ; }
Splits the given string .
355
6
145,861
public String join ( List < String > list ) { if ( list == null ) { return null ; } StringBuilder sb = new StringBuilder ( ) ; boolean first = true ; for ( String s : list ) { if ( s == null ) { if ( convertEmptyToNull ) { s = "" ; } else { throw new IllegalArgumentException ( "StringListFlattener does not support null strings in the list. Consider calling setConvertEmptyToNull(true)." ) ; } } if ( ! first ) { sb . append ( separator ) ; } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c == escapeChar || c == separator ) { sb . append ( escapeChar ) ; } sb . append ( c ) ; } first = false ; } return sb . toString ( ) ; }
Joins the given list into a single string .
198
10
145,862
protected void appendList ( StringBuilder sql , List < ? > list , String init , String sep ) { boolean first = true ; for ( Object s : list ) { if ( first ) { sql . append ( init ) ; } else { sql . append ( sep ) ; } sql . append ( s ) ; first = false ; } }
Constructs a list of items with given separators .
71
11
145,863
public static < E extends Enum < E > > EnumStringConverter < E > create ( Class < E > enumType ) { return new EnumStringConverter < E > ( enumType ) ; }
Factory method to create EnumStringConverter
47
10
145,864
public static Field [ ] getDeclaredFieldsInHierarchy ( Class < ? > clazz ) { if ( clazz . isPrimitive ( ) ) { throw new IllegalArgumentException ( "Primitive types not supported." ) ; } List < Field > result = new ArrayList < Field > ( ) ; while ( true ) { if ( clazz == Object . class ) { break ; } result . addAll ( Arrays . asList ( clazz . getDeclaredFields ( ) ) ) ; clazz = clazz . getSuperclass ( ) ; } return result . toArray ( new Field [ result . size ( ) ] ) ; }
Returns an array of all declared fields in the given class and all super - classes .
140
17
145,865
public static Field getDeclaredFieldWithPath ( Class < ? > clazz , String path ) { int lastDot = path . lastIndexOf ( ' ' ) ; if ( lastDot > - 1 ) { String parentPath = path . substring ( 0 , lastDot ) ; String fieldName = path . substring ( lastDot + 1 ) ; Field parentField = getDeclaredFieldWithPath ( clazz , parentPath ) ; return getDeclaredFieldInHierarchy ( parentField . getType ( ) , fieldName ) ; } else { return getDeclaredFieldInHierarchy ( clazz , path ) ; } }
Returns the Field for a given parent class and a dot - separated path of field names .
139
18
145,866
public static Object getFieldValue ( Object object , String fieldName ) { try { return getDeclaredFieldInHierarchy ( object . getClass ( ) , fieldName ) . get ( object ) ; } catch ( IllegalArgumentException e ) { throw new RuntimeException ( e ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } }
Convenience method for getting the value of a private object field without the stress of checked exceptions in the reflection API .
80
24
145,867
public static void setFieldValue ( Object object , String fieldName , Object value ) { try { getDeclaredFieldInHierarchy ( object . getClass ( ) , fieldName ) . set ( object , value ) ; } catch ( IllegalArgumentException e ) { throw new RuntimeException ( e ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } }
Convenience method for setting the value of a private object field without the stress of checked exceptions in the reflection API .
84
24
145,868
private static void checkPreconditions ( final long min , final long max ) { if ( max < min ) { throw new IllegalArgumentException ( String . format ( "max (%d) should not be < min (%d)" , max , min ) ) ; } }
Checks the preconditions for creating a new LMinMax processor .
57
15
145,869
public static Method findGetter ( final Object object , final String fieldName ) { if ( object == null ) { throw new NullPointerException ( "object should not be null" ) ; } else if ( fieldName == null ) { throw new NullPointerException ( "fieldName should not be null" ) ; } final Class < ? > clazz = object . getClass ( ) ; // find a standard getter final String standardGetterName = getMethodNameForField ( GET_PREFIX , fieldName ) ; Method getter = findGetterWithCompatibleReturnType ( standardGetterName , clazz , false ) ; // if that fails, try for an isX() style boolean getter if ( getter == null ) { final String booleanGetterName = getMethodNameForField ( IS_PREFIX , fieldName ) ; getter = findGetterWithCompatibleReturnType ( booleanGetterName , clazz , true ) ; } if ( getter == null ) { throw new SuperCsvReflectionException ( String . format ( "unable to find getter for field %s in class %s - check that the corresponding nameMapping element matches the field name in the bean" , fieldName , clazz . getName ( ) ) ) ; } return getter ; }
Returns the getter method associated with the object s field .
279
12
145,870
public static < T > void filterListToMap ( final Map < String , T > destinationMap , final String [ ] nameMapping , final List < ? extends T > sourceList ) { if ( destinationMap == null ) { throw new NullPointerException ( "destinationMap should not be null" ) ; } else if ( nameMapping == null ) { throw new NullPointerException ( "nameMapping should not be null" ) ; } else if ( sourceList == null ) { throw new NullPointerException ( "sourceList should not be null" ) ; } else if ( nameMapping . length != sourceList . size ( ) ) { throw new SuperCsvException ( String . format ( "the nameMapping array and the sourceList should be the same size (nameMapping length = %d, sourceList size = %d)" , nameMapping . length , sourceList . size ( ) ) ) ; } destinationMap . clear ( ) ; for ( int i = 0 ; i < nameMapping . length ; i ++ ) { final String key = nameMapping [ i ] ; if ( key == null ) { continue ; // null's in the name mapping means skip column } // no duplicates allowed if ( destinationMap . containsKey ( key ) ) { throw new SuperCsvException ( String . format ( "duplicate nameMapping '%s' at index %d" , key , i ) ) ; } destinationMap . put ( key , sourceList . get ( i ) ) ; } }
Converts a List to a Map using the elements of the nameMapping array as the keys of the Map .
326
23
145,871
public static List < Object > filterMapToList ( final Map < String , ? > map , final String [ ] nameMapping ) { if ( map == null ) { throw new NullPointerException ( "map should not be null" ) ; } else if ( nameMapping == null ) { throw new NullPointerException ( "nameMapping should not be null" ) ; } final List < Object > result = new ArrayList < Object > ( nameMapping . length ) ; for ( final String key : nameMapping ) { result . add ( map . get ( key ) ) ; } return result ; }
Returns a List of all of the values in the Map whose key matches an entry in the nameMapping array .
131
23
145,872
public static Object [ ] filterMapToObjectArray ( final Map < String , ? > values , final String [ ] nameMapping ) { if ( values == null ) { throw new NullPointerException ( "values should not be null" ) ; } else if ( nameMapping == null ) { throw new NullPointerException ( "nameMapping should not be null" ) ; } final Object [ ] targetArray = new Object [ nameMapping . length ] ; int i = 0 ; for ( final String name : nameMapping ) { targetArray [ i ++ ] = values . get ( name ) ; } return targetArray ; }
Converts a Map to an array of objects adding only those entries whose key is in the nameMapping array .
135
23
145,873
private static void checkPreconditions ( final Set < Object > possibleValues ) { if ( possibleValues == null ) { throw new NullPointerException ( "possibleValues Set should not be null" ) ; } else if ( possibleValues . isEmpty ( ) ) { throw new IllegalArgumentException ( "possibleValues Set should not be empty" ) ; } }
Checks the preconditions for creating a new IsIncludedIn processor with a Set of Objects .
78
21
145,874
private static void checkPreconditions ( final int maxSize , final String suffix ) { if ( maxSize <= 0 ) { throw new IllegalArgumentException ( String . format ( "maxSize should be > 0 but was %d" , maxSize ) ) ; } if ( suffix == null ) { throw new NullPointerException ( "suffix should not be null" ) ; } }
Checks the preconditions for creating a new Truncate processor .
82
15
145,875
protected void writeRow ( final String ... columns ) throws IOException { if ( columns == null ) { throw new NullPointerException ( String . format ( "columns to write should not be null on line %d" , lineNumber ) ) ; } else if ( columns . length == 0 ) { throw new IllegalArgumentException ( String . format ( "columns to write should not be empty on line %d" , lineNumber ) ) ; } StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < columns . length ; i ++ ) { columnNumber = i + 1 ; // column no used by CsvEncoder if ( i > 0 ) { builder . append ( ( char ) preference . getDelimiterChar ( ) ) ; // delimiter } final String csvElement = columns [ i ] ; if ( csvElement != null ) { final CsvContext context = new CsvContext ( lineNumber , rowNumber , columnNumber ) ; final String escapedCsv = encoder . encode ( csvElement , context , preference ) ; builder . append ( escapedCsv ) ; lineNumber = context . getLineNumber ( ) ; // line number can increment when encoding multi-line columns } } builder . append ( preference . getEndOfLineSymbols ( ) ) ; // EOL writer . write ( builder . toString ( ) ) ; }
Writes one or more String columns as a line to the CsvWriter .
294
16
145,876
private static void checkPreconditions ( final Map < Object , Object > mapping ) { if ( mapping == null ) { throw new NullPointerException ( "mapping should not be null" ) ; } else if ( mapping . isEmpty ( ) ) { throw new IllegalArgumentException ( "mapping should not be empty" ) ; } }
Checks the preconditions for creating a new HashMapper processor .
73
15
145,877
private static void checkPreconditions ( final String dateFormat , final Locale locale ) { if ( dateFormat == null ) { throw new NullPointerException ( "dateFormat should not be null" ) ; } else if ( locale == null ) { throw new NullPointerException ( "locale should not be null" ) ; } }
Checks the preconditions for creating a new ParseDateTimeAbstract processor with date format and locale .
72
22
145,878
private static void checkPreconditions ( final String regex , final String replacement ) { if ( regex == null ) { throw new NullPointerException ( "regex should not be null" ) ; } else if ( regex . length ( ) == 0 ) { throw new IllegalArgumentException ( "regex should not be empty" ) ; } if ( replacement == null ) { throw new NullPointerException ( "replacement should not be null" ) ; } }
Checks the preconditions for creating a new StrRegExReplace processor .
98
17
145,879
public V get ( final K1 firstKey , final K2 secondKey ) { // existence check on inner map final HashMap < K2 , V > innerMap = map . get ( firstKey ) ; if ( innerMap == null ) { return null ; } return innerMap . get ( secondKey ) ; }
Fetch a value from the Hashmap .
66
9
145,880
public Method getGetMethod ( final Object object , final String fieldName ) { if ( object == null ) { throw new NullPointerException ( "object should not be null" ) ; } else if ( fieldName == null ) { throw new NullPointerException ( "fieldName should not be null" ) ; } Method method = getCache . get ( object . getClass ( ) . getName ( ) , fieldName ) ; if ( method == null ) { method = ReflectionUtils . findGetter ( object , fieldName ) ; getCache . set ( object . getClass ( ) . getName ( ) , fieldName , method ) ; } return method ; }
Returns the getter method for field on an object .
143
11
145,881
public < T > Method getSetMethod ( final Object object , final String fieldName , final Class < ? > argumentType ) { if ( object == null ) { throw new NullPointerException ( "object should not be null" ) ; } else if ( fieldName == null ) { throw new NullPointerException ( "fieldName should not be null" ) ; } else if ( argumentType == null ) { throw new NullPointerException ( "argumentType should not be null" ) ; } Method method = setMethodsCache . get ( object . getClass ( ) , argumentType , fieldName ) ; if ( method == null ) { method = ReflectionUtils . findSetter ( object , fieldName , argumentType ) ; setMethodsCache . set ( object . getClass ( ) , argumentType , fieldName , method ) ; } return method ; }
Returns the setter method for the field on an object .
182
12
145,882
private static void invokeSetter ( final Object bean , final Method setMethod , final Object fieldValue ) { try { setMethod . setAccessible ( true ) ; setMethod . invoke ( bean , fieldValue ) ; } catch ( final Exception e ) { throw new SuperCsvReflectionException ( String . format ( "error invoking method %s()" , setMethod . getName ( ) ) , e ) ; } }
Invokes the setter on the bean with the supplied value .
89
13
145,883
private < T > T populateBean ( final T resultBean , final String [ ] nameMapping ) { // map each column to its associated field on the bean for ( int i = 0 ; i < nameMapping . length ; i ++ ) { final Object fieldValue = processedColumns . get ( i ) ; // don't call a set-method in the bean if there is no name mapping for the column or no result to store if ( nameMapping [ i ] == null || fieldValue == null ) { continue ; } // invoke the setter on the bean Method setMethod = cache . getSetMethod ( resultBean , nameMapping [ i ] , fieldValue . getClass ( ) ) ; invokeSetter ( resultBean , setMethod , fieldValue ) ; } return resultBean ; }
Populates the bean by mapping the processed columns to the fields of the bean .
173
16
145,884
private < T > T readIntoBean ( final T bean , final String [ ] nameMapping , final CellProcessor [ ] processors ) throws IOException { if ( readRow ( ) ) { if ( nameMapping . length != length ( ) ) { throw new IllegalArgumentException ( String . format ( "the nameMapping array and the number of columns read " + "should be the same size (nameMapping length = %d, columns = %d)" , nameMapping . length , length ( ) ) ) ; } if ( processors == null ) { processedColumns . clear ( ) ; processedColumns . addAll ( getColumns ( ) ) ; } else { executeProcessors ( processedColumns , processors ) ; } return populateBean ( bean , nameMapping ) ; } return null ; // EOF }
Reads a row of a CSV file and populates the bean using the supplied name mapping to map column values to the appropriate fields . If processors are supplied then they are used otherwise the raw String values will be used .
179
44
145,885
private void checkAndAddLengths ( final int ... requiredLengths ) { for ( final int length : requiredLengths ) { if ( length < 0 ) { throw new IllegalArgumentException ( String . format ( "required length cannot be negative but was %d" , length ) ) ; } this . requiredLengths . add ( length ) ; } }
Adds each required length ensuring it isn t negative .
75
10
145,886
private static void checkPreconditions ( List < String > requiredSubStrings ) { if ( requiredSubStrings == null ) { throw new NullPointerException ( "requiredSubStrings List should not be null" ) ; } else if ( requiredSubStrings . isEmpty ( ) ) { throw new IllegalArgumentException ( "requiredSubStrings List should not be empty" ) ; } }
Checks the preconditions for creating a new RequireSubStr processor with a List of Strings .
85
22
145,887
private void checkAndAddRequiredSubStrings ( final List < String > requiredSubStrings ) { for ( String required : requiredSubStrings ) { if ( required == null ) { throw new NullPointerException ( "required substring should not be null" ) ; } this . requiredSubStrings . add ( required ) ; } }
Adds each required substring checking that it s not null .
72
12
145,888
private static void checkPreconditions ( final List < String > forbiddenSubStrings ) { if ( forbiddenSubStrings == null ) { throw new NullPointerException ( "forbiddenSubStrings list should not be null" ) ; } else if ( forbiddenSubStrings . isEmpty ( ) ) { throw new IllegalArgumentException ( "forbiddenSubStrings list should not be empty" ) ; } }
Checks the preconditions for creating a new ForbidSubStr processor with a List of forbidden substrings .
88
23
145,889
private void checkAndAddForbiddenStrings ( final List < String > forbiddenSubStrings ) { for ( String forbidden : forbiddenSubStrings ) { if ( forbidden == null ) { throw new NullPointerException ( "forbidden substring should not be null" ) ; } this . forbiddenSubStrings . add ( forbidden ) ; } }
Adds each forbidden substring checking that it s not null .
73
12
145,890
public HashMap < K2 , HashMap < K3 , V > > get ( final K1 firstKey ) { return map . get ( firstKey ) ; }
Fetch the outermost Hashmap .
35
8
145,891
public TwoDHashMap < K2 , K3 , V > getAs2d ( final K1 firstKey ) { final HashMap < K2 , HashMap < K3 , V > > innerMap1 = map . get ( firstKey ) ; if ( innerMap1 != null ) { return new TwoDHashMap < K2 , K3 , V > ( innerMap1 ) ; } else { return new TwoDHashMap < K2 , K3 , V > ( ) ; } }
Fetch the outermost Hashmap as a TwoDHashMap .
107
14
145,892
public int size ( final K1 firstKey ) { // existence check on inner map final HashMap < K2 , HashMap < K3 , V > > innerMap = map . get ( firstKey ) ; if ( innerMap == null ) { return 0 ; } return innerMap . size ( ) ; }
Returns the number of key - value mappings in this map for the second key .
65
17
145,893
public int size ( final K1 firstKey , final K2 secondKey ) { // existence check on inner map final HashMap < K2 , HashMap < K3 , V > > innerMap1 = map . get ( firstKey ) ; if ( innerMap1 == null ) { return 0 ; } // existence check on inner map1 final HashMap < K3 , V > innerMap2 = innerMap1 . get ( secondKey ) ; if ( innerMap2 == null ) { return 0 ; } return innerMap2 . size ( ) ; }
Returns the number of key - value mappings in this map for the third key .
117
17
145,894
public static < T > T createProxy ( final Class < T > proxyInterface ) { if ( proxyInterface == null ) { throw new NullPointerException ( "proxyInterface should not be null" ) ; } return proxyInterface . cast ( Proxy . newProxyInstance ( proxyInterface . getClassLoader ( ) , new Class [ ] { proxyInterface } , new BeanInterfaceProxy ( ) ) ) ; }
Creates a proxy object which implements a given bean interface .
84
12
145,895
private static String getUnexpectedTypeMessage ( final Class < ? > expectedType , final Object actualValue ) { if ( expectedType == null ) { throw new NullPointerException ( "expectedType should not be null" ) ; } String expectedClassName = expectedType . getName ( ) ; String actualClassName = ( actualValue != null ) ? actualValue . getClass ( ) . getName ( ) : "null" ; return String . format ( "the input value should be of type %s but is %s" , expectedClassName , actualClassName ) ; }
Assembles the exception message when the value received by a CellProcessor isn t of the correct type .
122
22
145,896
protected List < Object > executeProcessors ( final List < Object > processedColumns , final CellProcessor [ ] processors ) { Util . executeCellProcessors ( processedColumns , getColumns ( ) , processors , getLineNumber ( ) , getRowNumber ( ) ) ; return processedColumns ; }
Executes the supplied cell processors on the last row of CSV that was read and populates the supplied List of processed columns .
66
25
145,897
public void stopListenting ( ) { if ( channel != null ) { log . info ( "closing server channel" ) ; channel . close ( ) . syncUninterruptibly ( ) ; channel = null ; } }
Closes the server socket . No new clients are accepted afterwards .
48
13
145,898
Document convertSelectorToDocument ( Document selector ) { Document document = new Document ( ) ; for ( String key : selector . keySet ( ) ) { if ( key . startsWith ( "$" ) ) { continue ; } Object value = selector . get ( key ) ; if ( ! Utils . containsQueryExpression ( value ) ) { Utils . changeSubdocumentValue ( document , key , value , ( AtomicReference < Integer > ) null ) ; } } return document ; }
convert selector used in an upsert statement into a document
102
12
145,899
String decodeCString ( ByteBuf buffer ) throws IOException { int length = buffer . bytesBefore ( BsonConstants . STRING_TERMINATION ) ; if ( length < 0 ) throw new IOException ( "string termination not found" ) ; String result = buffer . toString ( buffer . readerIndex ( ) , length , StandardCharsets . UTF_8 ) ; buffer . skipBytes ( length + 1 ) ; return result ; }
default visibility for unit test
95
5