idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
15,000 | public void changeScope ( final ThreadDelegatedContext context ) { final ThreadDelegatedContext oldContext = threadLocal . get ( ) ; if ( oldContext != null ) { if ( oldContext == context ) { return ; } else { oldContext . event ( ScopeEvent . LEAVE ) ; } } if ( context != null ) { threadLocal . set ( context ) ; context . event ( ScopeEvent . ENTER ) ; } else { threadLocal . remove ( ) ; } } | A thread enters the scope . Clear the current context . If a new context was given assign it to the scope otherwise leave it empty . |
15,001 | public static void generateFixedUrls ( final ContentSpec contentSpec , boolean missingOnly , final Integer fixedUrlPropertyTagId ) { final Set < String > existingFixedUrls = new HashSet < String > ( ) ; final Set < SpecNode > nodesWithoutFixedUrls = new HashSet < SpecNode > ( ) ; final List < SpecNode > specNodes = getAllSpecNodes ( contentSpec ) ; if ( missingOnly ) { collectFixedUrlInformation ( specNodes , nodesWithoutFixedUrls , existingFixedUrls ) ; } generateFixedUrlForNodes ( nodesWithoutFixedUrls , existingFixedUrls , fixedUrlPropertyTagId ) ; } | Generate the fixed urls and sets it where required for a content specification . |
15,002 | public static void collectFixedUrlInformation ( final Collection < SpecNode > specNodes , final Collection < SpecNode > nodesWithoutFixedUrls , final Set < String > existingFixedUrls ) { for ( final SpecNode specNode : specNodes ) { if ( isNullOrEmpty ( specNode . getFixedUrl ( ) ) ) { if ( specNode instanceof CommonContent ) { continue ; } else if ( specNode instanceof Level ) { final Level level = ( Level ) specNode ; if ( level . getLevelType ( ) != LevelType . INITIAL_CONTENT && level . getLevelType ( ) != LevelType . BASE ) { nodesWithoutFixedUrls . add ( specNode ) ; } } else if ( specNode instanceof ITopicNode ) { final ITopicNode topicNode = ( ( ITopicNode ) specNode ) ; if ( topicNode . getTopicType ( ) != TopicType . INFO && topicNode . getTopicType ( ) != TopicType . INITIAL_CONTENT ) { nodesWithoutFixedUrls . add ( specNode ) ; } } else { nodesWithoutFixedUrls . add ( specNode ) ; } } else { existingFixedUrls . add ( specNode . getFixedUrl ( ) ) ; } } } | Collect the fixed url information from a list of spec nodes . |
15,003 | public static String generateFixedURLForNode ( final SpecNode specNode , final Set < String > existingFixedUrls , final Integer fixedUrlPropertyTagId ) { String value ; if ( specNode instanceof ITopicNode ) { final ITopicNode topicNode = ( ITopicNode ) specNode ; final BaseTopicWrapper < ? > topic = topicNode . getTopic ( ) ; if ( STATIC_FIXED_URL_TOPIC_TYPES . contains ( topicNode . getTopicType ( ) ) ) { value = getStaticFixedURLForTopicNode ( topicNode ) ; } else if ( topic != null ) { final PropertyTagInTopicWrapper fixedUrl = topic . getProperty ( fixedUrlPropertyTagId ) ; if ( fixedUrl != null && ! existingFixedUrls . contains ( fixedUrl . getValue ( ) ) ) { value = fixedUrl . getValue ( ) ; } else { final String topicTitle ; if ( topic instanceof TranslatedTopicWrapper ) { topicTitle = ContentSpecUtilities . getTopicTitleWithConditions ( topicNode , ( ( TranslatedTopicWrapper ) topic ) . getTopic ( ) ) ; } else { topicTitle = ContentSpecUtilities . getTopicTitleWithConditions ( topicNode , topic ) ; } value = createURLTitle ( topicTitle ) ; } } else { value = createURLTitle ( specNode . getTitle ( ) ) ; } } else if ( specNode instanceof Level ) { final String levelPrefix = ContentSpecUtilities . getLevelPrefix ( ( Level ) specNode ) ; value = levelPrefix + createURLTitle ( specNode . getTitle ( ) ) ; } else { value = createURLTitle ( specNode . getTitle ( ) ) ; } if ( isNullOrEmpty ( value ) || existingFixedUrls . contains ( value ) ) { String baseUrlName = value ; if ( isNullOrEmpty ( baseUrlName ) || baseUrlName . matches ( "^\\d+$" ) ) { if ( specNode instanceof Level ) { final Level level = ( Level ) specNode ; final String levelPrefix = ContentSpecUtilities . getLevelPrefix ( level ) ; baseUrlName = levelPrefix + level . getLevelType ( ) . getTitle ( ) . replace ( " " , "_" ) + "ID" + specNode . getUniqueId ( ) ; } else if ( specNode instanceof ITopicNode ) { baseUrlName = "TopicID" + ( ( ITopicNode ) specNode ) . getDBId ( ) ; } else { throw new RuntimeException ( "Cannot generate a fixed url for an Unknown SpecNode type" ) ; } } String postFix = "" ; for ( int uniqueCount = 1 ; ; ++ uniqueCount ) { if ( ! existingFixedUrls . contains ( baseUrlName + postFix ) ) { value = baseUrlName + postFix ; break ; } else { postFix = uniqueCount + "" ; } } } return value ; } | Generate a fixed url for a specific content spec node making sure that it is valid within the Content Specification . |
15,004 | protected static void setFixedURL ( final SpecNode specNode , final String fixedURL , final Set < String > existingFixedUrls ) { specNode . setFixedUrl ( fixedURL ) ; existingFixedUrls . add ( fixedURL ) ; } | Sets the fixed URL property on the node . |
15,005 | public static String getStaticFixedURLForTopicNode ( final ITopicNode topicNode ) { if ( topicNode . getTopicType ( ) == TopicType . REVISION_HISTORY ) { return "appe-Revision_History" ; } else if ( topicNode . getTopicType ( ) == TopicType . LEGAL_NOTICE ) { return "Legal_Notice" ; } else if ( topicNode . getTopicType ( ) == TopicType . AUTHOR_GROUP ) { return "Author_Group" ; } else if ( topicNode . getTopicType ( ) == TopicType . ABSTRACT ) { return "Abstract" ; } else { return null ; } } | Generate the fixed url for a static topic node . |
15,006 | public static String createURLTitle ( final String title ) { String baseTitle = title ; baseTitle = baseTitle . replaceAll ( "</(.*?)>" , "" ) . replaceAll ( "<(.*?)>" , "" ) ; final Matcher invalidSequenceMatcher = STARTS_WITH_INVALID_SEQUENCE_RE . matcher ( baseTitle ) ; if ( invalidSequenceMatcher . find ( ) ) { baseTitle = invalidSequenceMatcher . group ( "EverythingElse" ) ; } final Matcher matcher = STARTS_WITH_NUMBER_RE . matcher ( baseTitle ) ; if ( matcher . find ( ) ) { final String numbers = matcher . group ( "Numbers" ) ; final String everythingElse = matcher . group ( "EverythingElse" ) ; if ( numbers != null && everythingElse != null ) { final NumberFormat formatter = new RuleBasedNumberFormat ( RuleBasedNumberFormat . SPELLOUT ) ; final String numbersSpeltOut = formatter . format ( Integer . parseInt ( numbers ) ) ; baseTitle = numbersSpeltOut + everythingElse ; if ( baseTitle . length ( ) > 0 ) { baseTitle = baseTitle . substring ( 0 , 1 ) . toUpperCase ( ) + baseTitle . substring ( 1 , baseTitle . length ( ) ) ; } } } final String escapedTitle = DocBookUtilities . escapeTitle ( baseTitle ) ; if ( escapedTitle . matches ( "^\\d+$" ) ) { return "" ; } else { return escapedTitle ; } } | Creates the URL specific title for a topic or level . |
15,007 | public static boolean containsFile ( final File parent , final File search ) { boolean exists = false ; final String [ ] children = parent . list ( ) ; if ( children == null ) { return false ; } final List < String > fileList = Arrays . asList ( children ) ; if ( fileList . contains ( search . getName ( ) ) ) { exists = true ; } return exists ; } | Checks if the given file contains only in the parent file not in the subdirectories . |
15,008 | public static boolean containsFile ( final File fileToSearch , final String pathname ) { final String [ ] allFiles = fileToSearch . list ( ) ; if ( allFiles == null ) { return false ; } final List < String > list = Arrays . asList ( allFiles ) ; return list . contains ( pathname ) ; } | Checks if the given file contains in the parent file . |
15,009 | public static boolean containsFileRecursive ( final File parent , final File search ) { final File toSearch = search . getAbsoluteFile ( ) ; boolean exists = false ; final File [ ] children = parent . getAbsoluteFile ( ) . listFiles ( ) ; if ( children == null ) { return false ; } final List < File > fileList = Arrays . asList ( children ) ; for ( final File currentFile : fileList ) { if ( currentFile . isDirectory ( ) ) { exists = FileSearchExtensions . containsFileRecursive ( currentFile , toSearch ) ; if ( exists ) { return true ; } } if ( fileList . contains ( toSearch ) ) { return true ; } } return exists ; } | Checks if the given file contains only in the parent file recursively . |
15,010 | public static long countAllFilesInDirectory ( final File dir , long length , final boolean includeDirectories ) { final File [ ] children = dir . getAbsoluteFile ( ) . listFiles ( ) ; if ( children == null || children . length < 1 ) { return length ; } for ( final File element : children ) { if ( element . isDirectory ( ) ) { if ( includeDirectories ) { length ++ ; } length = countAllFilesInDirectory ( element , length , includeDirectories ) ; } else { length ++ ; } } return length ; } | Counts all the files in a directory recursively . This includes files in the subdirectories . |
15,011 | public static List < File > findFiles ( final String start , final String [ ] extensions ) { final List < File > files = new ArrayList < > ( ) ; final Stack < File > dirs = new Stack < > ( ) ; final File startdir = new File ( start ) ; if ( startdir . isDirectory ( ) ) { dirs . push ( new File ( start ) ) ; } while ( dirs . size ( ) > 0 ) { final File dirFiles = dirs . pop ( ) ; final String s [ ] = dirFiles . list ( ) ; if ( s != null ) { for ( final String element : s ) { final File file = new File ( dirFiles . getAbsolutePath ( ) + File . separator + element ) ; if ( file . isDirectory ( ) ) { dirs . push ( file ) ; } else if ( match ( element , extensions ) ) { files . add ( file ) ; } } } } return files ; } | Searches for files with the given extensions and adds them to a Vector . |
15,012 | public static List < File > findFilesRecursive ( final File dir , final String filenameToSearch ) { final List < File > foundedFileList = new ArrayList < > ( ) ; final String regex = RegExExtensions . replaceWildcardsWithRE ( filenameToSearch ) ; final File [ ] children = dir . getAbsoluteFile ( ) . listFiles ( ) ; if ( children == null || children . length < 1 ) { return foundedFileList ; } for ( final File element : children ) { if ( element . isDirectory ( ) ) { final List < File > foundedFiles = findFilesRecursive ( element , filenameToSearch ) ; foundedFileList . addAll ( foundedFiles ) ; } else { final String filename = element . getName ( ) ; if ( filename . matches ( regex ) ) { foundedFileList . add ( element . getAbsoluteFile ( ) ) ; } } } return foundedFileList ; } | Finds all files that match the search pattern . The search is recursively . |
15,013 | public static List < File > findFilesWithFilter ( final File dir , final String ... extension ) { final List < File > foundedFileList = new ArrayList < > ( ) ; final File [ ] children = dir . listFiles ( new MultiplyExtensionsFileFilter ( true , extension ) ) ; for ( final File element : children ) { if ( element . isDirectory ( ) ) { foundedFileList . addAll ( findFilesWithFilter ( element , extension ) ) ; } else { foundedFileList . add ( element . getAbsoluteFile ( ) ) ; } } return foundedFileList ; } | Finds all files that match the given extension . The search is recursively . |
15,014 | public static List < File > getAllFilesFromDir ( final File dir ) { final List < File > foundedFileList = new ArrayList < > ( ) ; final File [ ] children = dir . getAbsoluteFile ( ) . listFiles ( ) ; if ( children == null || children . length < 1 ) { return foundedFileList ; } for ( final File child : children ) { if ( ! child . isDirectory ( ) ) { foundedFileList . add ( child . getAbsoluteFile ( ) ) ; } } return foundedFileList ; } | Gets the all files from directory . |
15,015 | public static String getSearchFilePattern ( final String ... fileExtensions ) { if ( fileExtensions . length == 0 ) { return "" ; } final String searchFilePatternPrefix = "([^\\s]+(\\.(?i)(" ; final String searchFilePatternSuffix = "))$)" ; final StringBuilder sb = new StringBuilder ( ) ; int count = 1 ; for ( final String fileExtension : fileExtensions ) { if ( count < fileExtensions . length ) { sb . append ( fileExtension ) . append ( "|" ) ; } else { sb . append ( fileExtension ) ; } count ++ ; } return searchFilePatternPrefix + sb . toString ( ) . trim ( ) + searchFilePatternSuffix ; } | Gets a regex search file pattern that can be used for searching files with a Matcher . |
15,016 | public static boolean match ( final String stringToMatch , final String suffixes [ ] ) { for ( final String suffix : suffixes ) { final int suffixesLength = suffix . length ( ) ; final int stringToMatchLength = stringToMatch . length ( ) ; final int result = stringToMatchLength - suffixesLength ; final String extensionToMatch = stringToMatch . substring ( result , stringToMatchLength ) ; final boolean equals = extensionToMatch . equalsIgnoreCase ( suffix ) ; if ( stringToMatchLength >= suffixesLength && equals ) { return true ; } } return false ; } | Checks the given String matches the given suffixes . |
15,017 | public BaseScreen getScreen ( Map < String , Object > properties ) { if ( m_topScreen == null ) m_topScreen = ( ScreenModel ) this . createTopScreen ( this . getTask ( ) , null ) ; BaseScreen screen = null ; if ( m_topScreen . getSFieldCount ( ) > 0 ) screen = ( BaseScreen ) m_topScreen . getSField ( 0 ) ; this . setProperties ( properties ) ; BaseScreen newScreen = ( BaseScreen ) m_topScreen . getScreen ( screen , this ) ; return newScreen ; } | GetScreen Method . |
15,018 | public ComponentParent createTopScreen ( Task task , Map < String , Object > properties ) { if ( properties == null ) properties = new HashMap < String , Object > ( ) ; properties . put ( ScreenModel . VIEW_TYPE , ScreenModel . XML_TYPE ) ; properties . put ( DBParams . TASK , task ) ; ComponentParent topScreen = ( ComponentParent ) BaseField . createScreenComponent ( ScreenModel . TOP_SCREEN , null , null , null , 0 , properties ) ; return topScreen ; } | CreateTopScreen Method . |
15,019 | private URI makeURI ( final String service , final Map < String , String > parameters ) { try { StringBuilder queryStringBuilder = new StringBuilder ( ) ; if ( apiBaseUri . getQuery ( ) != null ) { queryStringBuilder . append ( apiBaseUri . getQuery ( ) ) . append ( "&" ) ; } queryStringBuilder . append ( "srv=" ) . append ( service ) ; for ( Map . Entry < String , String > entry : parameters . entrySet ( ) ) { queryStringBuilder . append ( "&" ) . append ( entry . getKey ( ) ) . append ( "=" ) . append ( entry . getValue ( ) ) ; } return new URI ( apiBaseUri . getScheme ( ) , apiBaseUri . getAuthority ( ) , apiBaseUri . getPath ( ) , queryStringBuilder . toString ( ) , apiBaseUri . getFragment ( ) ) ; } catch ( URISyntaxException e ) { throw new AssertionError ( "Could not construct API URI" , e ) ; } } | Build the URI for a particular service call . |
15,020 | private < T extends CCBAPIResponse > T makeRequest ( final String api , final Map < String , String > params , final String form , final Class < T > clazz ) throws IOException { byte [ ] payload = null ; if ( form != null ) { payload = form . getBytes ( StandardCharsets . UTF_8 ) ; } final InputStream entity = httpClient . sendPostRequest ( makeURI ( api , params ) , payload ) ; try { T response = xmlBinder . bindResponseXML ( entity , clazz ) ; if ( response . getErrors ( ) != null && response . getErrors ( ) . size ( ) > 0 ) { throw new CCBErrorResponseException ( response . getErrors ( ) ) ; } return response ; } finally { if ( entity != null ) { entity . close ( ) ; } } } | Send a request to CCB . |
15,021 | public String getDestination ( TrxMessageHeader trxMessageHeader ) { String strDest = ( String ) trxMessageHeader . get ( TrxMessageHeader . DESTINATION_PARAM ) ; return strDest ; } | Get the message destination address |
15,022 | public static void addCompleter ( BiConsumer < Map < Object , Object > , Long > completer ) { Thread currentThread = Thread . currentThread ( ) ; if ( currentThread instanceof TaggableThread ) { TaggableThread taggableThread = ( TaggableThread ) currentThread ; taggableThread . addMe ( completer ) ; } } | Add a completer whose parameters are tag map and elapsed time in milliseconds . After thread run completers are called . |
15,023 | public static void tag ( Object key , Object value ) { Thread currentThread = Thread . currentThread ( ) ; if ( currentThread instanceof TaggableThread ) { TaggableThread taggableThread = ( TaggableThread ) currentThread ; taggableThread . tagMe ( key , value ) ; } } | Adds a tag if current thread is TaggableThread otherwise does nothing . |
15,024 | public final void pagedExecute ( String queryId , LogicalWorkflow workflow , IResultHandler resultHandler , int pageSize ) throws ConnectorException { Long time = null ; try { for ( LogicalStep project : workflow . getInitialSteps ( ) ) { ClusterName clusterName = ( ( Project ) project ) . getClusterName ( ) ; connectionHandler . startJob ( clusterName . getName ( ) ) ; } if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Async paged Executing [" + workflow . toString ( ) + "] : queryId [" + queryId + "]" ) ; } time = System . currentTimeMillis ( ) ; pagedExecuteWorkFlow ( queryId , workflow , resultHandler , pageSize ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "The async query [" + queryId + "] has ended" ) ; } } finally { for ( LogicalStep project : workflow . getInitialSteps ( ) ) { connectionHandler . endJob ( ( ( Project ) project ) . getClusterName ( ) . getName ( ) ) ; } if ( time != null ) { logger . info ( "TIME - The execute time to paged executed with queryId [" + queryId + "] has been [" + ( System . currentTimeMillis ( ) - time ) + "]" ) ; } } } | This method execute a async and paged query . |
15,025 | public final QueryResult execute ( String queryId , LogicalWorkflow workflow ) throws ConnectorException { QueryResult result = null ; Long time = null ; try { for ( LogicalStep project : workflow . getInitialSteps ( ) ) { ClusterName clusterName = ( ( Project ) project ) . getClusterName ( ) ; connectionHandler . startJob ( clusterName . getName ( ) ) ; } if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Executing [" + workflow . toString ( ) + "]" ) ; } time = System . currentTimeMillis ( ) ; result = executeWorkFlow ( workflow ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "The query has finished. The result form the query [" + workflow . toString ( ) + "] has returned " + "[" + result . getResultSet ( ) . size ( ) + "] rows" ) ; } } finally { for ( LogicalStep project : workflow . getInitialSteps ( ) ) { connectionHandler . endJob ( ( ( Project ) project ) . getClusterName ( ) . getName ( ) ) ; } if ( time != null ) { logger . info ( "TIME - The execute time has been [" + ( System . currentTimeMillis ( ) - time ) + "]" ) ; } } return result ; } | This method execute a query . |
15,026 | public IndexMetadataBuilder addColumn ( String columnName , ColumnType colType ) { ColumnName colName = new ColumnName ( tableName , columnName ) ; ColumnMetadata colMetadata = new ColumnMetadata ( colName , null , colType ) ; columns . put ( colName , colMetadata ) ; return this ; } | Add column . Parameters in columnMetadata will be null . |
15,027 | public IndexMetadataBuilder addOption ( String option , Boolean value ) { if ( options == null ) { options = new HashMap < Selector , Selector > ( ) ; } options . put ( new StringSelector ( option ) , new BooleanSelector ( value ) ) ; return this ; } | Adds a new boolean option . |
15,028 | public Map getProperties ( ) { Map properties = super . getProperties ( ) ; if ( m_propertiesForFilter != null ) properties . putAll ( m_propertiesForFilter ) ; return properties ; } | Get the properties for this filter . |
15,029 | public Field [ ] getAllFields ( Object o ) { Field [ ] fields = o . getClass ( ) . getDeclaredFields ( ) ; AccessibleObject . setAccessible ( fields , true ) ; return fields ; } | Returns all declared Fields on Object o as accessible . |
15,030 | public Method [ ] getAllMethods ( Object o ) { Method [ ] methods = o . getClass ( ) . getDeclaredMethods ( ) ; AccessibleObject . setAccessible ( methods , true ) ; return methods ; } | Returns all declared Methods on Object o as accessible . |
15,031 | public Object getField ( Object o , String fieldName ) throws NoSuchFieldException , IllegalAccessException { Field field = o . getClass ( ) . getDeclaredField ( fieldName ) ; field . setAccessible ( true ) ; return field . get ( o ) ; } | Gets the specified field on Object o even if that field is not normally accessible . Only fields declared on the class for Object o can be accessed . |
15,032 | public void setField ( Object o , String fieldName , Object value ) throws NoSuchFieldException , IllegalAccessException { Field field = o . getClass ( ) . getDeclaredField ( fieldName ) ; field . setAccessible ( true ) ; field . set ( o , value ) ; } | Sets the specified field on Object o to the specified value even if that field is not normally accessible . Only fields declared on the class for Object o can be accessed . |
15,033 | public void init ( Record record , String strName , int iDataLength , String strDesc , Object strDefault ) { super . init ( record , strName , DBConstants . DEFAULT_FIELD_LENGTH , strDesc , strDefault ) ; if ( iDataLength == DBConstants . DEFAULT_FIELD_LENGTH ) m_iFakeFieldLength = 24 ; else m_iFakeFieldLength = iDataLength ; } | Initialize the member fields . |
15,034 | public static void filterInnerPoints ( DenseMatrix64F points , DenseMatrix64F center , int minLeft , double percent ) { assert points . numCols == 2 ; assert center . numCols == 1 ; assert center . numRows == 2 ; if ( percent <= 0 || percent >= 1 ) { throw new IllegalArgumentException ( "percent " + percent + " is not between 0 & 1" ) ; } DistComp dc = new DistComp ( center . data [ 0 ] , center . data [ 1 ] ) ; Matrices . sort ( points , dc ) ; int rows = points . numRows ; double [ ] d = points . data ; double limit = dc . distance ( d [ 0 ] , d [ 1 ] ) * percent ; for ( int r = minLeft ; r < rows ; r ++ ) { double distance = dc . distance ( d [ 2 * r ] , d [ 2 * r + 1 ] ) ; if ( distance < limit ) { points . reshape ( r / 2 , 2 , true ) ; break ; } } } | Filters points which are closes to the last estimated tempCenter . |
15,035 | public static double meanCenter ( DenseMatrix64F points , DenseMatrix64F center ) { assert points . numCols == 2 ; assert center . numCols == 1 ; assert center . numRows == 2 ; center . zero ( ) ; int count = points . numRows ; double [ ] d = points . data ; for ( int i = 0 ; i < count ; i ++ ) { center . add ( 0 , 0 , d [ 2 * i ] ) ; center . add ( 1 , 0 , d [ 2 * i + 1 ] ) ; } if ( count > 0 ) { divide ( center , count ) ; DenseMatrix64F di = new DenseMatrix64F ( points . numRows , 1 ) ; computeDi ( center , points , di ) ; return elementSum ( di ) / ( double ) points . numRows ; } else { return Double . NaN ; } } | Calculates mean tempCenter of points |
15,036 | public static double initialCenter ( DenseMatrix64F points , DenseMatrix64F center ) { assert points . numCols == 2 ; assert center . numCols == 1 ; assert center . numRows == 2 ; center . zero ( ) ; int count = 0 ; int len1 = points . numRows ; int len2 = len1 - 1 ; int len3 = len2 - 1 ; for ( int i = 0 ; i < len3 ; i ++ ) { for ( int j = i + 1 ; j < len2 ; j ++ ) { for ( int k = j + 1 ; k < len1 ; k ++ ) { if ( center ( points , i , j , k , center ) ) { count ++ ; } } } } if ( count > 0 ) { divide ( center , count ) ; DenseMatrix64F di = new DenseMatrix64F ( points . numRows , 1 ) ; computeDi ( center , points , di ) ; return elementSum ( di ) / ( double ) points . numRows ; } else { return Double . NaN ; } } | Calculates an initial estimate for tempCenter . |
15,037 | public static File writeToFile ( InputStream inputStream , File file ) throws IOException { try ( RandomAccessFile raf = new RandomAccessFile ( file , "rw" ) ) { ReadableByteChannel inputChannel = Channels . newChannel ( inputStream ) ; FileChannel fileChannel = raf . getChannel ( ) ; fastChannelCopy ( inputChannel , fileChannel ) ; } return file ; } | Writes from an InputStream to a file |
15,038 | public static File writeToTempFile ( InputStream inputStream , String prefix , String suffix ) throws IOException { File file = File . createTempFile ( prefix , "." + suffix ) ; writeToFile ( inputStream , file ) ; return file ; } | Writes from an InputStream to a temporary file |
15,039 | public static File writeToTempFile ( String buf , String prefix , String suffix ) throws IOException { InputStream is = new ByteArrayInputStream ( buf . getBytes ( "UTF-8" ) ) ; return writeToTempFile ( is , prefix , suffix ) ; } | Writes from a String to a temporary file |
15,040 | public void scanProjects ( int parentProjectID ) { ClassProject classProject = new ClassProject ( this ) ; try { classProject . addNew ( ) ; classProject . setKeyArea ( ClassProject . ID_KEY ) ; classProject . getField ( ClassProject . ID ) . setValue ( parentProjectID ) ; if ( classProject . seek ( null ) ) { if ( isBaseDatabase ( classProject ) ) this . scanAllPackages ( classProject ) ; } IntegerField field = new IntegerField ( null , null , - 1 , null , null ) ; field . setValue ( parentProjectID ) ; classProject . addNew ( ) ; classProject . close ( ) ; classProject . setKeyArea ( ClassProject . PARENT_FOLDER_ID_KEY ) ; classProject . addListener ( new SubFileFilter ( field , ClassProject . PARENT_FOLDER_ID , null , null , null , null ) ) ; while ( classProject . hasNext ( ) ) { classProject . next ( ) ; this . scanProjects ( ( int ) classProject . getField ( ClassProject . ID ) . getValue ( ) ) ; } field . free ( ) ; } catch ( DBException e ) { e . printStackTrace ( ) ; } finally { classProject . free ( ) ; } } | ScanProjects Method . |
15,041 | public void scanAllPackages ( ClassProject classProject ) { this . setProperty ( "projectID" , classProject . getField ( ClassProject . ID ) . toString ( ) ) ; this . scanPackages ( classProject , ClassProject . CodeType . RESOURCE_CODE ) ; this . scanPackages ( classProject , ClassProject . CodeType . RESOURCE_PROPERTIES ) ; this . scanPackages ( classProject , ClassProject . CodeType . THIN ) ; this . scanPackages ( classProject , ClassProject . CodeType . INTERFACE ) ; this . scanPackages ( classProject , ClassProject . CodeType . THICK ) ; } | ScanAllPackages Method . |
15,042 | public void scanPackages ( ClassProject classProject , ClassProject . CodeType codeType ) { String projectClassDirectory = classProject . getFileName ( null , null , codeType , true , false ) ; Packages recPackages = ( Packages ) this . getMainRecord ( ) ; Map < String , Object > prop = new HashMap < String , Object > ( ) ; prop . put ( ConvertCode . SOURCE_DIR , projectClassDirectory ) ; prop . put ( ConvertCode . DEST_DIR , null ) ; prop . put ( "codeType" , codeType ) ; Task taskParent = this . getTask ( ) ; ConvertCode convert = new ConvertCode ( taskParent , null , prop ) ; convert . setScanListener ( new PackagesScanListener ( convert , recPackages ) ) ; convert . run ( ) ; } | ScanPackages Method . |
15,043 | public boolean isBaseDatabase ( Record record ) { BaseDatabase database = record . getTable ( ) . getDatabase ( ) ; boolean isBaseDB = true ; int counter = ( int ) record . getCounterField ( ) . getValue ( ) ; String startingID = database . getProperty ( BaseDatabase . STARTING_ID ) ; String endingID = database . getProperty ( BaseDatabase . ENDING_ID ) ; if ( startingID != null ) if ( counter < Integer . parseInt ( Converter . stripNonNumber ( startingID ) ) ) isBaseDB = false ; if ( endingID != null ) if ( counter > Integer . parseInt ( Converter . stripNonNumber ( endingID ) ) ) isBaseDB = false ; return isBaseDB ; } | IsBaseDatabase Method . |
15,044 | public String getFieldDesc ( ) { if ( m_convDescField != null ) return m_convDescField . getFieldDesc ( ) ; if ( ( m_strAltDesc == null ) || ( m_strAltDesc . length ( ) == 0 ) ) return super . getFieldDesc ( ) ; else return m_strAltDesc ; } | Get the field description . |
15,045 | protected String [ ] getLibEntries ( String dir ) { String [ ] entries = new String [ 0 ] ; File libdir = new File ( dir ) ; if ( libdir . exists ( ) && libdir . isDirectory ( ) ) { entries = libdir . list ( ) ; } return entries ; } | Returns a list of entries in the given directory . This method is separated so that unit tests can override it to return test - friendly file names . |
15,046 | public void free ( ) { if ( m_recordOwnerCollection != null ) m_recordOwnerCollection . free ( ) ; m_recordOwnerCollection = null ; if ( m_messageFilterList != null ) m_messageFilterList . free ( ) ; m_messageFilterList = null ; if ( m_vRecordList != null ) m_vRecordList . free ( this ) ; m_vRecordList = null ; if ( m_databaseCollection != null ) m_databaseCollection . free ( ) ; m_databaseCollection = null ; if ( m_sessionObjectParent != null ) m_sessionObjectParent . removeRecordOwner ( this ) ; m_sessionObjectParent = null ; } | Free this remote record owner . Also explicitly unexports the RMI object . |
15,047 | public static String embed ( final String expression , final char trigger ) { return new StringBuilder ( ) . append ( trigger ) . append ( '{' ) . append ( strip ( expression ) ) . append ( '}' ) . toString ( ) ; } | Embed the specified expression if necessary using the specified triggering character . |
15,048 | public static char getTrigger ( final String delimitedExpression ) { final String expr = StringUtils . trimToEmpty ( delimitedExpression ) ; Validate . isTrue ( isDelimited ( expr ) ) ; return expr . charAt ( 0 ) ; } | Get the trigger character for the specified delimited expression . |
15,049 | public static String strip ( final String expression ) { final String expr = StringUtils . trimToEmpty ( expression ) ; final Matcher matcher = DELIMITED_EXPR . matcher ( expr ) ; return matcher . matches ( ) ? matcher . group ( 1 ) : expr ; } | Strip any delimiter from the specified expression . |
15,050 | public static String join ( final char trigger , final String ... expressions ) { Validate . notEmpty ( expressions ) ; final StringBuilder buf = new StringBuilder ( ) ; for ( String expression : expressions ) { final String stripped = strip ( expression ) ; if ( expression . isEmpty ( ) ) { continue ; } final int len = buf . length ( ) ; if ( len > 0 ) { final int end = len - 1 ; final char last = buf . charAt ( end ) ; final char first = stripped . charAt ( 0 ) ; switch ( first ) { case DOT : case LBRACK : if ( last == DOT ) { buf . deleteCharAt ( end ) ; } break ; default : if ( last != DOT ) { buf . append ( DOT ) ; } break ; } } buf . append ( stripped ) ; } return embed ( buf . toString ( ) , trigger ) ; } | Join expressions using the specified trigger character . |
15,051 | public static < T > T coerceToType ( ELContext context , Class < T > toType , Object object ) { @ SuppressWarnings ( "unchecked" ) T result = ( T ) getExpressionFactory ( context ) . coerceToType ( object , toType ) ; return result ; } | Use EL specification coercion facilities to coerce an object to the specified type . |
15,052 | private org . hibernate . Query query ( String hql , Class < ? > ... type ) { org . hibernate . Query q = session . createQuery ( hql ) ; for ( int i = 0 ; i < positionedParameters . length ; i ++ ) { q . setParameter ( i , positionedParameters [ i ] ) ; } for ( Map . Entry < String , Object > entry : namedParameters . entrySet ( ) ) { Object value = entry . getValue ( ) ; if ( Types . isArray ( value ) ) { Object [ ] parameter = ( Object [ ] ) value ; if ( parameter . length == 0 ) { throw new HibernateException ( String . format ( "Invalid named parameter |%s|. Empty array." , entry . getKey ( ) ) ) ; } q . setParameterList ( entry . getKey ( ) , parameter ) ; } else if ( Types . isCollection ( value ) ) { Collection < ? > parameter = ( Collection < ? > ) value ; if ( parameter . isEmpty ( ) ) { throw new HibernateException ( String . format ( "Invalid named parameter |%s|. Empty list." , entry . getKey ( ) ) ) ; } q . setParameterList ( entry . getKey ( ) , parameter ) ; } else { q . setParameter ( entry . getKey ( ) , value ) ; } } if ( offset > 0 ) { q . setFirstResult ( offset ) ; } if ( rowsCount > 0 ) { q . setMaxResults ( rowsCount ) ; } if ( type . length > 0 ) { q . setResultTransformer ( Transformers . aliasToBean ( type [ 0 ] ) ) ; } return q ; } | Create Hibernate query object and initialize it from this helper properties . |
15,053 | public static AbstractMatrix getInstance ( int rows , int cols , Class < ? > cls ) { return new AbstractMatrix ( rows , Array . newInstance ( cls , rows * cols ) ) ; } | Returns new DoubleMatrix initialized to zeroes . |
15,054 | public void swapRows ( int r1 , int r2 , Object tmp ) { int col = columns ( ) ; System . arraycopy ( array , col * r1 , tmp , 0 , col ) ; System . arraycopy ( array , col * r2 , array , col * r1 , col ) ; System . arraycopy ( tmp , 0 , array , col * r2 , col ) ; } | Swaps row r1 and r2 possibly using tmp |
15,055 | public void classifyTree ( Area root , FeatureExtractor features ) { if ( classifier != null ) { System . out . print ( "tree visual classification..." ) ; testRoot = root ; this . features = features ; testset = new Instances ( trainset , 0 ) ; mapping = new HashMap < Area , Instance > ( ) ; recursivelyExtractAreaData ( testRoot ) ; System . out . println ( "done" ) ; } } | Classifies the areas in an area tree . |
15,056 | private Subquery < ImageFile > getImagesWithFileNameSubquery ( final String filename , final FilterStringLogic searchLogic ) { final CriteriaBuilder criteriaBuilder = getCriteriaBuilder ( ) ; final Subquery < ImageFile > subQuery = getCriteriaQuery ( ) . subquery ( ImageFile . class ) ; final Root < LanguageImage > root = subQuery . from ( LanguageImage . class ) ; subQuery . select ( root . get ( "imageFile" ) . as ( ImageFile . class ) ) ; final Predicate imageIdMatch = criteriaBuilder . equal ( getRootPath ( ) . get ( "imageFileId" ) , root . get ( "imageFile" ) . get ( "imageFileId" ) ) ; final Predicate filenameMatch ; if ( searchLogic == FilterStringLogic . MATCHES ) { filenameMatch = criteriaBuilder . equal ( root . get ( "originalFileName" ) , filename ) ; } else { filenameMatch = criteriaBuilder . like ( criteriaBuilder . lower ( root . get ( "originalFileName" ) . as ( String . class ) ) , '%' + cleanLikeCondition ( filename ) . toLowerCase ( ) + '%' ) ; } subQuery . where ( criteriaBuilder . and ( imageIdMatch , filenameMatch ) ) ; return subQuery ; } | Create a Subquery to check if a image has a specific filename . |
15,057 | protected void connectionClosed ( IoSession session ) { this . connected = false ; this . _disconnect ( ) ; log . info ( "Connection lost to aggregator at {}:{}" , this . host , Integer . valueOf ( this . port ) ) ; while ( this . stayConnected ) { try { Thread . sleep ( this . connectionRetryDelay ) ; } catch ( InterruptedException ie ) { } log . warn ( "Reconnecting to aggregator at {}:{}" , this . host , Integer . valueOf ( this . port ) ) ; if ( this . connect ( this . connectionTimeout ) ) { return ; } log . warn ( "Failed to reconnect to aggregator at {}:{}" , this . host , Integer . valueOf ( this . port ) ) ; } this . finishConnection ( ) ; } | Called when the connection to the aggregator closes . |
15,058 | protected void handshakeReceived ( IoSession session , HandshakeMessage handshakeMessage ) { log . debug ( "Received {}" , handshakeMessage ) ; this . receivedHandshake = handshakeMessage ; Boolean handshakeCheck = this . checkHandshake ( ) ; if ( handshakeCheck == null ) { return ; } if ( Boolean . FALSE . equals ( handshakeCheck ) ) { log . warn ( "Handshakes did not match." ) ; this . _disconnect ( ) ; } if ( Boolean . TRUE . equals ( handshakeCheck ) ) { SubscriptionMessage msg = this . generateGenericSubscriptionMessage ( ) ; this . session . write ( msg ) ; this . connected = true ; } } | Called when a handshake message is received from the aggregator . |
15,059 | protected SubscriptionMessage generateGenericSubscriptionMessage ( ) { SubscriptionMessage subMessage = new SubscriptionMessage ( ) ; subMessage . setRules ( this . rules ) ; subMessage . setMessageType ( SubscriptionMessage . SUBSCRIPTION_MESSAGE_ID ) ; return subMessage ; } | Creates a generic subscription message with the rules defined within this interface . |
15,060 | protected void solverSampleReceived ( IoSession session , SampleMessage sampleMessage ) { for ( SampleListener listener : this . sampleListeners ) { listener . sampleReceived ( this , sampleMessage ) ; } } | Called when a sample is received from the aggregator . |
15,061 | protected void subscriptionRequestSent ( IoSession session , SubscriptionMessage subscriptionMessage ) { this . sentSubscription = subscriptionMessage ; log . info ( "Sent {}" , subscriptionMessage ) ; } | Called after a subscription request message is sent to the aggregator . |
15,062 | protected void subscriptionResponseReceived ( IoSession session , SubscriptionMessage subscriptionMessage ) { log . info ( "Received {}" , subscriptionMessage ) ; this . receivedSubscription = subscriptionMessage ; if ( this . sentSubscription == null ) { log . error ( "Protocol error: Received a subscription response without sending a request.\n{}" , subscriptionMessage ) ; this . _disconnect ( ) ; return ; } if ( ! this . sentSubscription . equals ( this . receivedSubscription ) ) { log . info ( "Server did not fully accept subscription request.\nOriginal:\n{}\nAmended\n{}" , this . sentSubscription , this . receivedSubscription ) ; } for ( ConnectionListener listener : this . connectionListeners ) { listener . subscriptionReceived ( this , subscriptionMessage ) ; } } | Called when a subscription response is received from the aggregator . |
15,063 | protected void exceptionCaught ( IoSession session , Throwable cause ) { log . error ( "Unhandled exception for: " + String . valueOf ( session ) , cause ) ; if ( this . disconnectOnException ) { this . _disconnect ( ) ; } } | Called when an exception occurs on the session |
15,064 | public StoreSchema getStore ( final String name ) { for ( StoreSchema store : storeSchemas ) if ( store . getName ( ) . equals ( name ) ) return store ; return null ; } | Returns the schema for the stores on this annotation class whose name matches the provided name . This method returns null if no field matches . |
15,065 | public static void modify ( int calleeValKind , Object callee , String calleeClass , String fieldName , int callerValKind , Object caller , String callerClass ) { System . err . println ( "modify( " + valAndValKindToString ( callee , calleeClass , calleeValKind ) + " . " + fieldName + ", " + "caller=" + valAndValKindToString ( caller , callerClass , callerValKind ) + ", " + ")" ) ; } | an object WRITES a primitive field of another object |
15,066 | public void getPrice ( BaseMessage message ) { String strPrice = ( String ) message . get ( "hotelRate" ) ; System . out . println ( "Price: " + strPrice ) ; String strItem = ( String ) message . get ( "correlationID" ) ; int iHash = - 1 ; try { iHash = Integer . parseInt ( strItem ) ; } catch ( NumberFormatException ex ) { } if ( iHash != - 1 ) { CalendarProduct m_productItem = null ; for ( int i = 0 ; i < m_model . getRowCount ( ) ; i ++ ) { if ( m_model . getItem ( i ) . hashCode ( ) == iHash ) m_productItem = ( CalendarProduct ) m_model . getItem ( i ) ; } if ( m_productItem != null ) m_productItem . setStatus ( m_productItem . getStatus ( ) & ~ ( 1 << 2 ) ) ; } } | Get the price of this product . |
15,067 | public < A > void listen ( Class < A > key , VoidEvent < A > value ) { map . wire ( key , value ) ; } | Add void listener |
15,068 | static public Bus getBy ( String busName ) { if ( busName == null ) return get ( ) ; Bus bus = busMap . get ( busName ) ; if ( bus == null ) { bus = new Bus ( ) ; busMap . put ( busName , bus ) ; } return bus ; } | Get bus instance by name |
15,069 | static public Bus getBy ( Class < ? > busName ) { if ( busName == null ) return get ( ) ; return getBy ( busName . getName ( ) ) ; } | Get bus instance by class name |
15,070 | static public Bus getBy ( Object busName ) { if ( busName == null ) return get ( ) ; return getBy ( busName . getClass ( ) ) ; } | Get bus instance by object class name |
15,071 | public void setOwner ( ListenerOwner owner ) { super . setOwner ( owner ) ; if ( owner == null ) return ; if ( ( m_strFieldNameToCheck != null ) && ( m_strFieldNameToCheck . length ( ) > 0 ) ) if ( ( m_fldToCheck == null ) || ( m_fldToCheck . getFieldName ( ) == null ) || ( m_fldToCheck . getFieldName ( ) . length ( ) == 0 ) ) m_fldToCheck = this . getOwner ( ) . getField ( m_strFieldNameToCheck ) ; if ( m_fldToCompare != null ) if ( m_fldToCompare . getRecord ( ) != this . getOwner ( ) ) m_fldToCompare . addListener ( new FieldRemoveBOnCloseHandler ( this ) ) ; if ( m_fldToCheck != null ) if ( m_fldToCheck . getRecord ( ) != this . getOwner ( ) ) m_fldToCheck . addListener ( new FieldRemoveBOnCloseHandler ( this ) ) ; } | Set the field or file that owns this listener . Besides inherited this method closes the owner record . |
15,072 | public int getMessageLength ( ) { int length = 1 ; if ( this . matchingIds != null ) { for ( String id : this . matchingIds ) { try { length += 4 ; length += id . getBytes ( "UTF-16BE" ) . length ; } catch ( UnsupportedEncodingException uee ) { log . error ( "Unable to encode UTF-16BE String: {}" , uee ) ; } } } return length ; } | Gets the length of this message when encoded according to the Client - World Model protocol . |
15,073 | public int getRelativeSField ( int iSFieldSeq ) { Convert lastField = null ; for ( int i = 0 ; i < m_gridScreen . getSFieldCount ( ) ; i ++ ) { Convert field = m_gridScreen . getSField ( i ) . getConverter ( ) ; if ( field != null ) field = field . getField ( ) ; if ( m_gridScreen . getSField ( i ) instanceof ToolScreen ) field = null ; if ( ( field != null ) && ( field != lastField ) ) iSFieldSeq -- ; lastField = field ; if ( iSFieldSeq < 0 ) return i ; } return m_gridScreen . getSFieldCount ( ) - 1 ; } | This is lame . |
15,074 | public static void main ( final String [ ] args ) { Utils4Swing . initSystemLookAndFeel ( ) ; final Cancelable cancelable = new CancelableVolatile ( ) ; final FileCopyProgressMonitor monitor = new FileCopyProgressMonitor ( cancelable , "Copy Test" , 10 ) ; monitor . open ( ) ; try { for ( int i = 0 ; i < 10 ; i ++ ) { if ( cancelable . isCanceled ( ) ) { break ; } final int n = i + 1 ; final String fileName = "file" + n + ".jar" ; final int fileSize = n * 10 ; final String sourceFilename = "http://www.fuin.org/demo-app/" + fileName ; final String targetFilename = "/program files/demo app/" + fileName ; monitor . updateFile ( sourceFilename , targetFilename , n , fileSize ) ; for ( int j = 0 ; j < fileSize ; j ++ ) { monitor . updateByte ( j + 1 ) ; sleep ( 100 ) ; } } } finally { monitor . close ( ) ; } } | Main method to test the monitor . Only for testing purposes . |
15,075 | public void free ( ) { CalendarPanel panel = ( CalendarPanel ) JBasePanel . getSubScreen ( this , CalendarPanel . class ) ; if ( panel != null ) panel . free ( ) ; super . free ( ) ; } | Free the sub = components . |
15,076 | public CalendarModel getCalendarModel ( FieldTable table ) { if ( m_model == null ) if ( table != null ) m_model = new CalendarThinTableModel ( table ) ; return m_model ; } | Get the calendar model . Override this to supply the calendar model . The default listener wraps the table in a CalendarThinTableModel . |
15,077 | public void propertyChange ( PropertyChangeEvent evt ) { String strProperty = evt . getPropertyName ( ) ; if ( this . isValidProperty ( strProperty ) ) { Object objCurrentValue = this . get ( strProperty ) ; if ( evt . getNewValue ( ) != objCurrentValue ) { m_strCurrentProperty = strProperty ; if ( evt . getNewValue ( ) != null ) this . put ( strProperty , evt . getNewValue ( ) ) ; else this . remove ( strProperty ) ; if ( propertyChange != null ) propertyChange . firePropertyChange ( evt ) ; m_strCurrentProperty = null ; } } } | This method gets called when a bound property is changed . Propogate the event to all listeners . |
15,078 | public Map < String , Object > getProperties ( ) { Map < String , Object > properties = new Hashtable < String , Object > ( ) ; ParamDispatcher params = this ; for ( Enumeration < String > e = params . keys ( ) ; e . hasMoreElements ( ) ; ) { String strKey = e . nextElement ( ) ; String strValue = params . get ( strKey ) . toString ( ) ; properties . put ( strKey , strValue ) ; } return properties ; } | Get the current parameters for this screen . Convert the params to strings and place them in a properties object . |
15,079 | public boolean isValidProperty ( String strProperty ) { if ( m_rgstrValidParams != null ) { for ( int i = 0 ; i < m_rgstrValidParams . length ; i ++ ) { if ( m_rgstrValidParams [ i ] . equalsIgnoreCase ( strProperty ) ) { if ( m_strCurrentProperty != strProperty ) { return true ; } } } } return false ; } | This method gets called when a bound property is changed . Propagate the event to all listeners . |
15,080 | public void firePropertyChange ( String propertyName , Object oldValue , Object newValue ) { if ( propertyChange != null ) propertyChange . firePropertyChange ( propertyName , oldValue , newValue ) ; } | The firePropertyChange method was generated to support the propertyChange field . |
15,081 | public Angle add ( Angle angle , boolean clockwice ) { if ( clockwice ) { return new Angle ( normalizeToFullAngle ( value + angle . value ) ) ; } else { return new Angle ( normalizeToFullAngle ( value - angle . value ) ) ; } } | Add angle clockwise or counter clockwice . |
15,082 | public Angle turn ( Angle angle ) { if ( angle . getRadians ( ) < Math . PI ) { return add ( angle , true ) ; } else { return add ( angle . toHalfAngle ( ) , false ) ; } } | Turn angle clockwise or counter clockwice . If < ; 180 turns clockwice . If &ge ; 180 turns counter clockwice 360 - angle |
15,083 | public final boolean inSector ( Angle start , Angle end ) { if ( start . clockwise ( end ) ) { return ! clockwise ( start ) && clockwise ( end ) ; } else { return clockwise ( start ) && ! clockwise ( end ) ; } } | Sector is less than 180 degrees delimited by start and end |
15,084 | public static final Angle difference ( Angle a1 , Angle a2 ) { return new Angle ( normalizeToHalfAngle ( angleDiff ( a1 . value , a2 . value ) ) ) ; } | The difference between two angles |
15,085 | public static final boolean clockwise ( Angle angle1 , Angle angle2 ) { return clockwise ( angle1 . value , angle2 . value ) ; } | 10 is clockwise from 340 |
15,086 | public static final double signed ( double angle ) { angle = normalizeToFullAngle ( angle ) ; if ( angle > Math . PI ) { return angle - FULL_CIRCLE ; } else { return angle ; } } | Convert full angle to signed angle - 180 - 180 . 340 - > ; - 20 |
15,087 | public static UserInfo getUserInfo ( final String userId ) { if ( userId == null ) { throw new IllegalArgumentException ( "null userName" ) ; } try { Class < ? > accessor = Class . forName ( "com.sap.security.um.service.UserManagementAccessor" ) ; if ( accessor != null ) { Object users = MethodUtils . invokeExactStaticMethod ( accessor , "getUserProvider" , null ) ; if ( users != null ) { Object user = MethodUtils . invokeExactMethod ( users , "getUser" , userId ) ; if ( user != null ) { return new User ( userId , ( String ) MethodUtils . invokeExactMethod ( user , "getAttribute" , "firstname" ) , ( String ) MethodUtils . invokeExactMethod ( user , "getAttribute" , "lastname" ) , ( String ) MethodUtils . invokeExactMethod ( user , "getAttribute" , "email" ) ) ; } } } } catch ( ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e ) { log . warn ( e . getMessage ( ) ) ; } return new User ( userId , "" , "" , "" ) ; } | never returns null |
15,088 | public Predictor method ( int method , int startPage ) { input . add ( new CommandLine < > ( METHOD , 5 , method , startPage ) ) ; return this ; } | The METHOD command defines the analysis task to be performed for a particular system configuration . |
15,089 | public Predictor execute ( KRun krun ) { input . add ( new CommandLine < > ( EXECUTE , 5 , krun . ordinal ( ) ) ) ; return this ; } | The EXECUTE command causes the program to perform the indicated analysis task for the currently defined system configuration . |
15,090 | public Predictor time ( int ihro , int ihre , int ihrs , boolean ut ) { input . add ( new CommandLine < > ( TIME , 5 , ihro , ihre , ihrs , ut ? 1 : - 1 ) ) ; return this ; } | The TIME command indicates the time of day for which the analysis and predictions are to be performed . |
15,091 | public Predictor month ( int nyear , Month ... months ) { Object [ ] arr = new Object [ months . length + 1 ] ; arr [ 0 ] = nyear ; int index = 1 ; for ( Month m : months ) { arr [ index ++ ] = Double . valueOf ( m . getValue ( ) ) ; } input . add ( new CommandLine < > ( MONTH , 5 , arr ) ) ; return this ; } | The MONTH command indicates the year and months for which the analysis and prediction are to be performed . |
15,092 | public Predictor sunspot ( double ... sunspot ) { CommandLine < Double > line = new CommandLine < > ( SUNSPOT , 5 ) ; for ( double s : sunspot ) { line . add ( s ) ; } input . add ( line ) ; return this ; } | The sunspot command line indicates the sunspot numbers of the solar activity period of interest and is the 12 - month smoothed mean for each of the months specified . |
15,093 | public Predictor label ( String itran , String ircvr ) { input . add ( new CommandLine < > ( LABEL , 20 , itran , ircvr ) ) ; return this ; } | The LABEL command contains alphanumeric information used to describe the system location on both the input and output . |
15,094 | public Predictor circuit ( Location transmitter , Location receiver , boolean shorter ) { this . receiverLocation = receiver ; input . add ( new CommandLine < > ( CIRCUIT , 5 , Math . abs ( transmitter . getLatitude ( ) ) , transmitter . getLatitudeNS ( ) , Math . abs ( transmitter . getLongitude ( ) ) , transmitter . getLongitudeWE ( ) , Math . abs ( receiver . getLatitude ( ) ) , receiver . getLatitudeNS ( ) , Math . abs ( receiver . getLongitude ( ) ) , receiver . getLongitudeWE ( ) , shorter ? 0 : 1 ) ) ; return this ; } | The CIRCUIT command contains the geographic coordinates of the transmitter and receiver and a variable to indicate the user s choice between shorter or longer great circle paths from the transmitter to the receiver . |
15,095 | public Predictor frequency ( double ... frel ) { frequencies = frel ; CommandLine < Double > line = new CommandLine < > ( FREQUENCY , 5 ) ; for ( double f : frel ) { line . add ( f ) ; } input . add ( line ) ; return this ; } | The FREQUENCY complement command line contains up to 11 user - defined frequencies that are used in the calculation . |
15,096 | public < T extends BaseBugLinkStrategy < ? > > T create ( final BugLinkType type , final String serverUrl , final Object ... additionalArgs ) { if ( ! internalsRegistered ) { registerInternals ( ) ; } if ( map . containsKey ( type ) ) { try { final SortedSet < Helper > helpers = map . get ( type ) ; T helper = null ; for ( final Helper definedHelper : helpers ) { if ( definedHelper . useHelper ( serverUrl ) ) { helper = ( T ) definedHelper . getHelperClass ( ) . newInstance ( ) ; break ; } } if ( helper != null ) { helper . initialise ( serverUrl , additionalArgs ) ; } return helper ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } else { return null ; } } | Create a strategy instance to be used for the specified type and server url . |
15,097 | public static final int call ( Path cwd , Map < String , String > env , String ... args ) throws IOException , InterruptedException { if ( args . length == 1 ) { args = args [ 0 ] . split ( "[ ]+" ) ; } String cmd = Arrays . stream ( args ) . collect ( Collectors . joining ( " " ) ) ; JavaLogging . getLogger ( OSProcess . class ) . info ( "call: %s" , cmd ) ; ProcessBuilder builder = new ProcessBuilder ( args ) ; if ( cwd != null ) { builder . directory ( cwd . toFile ( ) ) ; } if ( env != null ) { Map < String , String > environment = builder . environment ( ) ; environment . clear ( ) ; environment . putAll ( env ) ; } Process process = builder . start ( ) ; Thread stdout = new Thread ( new ProcessLogger ( cmd , process . getInputStream ( ) , Level . INFO ) ) ; stdout . start ( ) ; Thread stderr = new Thread ( new ProcessLogger ( cmd , process . getErrorStream ( ) , Level . WARNING ) ) ; stderr . start ( ) ; return process . waitFor ( ) ; } | Call os process and waits it s execution . |
15,098 | public void sessionSetup ( String project , String profile ) throws PeachApiException { stashUnirestProxy ( ) ; if ( _debug ) System . out . println ( ">>sessionSetup" ) ; try { HttpResponse < JsonNode > ret = null ; try { ret = Unirest . post ( String . format ( "%s/api/sessions" , _api ) ) . queryString ( "project" , project ) . queryString ( "profile" , profile ) . header ( _token_header , _api_token ) . asJson ( ) ; } catch ( UnirestException ex ) { Logger . getLogger ( PeachProxy . class . getName ( ) ) . log ( Level . SEVERE , "Error contacting Peach API" , ex ) ; throw new PeachApiException ( String . format ( "Error, exception contacting Peach API: %s" , ex . getMessage ( ) ) , ex ) ; } if ( ret == null ) { throw new PeachApiException ( "Error, in Proxy.sessionSetup: ret was null" , null ) ; } if ( ret . getStatus ( ) != 200 ) { String errorMsg = String . format ( "Error, /api/sessions returned status code of %s: %s" , ret . getStatus ( ) , ret . getStatusText ( ) ) ; throw new PeachApiException ( errorMsg , null ) ; } _jobid = ret . getBody ( ) . getObject ( ) . getString ( "SessionId" ) ; _proxyUrl = ret . getBody ( ) . getObject ( ) . getString ( "ProxyUrl" ) ; verifyProxyAccess ( ) ; } finally { revertUnirestProxy ( ) ; } } | Start a Peach API Security job . |
15,099 | public void sessionTeardown ( ) throws PeachApiException { stashUnirestProxy ( ) ; if ( _debug ) System . out . println ( ">>sessionTeardown" ) ; try { HttpResponse < String > ret = null ; try { ret = Unirest . delete ( String . format ( "%s/api/sessions/%s" , _api , _jobid ) ) . header ( _token_header , _api_token ) . asString ( ) ; } catch ( UnirestException ex ) { Logger . getLogger ( PeachProxy . class . getName ( ) ) . log ( Level . SEVERE , "Error contacting Peach API" , ex ) ; throw new PeachApiException ( String . format ( "Error, exception contacting Peach API: %s" , ex . getMessage ( ) ) , ex ) ; } if ( ret == null ) { throw new PeachApiException ( "Error, in Proxy.sessionTearDown: ret was null" , null ) ; } if ( ret . getStatus ( ) != 200 ) { String errorMsg = String . format ( "Error, DELETE /api/sessions/{jobid} returned status code of %s: %s" , ret . getStatus ( ) , ret . getStatusText ( ) ) ; throw new PeachApiException ( errorMsg , null ) ; } } finally { revertUnirestProxy ( ) ; } } | Stop testing job and destroy proxy . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.