idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
8,900
int getAttributeProcessing ( ) { if ( attributeProcessing == - 1 ) { attributeProcessing = resolve ( mode ) . getAttributeProcessing ( ) ; if ( modeMap != null ) { for ( Enumeration e = modeMap . values ( ) ; e . hasMoreElements ( ) && attributeProcessing != Mode . ATTRIBUTE_PROCESSING_FULL ; ) attributeProcessing = Math . max ( resolve ( ( Mode ) e . nextElement ( ) ) . getAttributeProcessing ( ) , attributeProcessing ) ; } } return attributeProcessing ; }
Get the maximum attribute processing value from the default mode and from all the modes specified in the contexts .
8,901
public String getMergedJsonFile ( final VFS vfs , final ResourceResolver resolver , final String in ) throws IOException { final VFile file = vfs . find ( "/__temp__json__input" ) ; final List < Resource > resources = getJsonSourceFiles ( resolver . resolve ( in ) ) ; boolean foundJs = false ; boolean foundNonJs = false ; for ( final Resource resource : resources ) { foundJs |= FilenameUtils . isExtension ( resource . getPath ( ) , "js" ) ; foundNonJs |= ! FilenameUtils . isExtension ( resource . getPath ( ) , "js" ) ; } if ( foundJs && foundNonJs ) { for ( int i = 0 , n = resources . size ( ) ; i < n ; i ++ ) { final Resource resource = resources . get ( i ) ; if ( ! FilenameUtils . isExtension ( resource . getPath ( ) , "js" ) ) { final Resource jsResource = resource . getResolver ( ) . resolve ( FilenameUtils . getName ( FilenameUtils . removeExtension ( resource . getPath ( ) ) + ".js" ) ) ; resources . add ( resources . indexOf ( resource ) , jsResource ) ; resources . remove ( resource ) ; } } } VFSUtils . write ( file , merge ( resources ) ) ; return file . getPath ( ) ; }
Returns a merged temporary file with all contents listed in the given json file paths .
8,902
private boolean isUniqueFileResolved ( final Set < String > alreadyHandled , final String s ) { return this . uniqueFiles && alreadyHandled . contains ( s ) ; }
Examines a source file whether it is already resolved when it should be unique .
8,903
public Class < ? > getDomainClass ( Class < ? > toClass ) { Class < ? > declaredClass = getDeclaredDomainClass ( toClass ) ; return classReplacer . replaceClass ( declaredClass ) ; }
Get domain class for transfer object .
8,904
public boolean validate ( InputSource in ) throws SAXException , IOException { if ( schema == null ) throw new IllegalStateException ( "cannot validate without schema" ) ; if ( validator == null ) validator = schema . createValidator ( instanceProperties ) ; if ( xr == null ) { xr = ResolverFactory . createResolver ( instanceProperties ) . createXMLReader ( ) ; xr . setErrorHandler ( eh ) ; } eh . reset ( ) ; xr . setContentHandler ( validator . getContentHandler ( ) ) ; DTDHandler dh = validator . getDTDHandler ( ) ; if ( dh != null ) xr . setDTDHandler ( dh ) ; try { xr . parse ( in ) ; return ! eh . getHadErrorOrFatalError ( ) ; } finally { validator . reset ( ) ; } }
Validates a document against the currently loaded schema . This can be called multiple times in order to validate multiple documents .
8,905
public TypeMirror getOperatorKind ( TypeMirror leftMirror , TypeMirror rightMirror , TokenType . BinaryOperator operator ) { if ( leftMirror == null || rightMirror == null ) return null ; TypeKind leftKind = leftMirror . getKind ( ) ; TypeKind rightKind = rightMirror . getKind ( ) ; if ( isString ( leftMirror ) ) return leftMirror ; if ( isString ( rightMirror ) ) return rightMirror ; if ( either ( leftKind , rightKind , TypeKind . BOOLEAN ) ) { if ( operator != null ) { messageUtils . error ( Option . < Element > absent ( ) , "Cannot perform perform the operation '%s' with a boolean type. (%s %s %s)" , operator . toString ( ) , leftMirror , operator . toString ( ) , rightMirror ) ; } return null ; } if ( leftKind . isPrimitive ( ) && rightKind . isPrimitive ( ) ) { if ( typeUtils . isSameType ( leftMirror , rightMirror ) ) return typeUtils . getPrimitiveType ( leftKind ) ; if ( either ( leftKind , rightKind , TypeKind . DOUBLE ) ) return typeUtils . getPrimitiveType ( TypeKind . DOUBLE ) ; if ( either ( leftKind , rightKind , TypeKind . FLOAT ) ) return typeUtils . getPrimitiveType ( TypeKind . FLOAT ) ; if ( either ( leftKind , rightKind , TypeKind . LONG ) ) return typeUtils . getPrimitiveType ( TypeKind . LONG ) ; if ( either ( leftKind , rightKind , TypeKind . INT ) || either ( leftKind , rightKind , TypeKind . CHAR ) || either ( leftKind , rightKind , TypeKind . SHORT ) || either ( leftKind , rightKind , TypeKind . BYTE ) ) { return typeUtils . getPrimitiveType ( TypeKind . INT ) ; } } TypeMirror intMirror = typeUtils . getPrimitiveType ( TypeKind . INT ) ; if ( both ( assignable ( intMirror , leftMirror ) , assignable ( intMirror , rightMirror ) ) ) return intMirror ; TypeMirror longMirror = typeUtils . getPrimitiveType ( TypeKind . LONG ) ; if ( both ( assignable ( longMirror , leftMirror ) , assignable ( longMirror , rightMirror ) ) ) return longMirror ; TypeMirror floatMirror = typeUtils . getPrimitiveType ( TypeKind . FLOAT ) ; if ( both ( assignable ( floatMirror , leftMirror ) , assignable ( floatMirror , rightMirror ) ) ) return floatMirror ; TypeMirror doubleMirror = typeUtils . getPrimitiveType ( TypeKind . DOUBLE ) ; if ( both ( assignable ( doubleMirror , leftMirror ) , assignable ( doubleMirror , rightMirror ) ) ) return doubleMirror ; return null ; }
rules for this method are found here
8,906
void perform ( ContentHandler handler , SectionState state ) { final ModeUsage modeUsage = getModeUsage ( ) ; if ( handler != null ) state . addActiveHandler ( handler , modeUsage ) ; else state . addAttributeValidationModeUsage ( modeUsage ) ; state . addChildMode ( modeUsage , handler ) ; }
Performs this action on the section state .
8,907
public Token getNextToken ( ) { Token specialToken = null ; Token matchedToken ; int curPos = 0 ; EOFLoop : for ( ; ; ) { try { curChar = input_stream . BeginToken ( ) ; } catch ( EOFException e ) { jjmatchedKind = 0 ; matchedToken = jjFillToken ( ) ; matchedToken . specialToken = specialToken ; return matchedToken ; } image = jjimage ; image . setLength ( 0 ) ; jjimageLen = 0 ; switch ( curLexState ) { case 0 : jjmatchedKind = 0x7fffffff ; jjmatchedPos = 0 ; curPos = jjMoveStringLiteralDfa0_0 ( ) ; break ; case 1 : jjmatchedKind = 0x7fffffff ; jjmatchedPos = 0 ; curPos = jjMoveStringLiteralDfa0_1 ( ) ; break ; case 2 : jjmatchedKind = 0x7fffffff ; jjmatchedPos = 0 ; curPos = jjMoveStringLiteralDfa0_2 ( ) ; break ; } if ( jjmatchedKind != 0x7fffffff ) { if ( jjmatchedPos + 1 < curPos ) input_stream . backup ( curPos - jjmatchedPos - 1 ) ; if ( ( jjtoToken [ jjmatchedKind >> 6 ] & ( 1L << ( jjmatchedKind & 077 ) ) ) != 0L ) { matchedToken = jjFillToken ( ) ; matchedToken . specialToken = specialToken ; if ( jjnewLexState [ jjmatchedKind ] != - 1 ) curLexState = jjnewLexState [ jjmatchedKind ] ; return matchedToken ; } else { if ( ( jjtoSpecial [ jjmatchedKind >> 6 ] & ( 1L << ( jjmatchedKind & 077 ) ) ) != 0L ) { matchedToken = jjFillToken ( ) ; if ( specialToken == null ) specialToken = matchedToken ; else { matchedToken . specialToken = specialToken ; specialToken = ( specialToken . next = matchedToken ) ; } SkipLexicalActions ( matchedToken ) ; } else SkipLexicalActions ( null ) ; if ( jjnewLexState [ jjmatchedKind ] != - 1 ) curLexState = jjnewLexState [ jjmatchedKind ] ; continue EOFLoop ; } } int error_line = input_stream . getEndLine ( ) ; int error_column = input_stream . getEndColumn ( ) ; String error_after = null ; boolean EOFSeen = false ; try { input_stream . readChar ( ) ; input_stream . backup ( 1 ) ; } catch ( EOFException e1 ) { EOFSeen = true ; error_after = curPos <= 1 ? "" : input_stream . GetImage ( ) ; if ( curChar == '\n' || curChar == '\r' ) { error_line ++ ; error_column = 0 ; } else error_column ++ ; } if ( ! EOFSeen ) { input_stream . backup ( 1 ) ; error_after = curPos <= 1 ? "" : input_stream . GetImage ( ) ; } throw new TokenMgrError ( EOFSeen , curLexState , error_line , error_column , error_after , curChar , TokenMgrError . LEXICAL_ERROR ) ; } }
Get the next Token .
8,908
public String filter ( String value , String previousValue ) { if ( previousValue != null && value . length ( ) > previousValue . length ( ) ) return value ; return value . equals ( "0" ) || value . equals ( "0.0" ) ? "" : value ; }
The default filter removes the display of 0 or 0 . 0 if the user has erased the text . This is to prevent a number being shown when the user tries to erase it .
8,909
public String ipToString ( long ip ) { if ( ip > 4294967295l || ip < 0 ) { throw new IllegalArgumentException ( "invalid ip" ) ; } val ipAddress = new StringBuilder ( ) ; for ( int i = 3 ; i >= 0 ; i -- ) { int shift = i * 8 ; ipAddress . append ( ( ip & ( 0xff << shift ) ) >> shift ) ; if ( i > 0 ) { ipAddress . append ( "." ) ; } } return ipAddress . toString ( ) ; }
Returns the 32bit dotted format of the provided long ip .
8,910
void outputComplementDirect ( StringBuffer buf ) { if ( ! surrogatesDirect && getContainsBmp ( ) == NONE ) buf . append ( "[\u0000-\uFFFF]" ) ; else { buf . append ( "[^" ) ; inClassOutputDirect ( buf ) ; buf . append ( ']' ) ; } }
must not call if containsBmp == ALL && !surrogatesDirect
8,911
public Object doConvertOne ( JTransfo jTransfo , Object toObject , Class < ? > domainObjectType , String ... tags ) throws JTransfoException { return jTransfo . convertTo ( toObject , domainObjectType , tags ) ; }
Do the actual conversion of one object .
8,912
public static URIResolver createSAXURIResolver ( Resolver resolver ) { final SAXResolver saxResolver = new SAXResolver ( resolver ) ; return new URIResolver ( ) { public Source resolve ( String href , String base ) throws TransformerException { try { return saxResolver . resolve ( href , base ) ; } catch ( SAXException e ) { throw toTransformerException ( e ) ; } catch ( IOException e ) { throw new TransformerException ( e ) ; } } } ; }
Creates a URIResolver that returns a SAXSource .
8,913
public void addConverters ( Converter converter , String ... tags ) { for ( String tag : tags ) { if ( tag . startsWith ( "!" ) ) { notConverters . put ( tag . substring ( 1 ) , converter ) ; } else { converters . put ( tag , converter ) ; } } }
Add the converter which should be used for a specific tag .
8,914
public void checkValid ( CharSequence literal ) throws DatatypeException { ContextFactory cf = new ContextFactory ( ) ; Context cx = cf . enterContext ( ) ; RegExpImpl rei = new RegExpImpl ( ) ; String anchoredRegex = "^(?:" + literal + ")$" ; try { rei . compileRegExp ( cx , anchoredRegex , "" ) ; } catch ( EcmaError ee ) { throw newDatatypeException ( ee . getErrorMessage ( ) ) ; } finally { Context . exit ( ) ; } }
Checks that the value compiles as an anchored JavaScript regular expression .
8,915
public static < T extends Key < T > > NameMatcher < T > nameEquals ( final String compareTo ) { return new NameMatcher < > ( compareTo , StringOperatorName . EQUALS ) ; }
Create a NameMatcher that matches names equaling the given string .
8,916
public static < U extends Key < U > > NameMatcher < U > nameStartsWith ( final String compareTo ) { return new NameMatcher < > ( compareTo , StringOperatorName . STARTS_WITH ) ; }
Create a NameMatcher that matches names starting with the given string .
8,917
public static < U extends Key < U > > NameMatcher < U > nameEndsWith ( final String compareTo ) { return new NameMatcher < > ( compareTo , StringOperatorName . ENDS_WITH ) ; }
Create a NameMatcher that matches names ending with the given string .
8,918
public static < U extends Key < U > > NameMatcher < U > nameContains ( final String compareTo ) { return new NameMatcher < > ( compareTo , StringOperatorName . CONTAINS ) ; }
Create a NameMatcher that matches names containing the given string .
8,919
public static Class < ? > getFirstTypeArgument ( Type type ) { if ( type instanceof ParameterizedType ) { ParameterizedType p = ( ParameterizedType ) type ; return getRawClass ( p . getActualTypeArguments ( ) [ 0 ] ) ; } else { return null ; } }
Get declared type parameter of the type has one .
8,920
public static ParamProcessor newInstance ( ParamType type , String listSeparator ) { switch ( type ) { case COOKIE : return listSeparator != null ? new CollectionMergingCookieParamProcessor ( listSeparator ) : DefaultCookieParamProcessor . INSTANCE ; default : return listSeparator != null ? new CollectionMergingParamProcessor ( listSeparator ) : DefaultParamProcessor . INSTANCE ; } }
Returns an instance of a param processor .
8,921
public TriggerBuilder < T > forJob ( final IJobDetail jobDetail ) { final JobKey k = jobDetail . getKey ( ) ; if ( k . getName ( ) == null ) throw new IllegalArgumentException ( "The given job has not yet had a name assigned to it." ) ; m_aJobKey = k ; return this ; }
Set the identity of the Job which should be fired by the produced Trigger by extracting the JobKey from the given job .
8,922
public static String [ ] add ( String [ ] base , String ... extraTags ) { if ( null == base || base . length == 0 ) { return extraTags ; } if ( extraTags . length == 0 ) { return base ; } List < String > tags = new ArrayList < > ( Arrays . asList ( base ) ) ; tags . addAll ( Arrays . asList ( extraTags ) ) ; return tags . toArray ( new String [ tags . size ( ) ] ) ; }
Add extra tags to the existing set .
8,923
boolean allowsValue ( String str , ValidationContext vc ) { try { getValue ( str , vc ) ; return true ; } catch ( DatatypeException e ) { return false ; } }
Requires lexicallyAllows to be true
8,924
public void start ( ) { recordingSystem = new RecordingSystem ( config . getRecordingSystemShouldBeOn ( ) ) ; AuditStream auditStream = config . getAuditStream ( ) ; if ( ! recordingSystem . isRecordingSystemOk ( ) ) { auditStream . println ( "Please run `record_screen_and_upload` before continuing." ) ; return ; } auditStream . println ( "Connecting to " + config . getHostname ( ) ) ; runApp ( ) ; }
~~~~~~~~ The entry point ~~~~~~~~~
8,925
public Object get ( Object object ) throws IllegalAccessException , IllegalArgumentException { if ( null != getter ) { try { return getter . invoke ( object ) ; } catch ( InvocationTargetException ite ) { if ( ite . getCause ( ) instanceof RuntimeException && ! ( ite . getCause ( ) instanceof JTransfoException ) ) { throw ( RuntimeException ) ite . getCause ( ) ; } throw new JTransfoException ( String . format ( GET_SET_ITO , getter . getName ( ) , object . getClass ( ) . getName ( ) , getter . getDeclaringClass ( ) . getName ( ) , ite . getCause ( ) . getMessage ( ) ) , ite . getCause ( ) ) ; } } else { if ( ! getUsingFieldLogged ) { log . warn ( "Cannot find getter (not public, wrong name or wrong type), " + "using field to access field {} of {}." , name , field . getType ( ) . getName ( ) ) ; getUsingFieldLogged = true ; } return field . get ( object ) ; } }
Get field value .
8,926
public void set ( Object object , Object value ) throws IllegalAccessException , IllegalArgumentException { if ( null != setter ) { try { setter . invoke ( object , value ) ; } catch ( InvocationTargetException ite ) { if ( ite . getCause ( ) instanceof RuntimeException && ! ( ite . getCause ( ) instanceof JTransfoException ) ) { throw ( RuntimeException ) ite . getCause ( ) ; } throw new JTransfoException ( String . format ( GET_SET_ITO , setter . getName ( ) , object . getClass ( ) . getName ( ) , setter . getDeclaringClass ( ) . getName ( ) , ite . getCause ( ) . getMessage ( ) ) , ite . getCause ( ) ) ; } } else { if ( ! setUsingFieldLogged ) { log . warn ( "Cannot find setter (not public, wrong name or wrong type), " + "using field to access field {} of {}." , name , field . getType ( ) . getName ( ) ) ; setUsingFieldLogged = true ; } field . set ( object , value ) ; } }
Set field value .
8,927
public static boolean hasMultiPart ( ParamConfig [ ] paramConfigs ) { for ( ParamConfig cfg : paramConfigs ) { if ( hasMultiPart ( cfg . getMetaDatas ( ) ) ) { return true ; } } return false ; }
Checks if the given param config array contains a param with multipart meta datas .
8,928
public static void putMetaDatas ( Map < String , Object > metadatas , String contentType , String fileName ) { metadatas . put ( MULTIPART_FLAG , true ) ; if ( isNotBlank ( contentType ) ) { metadatas . put ( CONTENT_TYPE , contentType ) ; } if ( isNotBlank ( fileName ) ) { metadatas . put ( FILENAME , fileName ) ; } }
Puts multipart metadata informations into the given metadata map
8,929
public static Map < String , Object > toMetaDatas ( String contentType , String fileName ) { Map < String , Object > metadatas = new HashMap < String , Object > ( ) ; putMetaDatas ( metadatas , contentType , fileName ) ; return metadatas ; }
Returns a multipart metadata map
8,930
public String generateInstanceId ( ) throws SchedulerException { String property = System . getProperty ( getSystemPropertyName ( ) ) ; if ( property == null ) throw new SchedulerException ( "No value for '" + SYSTEM_PROPERTY + "' system property found, please configure your environment accordingly!" ) ; if ( getPrepend ( ) != null ) property = getPrepend ( ) + property ; if ( getPostpend ( ) != null ) property = property + getPostpend ( ) ; return property ; }
Returns the cluster wide value for this scheduler instance s id based on a system property
8,931
protected static final String underbarStringToSentence ( String str ) { if ( str == null ) { return null ; } char [ ] buf = new char [ str . length ( ) ] ; buf [ 0 ] = str . charAt ( 0 ) ; for ( int i = 1 ; i < str . length ( ) ; i ++ ) { char c = str . charAt ( i ) ; if ( c >= 'A' && c <= 'Z' ) { c += 0x20 ; } else if ( c == 0x5f ) { c = 0x20 ; } buf [ i ] = c ; } return new String ( buf ) ; }
Turn FOO_BAR_BAZ into Foo bar baz .
8,932
public static int cusolverDnSpotrf_bufferSize ( cusolverDnHandle handle , int uplo , int n , Pointer A , int lda , int [ ] Lwork ) { return checkResult ( cusolverDnSpotrf_bufferSizeNative ( handle , uplo , n , A , lda , Lwork ) ) ; }
Cholesky factorization and its solver
8,933
public static int cusolverDnSpotrfBatched ( cusolverDnHandle handle , int uplo , int n , Pointer Aarray , int lda , Pointer infoArray , int batchSize ) { return checkResult ( cusolverDnSpotrfBatchedNative ( handle , uplo , n , Aarray , lda , infoArray , batchSize ) ) ; }
batched Cholesky factorization and its solver
8,934
public static int cusolverDnSorgqr_bufferSize ( cusolverDnHandle handle , int m , int n , int k , Pointer A , int lda , Pointer tau , int [ ] lwork ) { return checkResult ( cusolverDnSorgqr_bufferSizeNative ( handle , m , n , k , A , lda , tau , lwork ) ) ; }
generate unitary matrix Q from QR factorization
8,935
public static int cusolverDnSorgtr_bufferSize ( cusolverDnHandle handle , int uplo , int n , Pointer A , int lda , Pointer tau , int [ ] lwork ) { return checkResult ( cusolverDnSorgtr_bufferSizeNative ( handle , uplo , n , A , lda , tau , lwork ) ) ; }
generate unitary Q comes from sytrd
8,936
private static String getHash ( String str , String algorithm ) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest . getInstance ( algorithm ) ; md . update ( str . getBytes ( ) ) ; byte byteData [ ] = md . digest ( ) ; StringBuilder hexString = new StringBuilder ( ) ; for ( int i = 0 ; i < byteData . length ; i ++ ) { String hex = Integer . toHexString ( 0xff & byteData [ i ] ) ; if ( hex . length ( ) == 1 ) { hexString . append ( '0' ) ; } hexString . append ( hex ) ; } return hexString . toString ( ) ; }
Return the hezadecimal representation of the string digest given the specified algorithm .
8,937
private String [ ] split ( final String string , final String delim ) { final List < String > result = new ArrayList < > ( ) ; final StringTokenizer stringTokenizer = new StringTokenizer ( string , delim ) ; while ( stringTokenizer . hasMoreTokens ( ) ) { result . add ( stringTokenizer . nextToken ( ) ) ; } return result . toArray ( new String [ result . size ( ) ] ) ; }
Helper method to split the given string by the given delimiter .
8,938
private void _validate ( final int hourOfDay , final int minute , final int second , final int millis ) { if ( hourOfDay < 0 || hourOfDay > 23 ) { throw new IllegalArgumentException ( invalidHourOfDay + hourOfDay ) ; } if ( minute < 0 || minute > 59 ) { throw new IllegalArgumentException ( invalidMinute + minute ) ; } if ( second < 0 || second > 59 ) { throw new IllegalArgumentException ( invalidSecond + second ) ; } if ( millis < 0 || millis > 999 ) { throw new IllegalArgumentException ( invalidMillis + millis ) ; } }
Checks the specified values for validity as a set of time values .
8,939
public SchemaReceiver createSchemaReceiver ( String namespaceUri , PropertyMap properties ) { if ( ! SchemaImpl . NVDL_URI . equals ( namespaceUri ) ) return null ; return new SchemaReceiverImpl ( properties ) ; }
Checks if the namespace is the NVDL namespace and if yes then it creates a schema receiver otherwise returns null .
8,940
protected void pushContext ( Context c ) { Stack < Context > stack = threadSafeContextStack . get ( ) ; if ( stack == null ) { stack = new Stack < Context > ( ) ; stack . push ( c ) ; threadSafeContextStack . set ( stack ) ; } else { threadSafeContextStack . get ( ) . push ( c ) ; } }
Push a new write context onto the stack .
8,941
public final void run ( ) throws IOException , InterruptedException { InputStreamReader isr = new InputStreamReader ( this . is , this . charset ) ; BufferedReader br = new BufferedReader ( isr ) ; this . line = null ; this . lineNumber = 0 ; try { do { if ( this . exit ) { return ; } if ( Thread . currentThread ( ) . isInterrupted ( ) ) { throw new InterruptedException ( ) ; } this . nextLine = br . readLine ( ) ; try { if ( this . line != null ) { processLine ( this . line ) ; if ( this . exit ) { return ; } } } catch ( Exception e ) { onExceptionFound ( e ) ; } finally { this . lineNumber ++ ; this . line = this . nextLine ; } } while ( this . line != null ) ; } finally { onFinish ( ) ; } }
Synchronously processes the input stream
8,942
protected Locator byHeader ( int colIndex ) { if ( colIndex < 1 ) { throw new IllegalArgumentException ( "Column index must be greater than 0." ) ; } String xpath = headerTag . isPresent ( ) ? "./thead/tr[1]/th[" + colIndex + "]" : "./tr[1]/th[" + colIndex + "]" ; return byInner ( By . xpath ( xpath ) ) ; }
Conveniently allows column implementations to lookup headers without duplicating the effort to come up with xpath for each column s header . Simply use this method with that column s index .
8,943
protected Locator byRowColumn ( int rowIndex , int colIndex ) { if ( rowIndex < 1 ) { throw new IllegalArgumentException ( "Row index must be greater than 0." ) ; } if ( colIndex < 1 ) { throw new IllegalArgumentException ( "Column index must be greater than 0." ) ; } String xpath = bodyTag . isPresent ( ) ? "./tbody/tr[" + rowIndex + "]/td[" + colIndex + "]" : "./tr[" + rowIndex + "]/td[" + colIndex + "]" ; return byInner ( By . xpath ( xpath ) ) ; }
Conveniently allows column implementations to lookup cells inside a column without duplicating the effort to come up with xpath for each column s cells . Simply use this method with that column s index .
8,944
public void push ( final T newVal ) { final int index = ( int ) ( m_aCurrentIndex . incrementAndGet ( ) % m_nMaxSize ) ; m_aCircularArray [ index ] . set ( newVal ) ; }
Adds a new item
8,945
public T [ ] toArray ( final T [ ] type ) { if ( type . length > m_nMaxSize ) throw new IllegalArgumentException ( "Size of array passed in cannot be greater than " + m_nMaxSize ) ; final int curIndex = _getCurrentIndex ( ) ; for ( int k = 0 ; k < type . length ; k ++ ) { final int index = _getIndex ( curIndex - k ) ; type [ k ] = m_aCircularArray [ index ] . get ( ) ; } return type ; }
Returns an array of the current elements in the queue . The order of elements is in reverse order of the order items were added .
8,946
public ToConverter getToConverter ( Class toClass , Class domainClass ) throws JTransfoException { ToConverter converter = withPreConverter ( toClass ) ; List < SyntheticField > domainFields = reflectionHelper . getSyntheticFields ( domainClass ) ; for ( Field field : reflectionHelper . getFields ( toClass ) ) { boolean isTransient = Modifier . isTransient ( field . getModifiers ( ) ) ; List < NotMapped > notMapped = reflectionHelper . getAnnotationWithMeta ( field , NotMapped . class ) ; if ( ! isTransient && ( 0 == notMapped . size ( ) ) ) { List < MappedBy > mappedBies = reflectionHelper . getAnnotationWithMeta ( field , MappedBy . class ) ; if ( mappedBies . size ( ) > 1 ) { throw new JTransfoException ( "Field " + field . getName ( ) + " on type " + field . getDeclaringClass ( ) . getName ( ) + " MappedBy is ambiguous, check your meta-annotations." ) ; } MappedBy mappedBy = null ; if ( 1 == mappedBies . size ( ) ) { mappedBy = mappedBies . get ( 0 ) ; } boolean isStatic = ( 0 != ( field . getModifiers ( ) & Modifier . STATIC ) ) ; if ( 0 != mappedBies . size ( ) || ! isStatic ) { buildConverters ( field , domainFields , domainClass , converter , mappedBy ) ; } } } addPostConverter ( converter , toClass ) ; return converter ; }
Build the descriptor for conversion between given object types .
8,947
String withPath ( String [ ] path ) { StringBuilder sb = new StringBuilder ( ) ; if ( path . length > 0 ) { sb . append ( " (with path " ) ; for ( int i = 0 ; i < path . length - 1 ; i ++ ) { sb . append ( path [ i ] ) ; sb . append ( "." ) ; } sb . append ( path [ path . length - 1 ] ) ; sb . append ( ") " ) ; } return sb . toString ( ) ; }
Convert path array to a readable representation .
8,948
SyntheticField [ ] findField ( List < SyntheticField > domainFields , String fieldName , String [ ] path , Class < ? > type , boolean readOnlyField ) throws JTransfoException { List < SyntheticField > fields = domainFields ; SyntheticField [ ] result = new SyntheticField [ path . length + 1 ] ; int index = 0 ; Class < ? > currentType = type ; for ( ; index < path . length ; index ++ ) { boolean found = false ; for ( SyntheticField field : fields ) { if ( field . getName ( ) . equals ( path [ index ] ) ) { found = true ; result [ index ] = field ; break ; } } if ( ! found ) { result [ index ] = new AccessorSyntheticField ( reflectionHelper , currentType , path [ index ] , readOnlyField ) ; } currentType = result [ index ] . getType ( ) ; fields = reflectionHelper . getSyntheticFields ( currentType ) ; } for ( SyntheticField field : fields ) { if ( field . getName ( ) . equals ( fieldName ) ) { result [ index ] = field ; return result ; } } result [ index ] = new AccessorSyntheticField ( reflectionHelper , currentType , fieldName , readOnlyField ) ; return result ; }
Find one field in a list of fields .
8,949
TypeConverter getDefaultTypeConverter ( Type toField , Type domainField ) { for ( TypeConverter typeConverter : typeConvertersInOrder ) { if ( typeConverter . canConvert ( toField , domainField ) ) { return typeConverter ; } } return new NoConversionTypeConverter ( ) ; }
Get the default type converter given the field types to convert between .
8,950
String sendAction ( String action ) throws ClientErrorException , ServerErrorException , OtherCommunicationException { try { String encodedPath = URLEncoder . encode ( this . journeyId , "UTF-8" ) ; String url = String . format ( "http://%s:%d/action/%s/%s" , this . hostname , port , action , encodedPath ) ; HttpResponse < String > response = Unirest . post ( url ) . header ( "Accept" , this . acceptHeader ) . header ( "Accept-Charset" , "UTF-8" ) . asString ( ) ; ensureStatusOk ( response ) ; return response . getBody ( ) ; } catch ( UnirestException | UnsupportedEncodingException e ) { throw new OtherCommunicationException ( "Could not perform POST request" , e ) ; } }
~~~~~~~ POST ~~~~~~~~
8,951
private static void ensureStatusOk ( HttpResponse < String > response ) throws ClientErrorException , ServerErrorException , OtherCommunicationException { int responseStatus = response . getStatus ( ) ; if ( isClientError ( responseStatus ) ) { throw new ClientErrorException ( response . getBody ( ) ) ; } else if ( isServerError ( responseStatus ) ) { throw new ServerErrorException ( ) ; } else if ( isOtherErrorResponse ( responseStatus ) ) { throw new OtherCommunicationException ( ) ; } }
~~~~~~~ Error handling ~~~~~~~~~
8,952
public Gmap3ToDoItem newToDo ( final String description , final String userName ) { final Gmap3ToDoItem toDoItem = repositoryService . instantiate ( Gmap3ToDoItem . class ) ; toDoItem . setDescription ( description ) ; toDoItem . setOwnedBy ( userName ) ; toDoItem . setLocation ( new Location ( 51.5172 + random ( - 0.05 , + 0.05 ) , 0.1182 + random ( - 0.05 , + 0.05 ) ) ) ; repositoryService . persistAndFlush ( toDoItem ) ; return toDoItem ; }
region > programmatic helpers
8,953
private static BigInteger computeDays ( BigInteger months , int refYear , int refMonth ) { switch ( months . signum ( ) ) { case 0 : return BigInteger . valueOf ( 0 ) ; case - 1 : return computeDays ( months . negate ( ) , refYear , refMonth ) . negate ( ) ; } BigInteger [ ] tem = months . divideAndRemainder ( BigInteger . valueOf ( 400 * 12 ) ) ; -- refMonth ; int total = 0 ; for ( int rem = tem [ 1 ] . intValue ( ) ; rem > 0 ; rem -- ) { total += daysInMonth ( refYear , refMonth ) ; if ( ++ refMonth == 12 ) { refMonth = 0 ; refYear ++ ; } } return tem [ 0 ] . multiply ( BigInteger . valueOf ( 365 * 400 + 97 ) ) . add ( BigInteger . valueOf ( total ) ) ; }
Returns the number of days spanned by a period of months starting with a particular reference year and month .
8,954
private static BigDecimal daysPlusSeconds ( BigInteger days , BigDecimal seconds ) { return seconds . add ( new BigDecimal ( days . multiply ( BigInteger . valueOf ( 24 * 60 * 60 ) ) ) ) ; }
Returns the total number of seconds from a specified number of days and seconds .
8,955
private static BigInteger computeMonths ( Duration d ) { return d . getYears ( ) . multiply ( BigInteger . valueOf ( 12 ) ) . add ( d . getMonths ( ) ) ; }
Returns the total number of months specified by the year and month fields of the duration
8,956
private static BigDecimal computeSeconds ( Duration d ) { return d . getSeconds ( ) . add ( new BigDecimal ( d . getDays ( ) . multiply ( BigInteger . valueOf ( 24 ) ) . add ( d . getHours ( ) ) . multiply ( BigInteger . valueOf ( 60 ) ) . add ( d . getMinutes ( ) ) . multiply ( BigInteger . valueOf ( 60 ) ) ) ) ; }
Returns the total number of seconds specified by the days hours minuts and seconds fields of the duration .
8,957
public Boolean process ( final AciResponseInputStream aciResponse ) { try { IOUtils . copy ( aciResponse , outputStream ) ; outputStream . flush ( ) ; return true ; } catch ( final IOException e ) { throw new ProcessorException ( e ) ; } }
Copies the given AciResponseInputStream into the OutputStream .
8,958
public SipStack initializeSipStack ( String transport , String myPort , Properties myProperties ) throws Exception { tearDown ( ) ; try { sipStack = new SipStack ( transport , Integer . valueOf ( myPort ) , myProperties ) ; logger . info ( "SipStack - " + sipStackName + " - created!" ) ; } catch ( Exception ex ) { logger . info ( "Exception: " + ex . getClass ( ) . getName ( ) + ": " + ex . getMessage ( ) ) ; throw ex ; } initialized = true ; return sipStack ; }
Initialize SipStack using provided properties
8,959
public T newProxy ( ) { Object proxy = Proxy . newProxyInstance ( classLoader , exportInterfaces , this ) ; return clazz . cast ( proxy ) ; }
Creates an proxy implementing T and all passed additional interfaces .
8,960
public static void setInput ( Input input , InputSource inputSource ) { input . setByteStream ( inputSource . getByteStream ( ) ) ; input . setCharacterStream ( inputSource . getCharacterStream ( ) ) ; input . setUri ( inputSource . getSystemId ( ) ) ; input . setEncoding ( inputSource . getEncoding ( ) ) ; }
public because needed by transform package
8,961
public XMLReader getXMLReader ( ) throws SAXException { XMLFilter filter = _Verifier . getVerifierFilter ( ) ; filter . setParent ( _WrappedParser . getXMLReader ( ) ) ; return filter ; }
returns a new XMLReader for parsing and validating the input
8,962
public void parse ( File f , DefaultHandler dh ) throws SAXException , IOException { XMLReader reader = getXMLReader ( ) ; InputSource source = new InputSource ( new FileInputStream ( f ) ) ; reader . setContentHandler ( dh ) ; reader . parse ( source ) ; }
parses and validates the given File using the given DefaultHandler
8,963
public void parse ( InputSource source , DefaultHandler dh ) throws SAXException , IOException { XMLReader reader = getXMLReader ( ) ; reader . setContentHandler ( dh ) ; reader . parse ( source ) ; }
parses and validates the given InputSource using the given DefaultHandler
8,964
public String getAuditText ( ) { return String . format ( "id = %s, req = %s(%s)" , getId ( ) , getMethodName ( ) , PresentationUtils . toDisplayableString ( getParams ( ) ) ) ; }
~~~ Pretty print
8,965
XMLReader newXMLReader ( ) throws ParserConfigurationException , SAXException , FactoryConfigurationError { SAXParserFactory parserFactory = SAXParserFactory . newInstance ( ) ; SAXParser saxParser = parserFactory . newSAXParser ( ) ; XMLReader reader = saxParser . getXMLReader ( ) ; reader . setContentHandler ( this ) ; return reader ; }
Convenience method that creates a XMLReader configured with this XmlRpcHandler instance .
8,966
public static boolean isValid ( String s ) { try { new URI ( UriEncoder . encode ( s ) ) ; } catch ( URISyntaxException e ) { return false ; } return true ; }
Tests whether a string is a valid URI reference .
8,967
public static boolean isAbsolute ( String uri ) { int i = uri . indexOf ( ':' ) ; if ( i < 0 ) return false ; while ( -- i >= 0 ) { switch ( uri . charAt ( i ) ) { case '#' : case '/' : case '?' : return false ; } } return true ; }
Tests whether a valid URI reference is absolute . It is allowed to pass an invalid URI reference but the result is not defined . It is also allowed to pass a valid URI with leading and trailing whitespace .
8,968
public boolean mustShowWindowForError ( SAXParseException error ) { for ( Pattern curIgnorePattern : ignoreErrorsForWindow ) { if ( curIgnorePattern . matcher ( error . getMessage ( ) ) . find ( ) ) return false ; } return true ; }
Determines whether the validation result window should pop up for this particular error . If just one error instructs that the window should pop up it does so .
8,969
private ActionSet getElementActionsExplicit ( String ns ) { ActionSet actions = ( ActionSet ) elementMap . get ( ns ) ; if ( actions == null ) { for ( Enumeration e = nssElementMap . keys ( ) ; e . hasMoreElements ( ) && actions == null ; ) { NamespaceSpecification nssI = ( NamespaceSpecification ) e . nextElement ( ) ; if ( nssI . covers ( ns ) ) { actions = ( ActionSet ) nssElementMap . get ( nssI ) ; } } if ( actions != null ) { elementMap . put ( ns , actions ) ; } } if ( actions == null && includedModes != null ) { Iterator i = includedModes . iterator ( ) ; while ( actions == null && i . hasNext ( ) ) { Mode includedMode = ( Mode ) i . next ( ) ; actions = includedMode . getElementActionsExplicit ( ns ) ; } if ( actions != null ) { actions = actions . changeCurrentMode ( this ) ; elementMap . put ( ns , actions ) ; } } if ( actions == null && baseMode != null ) { actions = baseMode . getElementActionsExplicit ( ns ) ; if ( actions != null ) { actions = actions . changeCurrentMode ( this ) ; elementMap . put ( ns , actions ) ; } } if ( actions != null && actions . getCancelNestedActions ( ) ) { actions = null ; } return actions ; }
Look for element actions specifically specified for this namespace . If the current mode does not have actions for that namespace look at base modes . If the actions are defined in a base mode we need to get a copy of those actions associated with this mode so we call changeCurrentMode on them .
8,970
private AttributeActionSet getAttributeActionsExplicit ( String ns ) { AttributeActionSet actions = ( AttributeActionSet ) attributeMap . get ( ns ) ; if ( actions == null ) { for ( Enumeration e = nssAttributeMap . keys ( ) ; e . hasMoreElements ( ) && actions == null ; ) { NamespaceSpecification nssI = ( NamespaceSpecification ) e . nextElement ( ) ; if ( nssI . covers ( ns ) ) { actions = ( AttributeActionSet ) nssAttributeMap . get ( nssI ) ; } } if ( actions != null ) { attributeMap . put ( ns , actions ) ; } } if ( actions == null && includedModes != null ) { Iterator i = includedModes . iterator ( ) ; while ( actions == null && i . hasNext ( ) ) { Mode includedMode = ( Mode ) i . next ( ) ; actions = includedMode . getAttributeActionsExplicit ( ns ) ; } if ( actions != null ) { attributeMap . put ( ns , actions ) ; } } if ( actions == null && baseMode != null ) { actions = baseMode . getAttributeActionsExplicit ( ns ) ; if ( actions != null ) attributeMap . put ( ns , actions ) ; } if ( actions != null && actions . getCancelNestedActions ( ) ) { actions = null ; } return actions ; }
Look for attribute actions specifically specified for this namespace . If the current mode does not have actions for that namespace look at base modes . If the actions are defined in a base mode we need to get a copy of those actions associated with this mode so we call changeCurrentMode on them .
8,971
boolean bindElement ( String ns , String wildcard , ActionSet actions ) { NamespaceSpecification nss = new NamespaceSpecification ( ns , wildcard ) ; if ( nssElementMap . get ( nss ) != null ) return false ; for ( Enumeration e = nssElementMap . keys ( ) ; e . hasMoreElements ( ) ; ) { NamespaceSpecification nssI = ( NamespaceSpecification ) e . nextElement ( ) ; if ( nss . compete ( nssI ) ) { return false ; } } nssElementMap . put ( nss , actions ) ; return true ; }
Adds a set of element actions to be performed in this mode for elements in a specified namespace .
8,972
boolean bindAttribute ( String ns , String wildcard , AttributeActionSet actions ) { NamespaceSpecification nss = new NamespaceSpecification ( ns , wildcard ) ; if ( nssAttributeMap . get ( nss ) != null ) return false ; for ( Enumeration e = nssAttributeMap . keys ( ) ; e . hasMoreElements ( ) ; ) { NamespaceSpecification nssI = ( NamespaceSpecification ) e . nextElement ( ) ; if ( nss . compete ( nssI ) ) { return false ; } } nssAttributeMap . put ( nss , actions ) ; return true ; }
Adds a set of attribute actions to be performed in this mode for attributes in a specified namespace .
8,973
private static boolean isInternetReachable ( ) { try { final URL url = new URL ( "http://www.google.com" ) ; final HttpURLConnection urlConnect = ( HttpURLConnection ) url . openConnection ( ) ; urlConnect . setConnectTimeout ( 1000 ) ; urlConnect . getContent ( ) ; urlConnect . disconnect ( ) ; } catch ( UnknownHostException e ) { return false ; } catch ( IOException e ) { return false ; } return true ; }
Tries to retrieve some content 1 second timeout .
8,974
public Date build ( ) { Calendar cal ; if ( m_aTZ != null && m_aLocale != null ) cal = Calendar . getInstance ( m_aTZ , m_aLocale ) ; else if ( m_aTZ != null ) cal = Calendar . getInstance ( m_aTZ , Locale . getDefault ( Locale . Category . FORMAT ) ) ; else if ( m_aLocale != null ) cal = Calendar . getInstance ( TimeZone . getDefault ( ) , m_aLocale ) ; else cal = PDTFactory . createCalendar ( ) ; cal . set ( Calendar . YEAR , m_nYear ) ; cal . set ( Calendar . MONTH , m_nMonth - 1 ) ; cal . set ( Calendar . DAY_OF_MONTH , m_nDay ) ; cal . set ( Calendar . HOUR_OF_DAY , m_nHour ) ; cal . set ( Calendar . MINUTE , m_nMinute ) ; cal . set ( Calendar . SECOND , m_nSecond ) ; cal . set ( Calendar . MILLISECOND , 0 ) ; return cal . getTime ( ) ; }
Build the Date defined by this builder instance .
8,975
protected String [ ] ph ( String ... strs ) { String [ ] res = new String [ strs . length ] ; for ( int i = 0 ; i < res . length ; i ++ ) { res [ i ] = ph ( strs [ i ] ) ; } return res ; }
replace any placeholder from the given strings
8,976
public ParamConfigBuilder newParamConfig ( Class < ? > type , Type genericType ) { return paramConfigBuilderFactory . newInstance ( type , genericType ) ; }
Returns a new param config for the given class and generic type
8,977
public Map < Layout , Collection < XmlScope > > getXmlScopes ( ) { List < File > layoutDirs = layoutsFinder . findLayoutDirs ( ) ; Collection < File > layoutFiles = collectionUtils . flatMap ( layoutDirs , new CollectionUtils . Function < File , Collection < File > > ( ) { public Collection < File > apply ( File file ) { return collectionUtils . filter ( Arrays . asList ( file . listFiles ( ) ) , new CollectionUtils . Function < File , Boolean > ( ) { public Boolean apply ( File file ) { return file . getName ( ) . endsWith ( ".xml" ) ; } } ) ; } } ) ; Collection < Document > docs = collectionUtils . flatMapOpt ( layoutFiles , new CollectionUtils . Function < File , Option < Document > > ( ) { public Option < Document > apply ( File file ) { return getDocumentFromFile ( file ) ; } } ) ; return collectionUtils . toMap ( collectionUtils . flatMapOpt ( docs , new CollectionUtils . Function < Document , Option < Tuple < Layout , Collection < XmlScope > > > > ( ) { public Option < Tuple < Layout , Collection < XmlScope > > > apply ( Document doc ) { Option < String > optNameSpace = namespaceFinder . getNameSpace ( doc ) ; if ( optNameSpace . isPresent ( ) ) { attrPattern = Pattern . compile ( String . format ( NAMESPACE_ATTRIBUTE_REG , optNameSpace . get ( ) ) ) ; Collection < XmlScope > scopes = getScopes ( doc ) ; return Option . of ( Tuple . of ( new Layout ( doc . getDocumentURI ( ) ) , scopes ) ) ; } else { return Option . absent ( ) ; } } } ) ) ; }
maps all of the layouts to their scopes could be optimized
8,978
public void setGroupName ( final String sGroupName ) { ValueEnforcer . notEmpty ( sGroupName , "GroupName" ) ; m_sGroupName = sGroupName ; }
Set the Quartz internal group name .
8,979
public void addJobListener ( final IJobListener aJobListener ) { ValueEnforcer . notNull ( aJobListener , "JobListener" ) ; try { m_aScheduler . getListenerManager ( ) . addJobListener ( aJobListener , EverythingMatcher . allJobs ( ) ) ; } catch ( final SchedulerException ex ) { throw new IllegalStateException ( "Failed to add job listener " + aJobListener . toString ( ) , ex ) ; } }
Add a job listener for all jobs .
8,980
public TriggerKey scheduleJob ( final String sJobName , final JDK8TriggerBuilder < ? extends ITrigger > aTriggerBuilder , final Class < ? extends IJob > aJobClass , final Map < String , ? extends Object > aJobData ) { ValueEnforcer . notNull ( sJobName , "JobName" ) ; ValueEnforcer . notNull ( aTriggerBuilder , "TriggerBuilder" ) ; ValueEnforcer . notNull ( aJobClass , "JobClass" ) ; final IJobDetail aJobDetail = JobBuilder . newJob ( aJobClass ) . withIdentity ( sJobName , m_sGroupName ) . build ( ) ; aJobDetail . getJobDataMap ( ) . putAllIn ( aJobData ) ; try { final ITrigger aTrigger = aTriggerBuilder . build ( ) ; m_aScheduler . scheduleJob ( aJobDetail , aTrigger ) ; final TriggerKey ret = aTrigger . getKey ( ) ; LOGGER . info ( "Succesfully scheduled job '" + sJobName + "' with TriggerKey " + ret . toString ( ) + " - starting at " + PDTFactory . createLocalDateTime ( aTrigger . getStartTime ( ) ) ) ; return ret ; } catch ( final SchedulerException ex ) { throw new RuntimeException ( ex ) ; } }
This method is only for testing purposes .
8,981
public TriggerKey scheduleJobNowOnce ( final String sJobName , final Class < ? extends IJob > aJobClass , final Map < String , ? extends Object > aJobData ) { return scheduleJob ( sJobName , JDK8TriggerBuilder . newTrigger ( ) . startNow ( ) . withSchedule ( SimpleScheduleBuilder . simpleSchedule ( ) . withIntervalInMinutes ( 1 ) . withRepeatCount ( 0 ) ) , aJobClass , aJobData ) ; }
Schedule a new job that should be executed now and only once .
8,982
public void shutdown ( ) throws SchedulerException { try { m_aScheduler . shutdown ( true ) ; LOGGER . info ( "Successfully shutdown GlobalQuartzScheduler" ) ; } catch ( final SchedulerException ex ) { LOGGER . error ( "Failed to shutdown GlobalQuartzScheduler" , ex ) ; throw ex ; } }
Shutdown the scheduler and wait for all jobs to complete .
8,983
public void setHttpClient ( HttpClient httpClient ) { if ( httpClient != defaultHttpClient && this . httpClient == defaultHttpClient ) { defaultHttpClient . getConnectionManager ( ) . shutdown ( ) ; } this . httpClient = httpClient ; }
Sets the HTTP client . If the new client is different from the default and the default is still in use it will be automatically closed .
8,984
public static void closeQuietly ( XMLStreamWriter writer ) { if ( writer != null ) { try { writer . close ( ) ; } catch ( XMLStreamException e ) { logger . warn ( "Error while closing" , e ) ; } } }
Closes the given writer without throwing an exception on failure . Instead a warning will be logged .
8,985
public static void closeQuietly ( XMLStreamReader reader ) { if ( reader != null ) { try { reader . close ( ) ; } catch ( XMLStreamException e ) { logger . warn ( "Error while closing" , e ) ; } } }
Closes the given reader without throwing an exception on failure . Instead a warning will be logged .
8,986
public static InputStream get ( HttpClient httpClient , URI requestURI ) throws IOException { HttpEntity entity = doGet ( httpClient , requestURI ) ; if ( entity == null ) { return new ByteArrayInputStream ( new byte [ 0 ] ) ; } return entity . getContent ( ) ; }
Performs an HTTP GET using the given client returning an input stream over the response body . The caller MUST close the stream when finished .
8,987
private File baseDir ( ) throws IOException { if ( baseDir == null ) { baseDir = File . createTempFile ( "fcrepo-dto" , null ) ; if ( ! baseDir . delete ( ) ) { throw new IOException ( "Can't delete temp file " + baseDir ) ; } if ( ! baseDir . mkdir ( ) ) { throw new IOException ( "Can't create temp dir " + baseDir ) ; } } return baseDir ; }
allocates the temporary base directory lazily
8,988
private static void rmDir ( File dir ) { for ( File file : dir . listFiles ( ) ) { if ( file . isDirectory ( ) ) { rmDir ( file ) ; } else { if ( ! file . delete ( ) ) { logger . warn ( "Can't delete file " + file ) ; } } } if ( ! dir . delete ( ) ) { logger . warn ( "Can't delete dir " + dir ) ; } }
recursively remove a directory logging warnings if needed .
8,989
public void setContentHandler ( ContentHandler contentHandler ) { if ( contentHandler == null ) throw new NullPointerException ( ) ; if ( contentHandler != defaultContentHandler && this . contentHandler == defaultContentHandler ) { defaultContentHandler . close ( ) ; } }
Sets the content handler . If the new content handler is different from the default and the default is still in use it will be automatically closed .
8,990
public List < String > getNamespaces ( ) { List < String > namespaceList = new ArrayList < String > ( ) ; java . util . Map < String , String > attributes = model . getAttributes ( ) ; for ( Entry < String , String > e : attributes . entrySet ( ) ) { final String name = e . getKey ( ) ; final String value = e . getValue ( ) ; if ( value != null && value . startsWith ( "http://" ) ) { namespaceList . add ( name + "=" + value ) ; } } return namespaceList ; }
Returns all defined namespaces .
8,991
public SingleSwapMove getRandomMove ( PermutationSolution solution , Random rnd ) { int n = solution . size ( ) ; if ( n < 2 ) { return null ; } int i = rnd . nextInt ( n ) ; int j = rnd . nextInt ( n - 1 ) ; if ( j >= i ) { j ++ ; } return new SingleSwapMove ( i , j ) ; }
Create a random single swap move .
8,992
public final void evaluate ( ) throws IllegalAccessException , InvocationTargetException { if ( simple ) tr . startCollection ( ) ; fTestMethod . invoke ( fTarget , params ) ; if ( simple ) tr . stopCollection ( ) ; }
Evaluates the statement i . e . executes the tests .
8,993
public Telefonnummer getInlandsnummer ( ) { if ( getLaenderkennzahl ( ) . isPresent ( ) ) { String nummer = this . getCode ( ) . substring ( 3 ) . trim ( ) ; if ( StringUtils . startsWithAny ( nummer , "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" ) ) { nummer = "0" + nummer ; } return new Telefonnummer ( nummer ) ; } else { return this ; } }
Liefert die Telefonnummer ohne Laenderkennzahl dafuer mit Vorwahl inklusive fuehrender Null .
8,994
public Telefonnummer getRufnummer ( ) { String inlandsnummer = RegExUtils . replaceAll ( this . getInlandsnummer ( ) . toString ( ) , "[ /]+" , " " ) ; return new Telefonnummer ( StringUtils . substringAfter ( inlandsnummer , " " ) . replaceAll ( " " , "" ) ) ; }
Liefert die Nummer der Ortsvermittlungsstelle d . h . die Telefonnummer ohne Vorwahl und Laenderkennzahl .
8,995
public String toDinString ( ) { Optional < String > laenderkennzahl = getLaenderkennzahl ( ) ; return laenderkennzahl . map ( s -> s + " " + getVorwahl ( ) . substring ( 1 ) + " " + getRufnummer ( ) ) . orElseGet ( ( ) -> getVorwahl ( ) + " " + getRufnummer ( ) ) ; }
Gibt den String nach DIN 5008 aus . Die Nummern werden dabei funktionsbezogen durch Leerzeichen und die Durchwahl mit Bindestrich abgetrennt .
8,996
public String toQueryString ( ) { String result = null ; List < String > parameters = new ArrayList < > ( ) ; for ( Map . Entry < String , String > entry : entrySet ( ) ) { String key = entry . getKey ( ) ; String value ; try { value = URLEncoder . encode ( entry . getValue ( ) , StandardCharsets . UTF_8 . name ( ) ) ; } catch ( UnsupportedEncodingException e ) { throw new IllegalArgumentException ( "Error encoding URL" , e ) ; } parameters . add ( key + "=" + value ) ; } if ( parameters . size ( ) > 0 ) { result = StringUtils . join ( parameters , '&' ) ; } return result ; }
A value suitable for constructinng URIs with . This means that if there are no parameters null will be returned .
8,997
public void compile ( JQElement element , JSON attrs ) { String text = SafeHtmlUtils . htmlEscape ( element . text ( ) ) ; element . empty ( ) . append ( prettifier . prettify ( text ) ) ; }
Processes the element body using Prettify filter .
8,998
public E apply ( Iterator < E > consumable ) { dbc . precondition ( consumable != null , "consuming a null iterator" ) ; dbc . precondition ( consumable . hasNext ( ) , "no element to consume" ) ; final E found = consumable . next ( ) ; dbc . state ( ! consumable . hasNext ( ) , "found more than one element consuming the iterator" ) ; return found ; }
Consumes the iterator and yields the only element contained in it .
8,999
public static < T > Pair < Integer , List < T > > page ( long start , long howMany , Iterator < T > iterator ) { final Pair < Long , List < T > > page = Pagination . LongPages . page ( start , howMany , iterator ) ; dbc . state ( page . first ( ) <= Integer . MAX_VALUE , "iterator size overflows an integer" ) ; return Pair . of ( page . first ( ) . intValue ( ) , page . second ( ) ) ; }
Creates a page view of an iterator .