idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
19,700 | public static List < ConfigObjectRecord > readRecordFromLDAP ( final ChaiEntry ldapEntry , final String attr , final String recordType , final Set guid1 , final Set guid2 ) throws ChaiOperationException , ChaiUnavailableException { if ( ldapEntry == null ) { throw new NullPointerException ( "ldapEntry can not be null" ) ; } if ( attr == null ) { throw new NullPointerException ( "attr can not be null" ) ; } if ( recordType == null ) { throw new NullPointerException ( "recordType can not be null" ) ; } final Set < String > values = ldapEntry . readMultiStringAttribute ( attr ) ; final List < ConfigObjectRecord > cors = new ArrayList < ConfigObjectRecord > ( ) ; for ( final String value : values ) { final ConfigObjectRecord loopRec = parseString ( value ) ; loopRec . objectEntry = ldapEntry ; loopRec . attr = attr ; cors . add ( loopRec ) ; if ( ! loopRec . getRecordType ( ) . equalsIgnoreCase ( recordType ) ) { cors . remove ( loopRec ) ; } else if ( guid1 != null && ! guid1 . contains ( loopRec . getGuid1 ( ) ) ) { cors . remove ( loopRec ) ; } else if ( guid2 != null && ! guid2 . contains ( loopRec . getGuid2 ( ) ) ) { cors . remove ( loopRec ) ; } } return cors ; } | Retreive matching config object records from the directory . |
19,701 | public static ChaiGroup createGroup ( final String parentDN , final String name , final ChaiProvider provider ) throws ChaiOperationException , ChaiUnavailableException { final String objectCN = findUniqueName ( name , parentDN , provider ) ; final StringBuilder entryDN = new StringBuilder ( ) ; entryDN . append ( "cn=" ) ; entryDN . append ( objectCN ) ; entryDN . append ( ',' ) ; entryDN . append ( parentDN ) ; provider . createEntry ( entryDN . toString ( ) , ChaiConstant . OBJECTCLASS_BASE_LDAP_GROUP , Collections . emptyMap ( ) ) ; final ChaiEntry theObject = provider . getEntryFactory ( ) . newChaiEntry ( entryDN . toString ( ) ) ; theObject . writeStringAttribute ( ChaiConstant . ATTR_LDAP_DESCRIPTION , name ) ; return provider . getEntryFactory ( ) . newChaiGroup ( entryDN . toString ( ) ) ; } | Creates a new group entry in the ldap directory . A new groupOfNames object is created . The cn and description ldap attributes are set to the supplied name . |
19,702 | public static String findUniqueName ( final String baseName , final String containerDN , final ChaiProvider provider ) throws ChaiOperationException , ChaiUnavailableException { char ch ; final StringBuilder cnStripped = new StringBuilder ( ) ; final String effectiveBasename = ( baseName == null ) ? "" : baseName ; for ( int i = 0 ; i < effectiveBasename . length ( ) ; i ++ ) { ch = effectiveBasename . charAt ( i ) ; if ( Character . isLetterOrDigit ( ch ) ) { cnStripped . append ( ch ) ; } } if ( cnStripped . length ( ) == 0 ) { cnStripped . append ( System . currentTimeMillis ( ) ) ; } String uniqueCN ; StringBuilder filter ; final Random randomNumber = new Random ( ) ; String stringCounter = null ; int counter = randomNumber . nextInt ( ) % 1000 ; while ( true ) { filter = new StringBuilder ( 64 ) ; if ( stringCounter != null ) { uniqueCN = cnStripped . append ( stringCounter ) . toString ( ) ; } else { uniqueCN = cnStripped . toString ( ) ; } filter . append ( "(" ) . append ( ChaiConstant . ATTR_LDAP_COMMON_NAME ) . append ( "=" ) . append ( uniqueCN ) . append ( ")" ) ; final Map < String , Map < String , String > > results = provider . search ( containerDN , filter . toString ( ) , null , SearchScope . ONE ) ; if ( results . size ( ) == 0 ) { break ; } else { stringCounter = Integer . toString ( counter ++ ) ; } } return uniqueCN ; } | Derives a unique entry name for an ldap container . Assumes CN as the naming attribute . |
19,703 | public static String entryToLDIF ( final ChaiEntry theEntry ) throws ChaiUnavailableException , ChaiOperationException { final StringBuilder sb = new StringBuilder ( ) ; sb . append ( "dn: " ) . append ( theEntry . getEntryDN ( ) ) . append ( "\n" ) ; final Map < String , Map < String , List < String > > > results = theEntry . getChaiProvider ( ) . searchMultiValues ( theEntry . getEntryDN ( ) , "(objectClass=*)" , null , SearchScope . BASE ) ; final Map < String , List < String > > props = results . get ( theEntry . getEntryDN ( ) ) ; for ( final Map . Entry < String , List < String > > entry : props . entrySet ( ) ) { final String attrName = entry . getKey ( ) ; final List < String > values = entry . getValue ( ) ; for ( final String value : values ) { sb . append ( attrName ) . append ( ": " ) . append ( value ) . append ( '\n' ) ; } } return sb . toString ( ) ; } | Convert to an LDIF format . Useful for debugging or other purposes |
19,704 | public static DirectoryVendor determineDirectoryVendor ( final ChaiEntry rootDSE ) throws ChaiUnavailableException , ChaiOperationException { final Set < String > interestedAttributes = new HashSet < > ( ) ; for ( final DirectoryVendor directoryVendor : DirectoryVendor . values ( ) ) { interestedAttributes . addAll ( directoryVendor . getVendorFactory ( ) . interestedDseAttributes ( ) ) ; } final SearchHelper searchHelper = new SearchHelper ( ) ; searchHelper . setAttributes ( interestedAttributes . toArray ( new String [ interestedAttributes . size ( ) ] ) ) ; searchHelper . setFilter ( "(objectClass=*)" ) ; searchHelper . setMaxResults ( 1 ) ; searchHelper . setSearchScope ( SearchScope . BASE ) ; final Map < String , Map < String , List < String > > > results = rootDSE . getChaiProvider ( ) . searchMultiValues ( "" , searchHelper ) ; if ( results != null && ! results . isEmpty ( ) ) { final Map < String , List < String > > rootDseSearchResults = results . values ( ) . iterator ( ) . next ( ) ; for ( final DirectoryVendor directoryVendor : DirectoryVendor . values ( ) ) { if ( directoryVendor . getVendorFactory ( ) . detectVendorFromRootDSEData ( rootDseSearchResults ) ) { return directoryVendor ; } } } return DirectoryVendor . GENERIC ; } | Determines the vendor of a the ldap directory by reading RootDSE attributes . |
19,705 | static boolean isAuthenticationRelated ( final String message ) { for ( final DirectoryVendor vendor : DirectoryVendor . values ( ) ) { final ErrorMap errorMap = vendor . getVendorFactory ( ) . getErrorMap ( ) ; if ( errorMap . isAuthenticationRelated ( message ) ) { return true ; } } return false ; } | Indicates if the error is related to authentication . |
19,706 | public void setFilterNot ( final String attributeName , final String value ) { this . setFilter ( attributeName , value ) ; filter = "(!" + filter + ")" ; } | Set up a not exists filter for an attribute name and value pair . |
19,707 | public void setFilter ( final String attributeName , final String value ) { filter = new FilterSequence ( attributeName , value ) . toString ( ) ; } | Set up a standard filter attribute name and value pair . |
19,708 | public void setFilterOr ( final Map < String , String > nameValuePairs ) { if ( nameValuePairs == null ) { throw new NullPointerException ( ) ; } if ( nameValuePairs . size ( ) < 1 ) { throw new IllegalArgumentException ( "requires at least one key" ) ; } final List < FilterSequence > filters = new ArrayList < > ( ) ; for ( final Map . Entry < String , String > entry : nameValuePairs . entrySet ( ) ) { filters . add ( new FilterSequence ( entry . getKey ( ) , entry . getValue ( ) , FilterSequence . MatchingRuleEnum . EQUALS ) ) ; } setFilterBind ( filters , "|" ) ; } | Set up an OR filter for each map key and value . Consider the following example . |
19,709 | public static boolean convertStrToBoolean ( final String string ) { return ! ( string == null || string . length ( ) < 1 ) && ( "true" . equalsIgnoreCase ( string ) || "1" . equalsIgnoreCase ( string ) || "yes" . equalsIgnoreCase ( string ) || "y" . equalsIgnoreCase ( string ) ) ; } | Convert a string value to a boolean . If the value is a common positive string value such as 1 true y or yes then TRUE is returned . For any other value or null FALSE is returned . |
19,710 | public byte [ ] getEncodedValue ( ) { final String characterEncoding = this . chaiConfiguration . getSetting ( ChaiSetting . LDAP_CHARACTER_ENCODING ) ; final byte [ ] password = modifyPassword . getBytes ( Charset . forName ( characterEncoding ) ) ; final byte [ ] dn = modifyDn . getBytes ( Charset . forName ( characterEncoding ) ) ; final int encodedLength = 6 + dn . length + password . length ; final byte [ ] encoded = new byte [ encodedLength ] ; int valueI = 0 ; encoded [ valueI ++ ] = ( byte ) 0x30 ; encoded [ valueI ++ ] = ( byte ) ( 4 + dn . length + password . length ) ; encoded [ valueI ++ ] = LDAP_TAG_EXOP_X_MODIFY_PASSWD_ID ; encoded [ valueI ++ ] = ( byte ) dn . length ; System . arraycopy ( dn , 0 , encoded , valueI , dn . length ) ; valueI += dn . length ; encoded [ valueI ++ ] = LDAP_TAG_EXOP_X_MODIFY_PASSWD_NEW ; encoded [ valueI ++ ] = ( byte ) password . length ; System . arraycopy ( password , 0 , encoded , valueI , password . length ) ; valueI += password . length ; return encoded ; } | Get the BER encoded value for this operation . |
19,711 | public static void registerTypeConversion ( Conversion < ? > conversion ) { Object [ ] keys = conversion . getTypeKeys ( ) ; if ( keys == null ) { return ; } for ( int i = 0 ; i < keys . length ; i ++ ) { registerTypeConversion ( keys [ i ] , conversion ) ; } } | Register a type conversion object under the specified keys . This method can be used by developers to register custom type conversion objects . |
19,712 | private static List < Object > getTypeKeys ( Conversion < ? > conversion ) { List < Object > result = new ArrayList < Object > ( ) ; synchronized ( typeConversions ) { Map < Object , Conversion < ? > > map = new HashMap < Object , Conversion < ? > > ( typeConversions ) ; for ( Map . Entry < Object , Conversion < ? > > entry : map . entrySet ( ) ) { if ( entry . getValue ( ) == conversion ) { result . add ( entry . getKey ( ) ) ; } } } return result ; } | Discover all the type key mappings for this conversion |
19,713 | private static Conversion < ? > getTypeConversion ( Object typeKey , Object value ) { if ( typeKey instanceof Class && ( ( Class ) typeKey ) != Object . class && ( ( Class ) typeKey ) . isInstance ( value ) ) { return IDENTITY_CONVERSION ; } return ( value instanceof Convertible ) ? ( ( Convertible ) value ) . getTypeConversion ( typeKey ) : typeConversions . get ( typeKey ) ; } | Obtain a conversion for the specified type key and value |
19,714 | public boolean getScrollableTracksViewportWidth ( ) { Component parent = getParent ( ) ; ComponentUI myui = getUI ( ) ; return parent == null || ( myui . getPreferredSize ( this ) . width <= parent . getSize ( ) . width ) ; } | to preserve the full width of the text |
19,715 | public int yToLine ( int y ) { FontMetrics fm = this . getFontMetrics ( this . getFont ( ) ) ; int height = fm . getHeight ( ) ; Document doc = this . getDocument ( ) ; int length = doc . getLength ( ) ; Element map = doc . getDefaultRootElement ( ) ; int startLine = map . getElementIndex ( 0 ) ; int endline = map . getElementIndex ( length ) ; return Math . max ( 0 , Math . min ( endline - 1 , y / height + startLine ) ) - 1 ; } | Converts a y co - ordinate to a line index . |
19,716 | public Campaign readFile ( String fileName ) throws Exception { Campaign result = new Campaign ( ) ; DocumentBuilderFactory dbf = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder db = dbf . newDocumentBuilder ( ) ; Document doc = db . parse ( fileName ) ; doc . getDocumentElement ( ) . normalize ( ) ; Element el = doc . getDocumentElement ( ) ; if ( ! el . getNodeName ( ) . equals ( "campaign" ) ) { throw new Exception ( fileName + " is not a valid xml campain file" ) ; } result . name = el . getAttributeNode ( "name" ) . getValue ( ) ; NodeList nodeLst = doc . getElementsByTagName ( "run" ) ; for ( int s = 0 ; s < nodeLst . getLength ( ) ; s ++ ) { Node node = nodeLst . item ( s ) ; if ( node . getNodeType ( ) == Node . ELEMENT_NODE ) { Element element = ( Element ) node ; CampaignRun run = new CampaignRun ( ) ; run . testbed = element . getAttribute ( "testbed" ) ; result . runs . add ( run ) ; NodeList nodeList = element . getElementsByTagName ( "testsuite" ) ; for ( int t = 0 ; t < nodeList . getLength ( ) ; t ++ ) { TestSuiteParams params = new TestSuiteParams ( ) ; run . testsuites . add ( params ) ; params . setDirectory ( nodeList . item ( t ) . getAttributes ( ) . getNamedItem ( "directory" ) . getNodeValue ( ) ) ; NodeList childList = nodeList . item ( t ) . getChildNodes ( ) ; for ( int c = 0 ; c < childList . getLength ( ) ; c ++ ) { Node childNode = childList . item ( c ) ; if ( childNode . getNodeName ( ) . equals ( "testdata" ) ) { String selectorStr = childNode . getAttributes ( ) . getNamedItem ( "selector" ) . getNodeValue ( ) ; String [ ] selectedRowsStr = selectorStr . split ( "," ) ; TreeSet < Integer > selectedRows = new TreeSet < > ( ) ; for ( String selectedRowStr : selectedRowsStr ) { selectedRows . add ( Integer . parseInt ( selectedRowStr ) ) ; } params . setDataRows ( selectedRows ) ; } if ( childList . item ( c ) . getNodeName ( ) . equals ( "loopInHours" ) ) { params . setLoopInHours ( true ) ; } if ( childList . item ( c ) . getNodeName ( ) . equals ( "count" ) ) { try { params . setCount ( Integer . parseInt ( childList . item ( c ) . getTextContent ( ) ) ) ; } catch ( NumberFormatException e ) { logger . error ( "count field in " + fileName + " file should be numeric" ) ; } } } } } } return result ; } | Read the xml campaign file |
19,717 | public boolean execute ( Campaign campaign ) { boolean campaignResult = true ; currentCampaign = campaign ; campaignStartTimeStamp = new Date ( ) ; try { createReport ( ) ; for ( CampaignRun run : currentCampaign . getRuns ( ) ) { if ( TestEngine . isAbortedByUser ( ) ) { break ; } currentTestBed = run . getTestbed ( ) ; String testSuiteName = currentCampaign . getName ( ) + " - " + currentTestBed . substring ( 0 , currentTestBed . lastIndexOf ( '.' ) ) ; TestBedConfiguration . setConfigFile ( StaticConfiguration . TESTBED_CONFIG_DIRECTORY + "/" + currentTestBed ) ; currentTestSuite = MetaTestSuite . createMetaTestSuite ( testSuiteName , run . getTestsuites ( ) ) ; if ( currentTestSuite == null ) { continue ; } currentTestSuite . addTestReportListener ( this ) ; campaignResult &= TestEngine . execute ( currentTestSuite ) ; currentTestSuite . removeTestReportListener ( this ) ; currentTestSuite = null ; } CampaignReportManager . getInstance ( ) . stopReport ( ) ; } finally { TestEngine . tearDown ( ) ; campaignStartTimeStamp = null ; currentCampaign = null ; } return campaignResult ; } | Executes a campaign |
19,718 | private void createReport ( ) { CampaignReportManager . getInstance ( ) . startReport ( campaignStartTimeStamp , currentCampaign . getName ( ) ) ; for ( CampaignRun run : currentCampaign . getRuns ( ) ) { CampaignResult result = new CampaignResult ( run . getTestbed ( ) ) ; result . setStatus ( Status . NOT_EXECUTED ) ; CampaignReportManager . getInstance ( ) . putEntry ( result ) ; } CampaignReportManager . getInstance ( ) . refresh ( ) ; } | Create a empty report . All campaign run will be Not Executed |
19,719 | public void open ( ) throws SQLException , ClassNotFoundException { logger . info ( "Using database driver: " + jdbcDriver ) ; Class . forName ( jdbcDriver ) ; logger . info ( "Using database.url: " + jdbcURL ) ; con = DriverManager . getConnection ( jdbcURL , user , password ) ; connected = true ; } | Open a JDBC connection to the database |
19,720 | public ResultSet executeQuery ( String query ) throws SQLException , ClassNotFoundException { if ( ! connected ) { open ( ) ; } Statement stmt = con . createStatement ( ) ; return stmt . executeQuery ( query ) ; } | Execute the specified query If the SQL connection if not open it will be opened automatically |
19,721 | public boolean executeCommand ( String query ) throws SQLException , ClassNotFoundException { if ( ! connected ) { open ( ) ; } Statement stmt = con . createStatement ( ) ; return stmt . execute ( query ) ; } | Execute the specified SQL command If the SQL connection if not open it will be opened automatically |
19,722 | public void doubleClick ( String fileName ) throws QTasteException { try { new Region ( this . rect ) . doubleClick ( fileName ) ; } catch ( Exception ex ) { throw new QTasteException ( ex . getMessage ( ) , ex ) ; } } | Simulates a double click on the specified image of the area . |
19,723 | public static Type getType ( ) { String osName = System . getProperty ( "os.name" ) . toLowerCase ( ) ; if ( osName . contains ( "windows" ) ) { return Type . WINDOWS ; } else if ( osName . contains ( "linux" ) ) { return Type . LINUX ; } else if ( osName . contains ( "mac" ) ) { return Type . MAC ; } return Type . UNKNOWN ; } | Get OS type . |
19,724 | public static void copyFiles ( File src , File dest ) throws IOException { if ( src . isDirectory ( ) ) { dest . mkdirs ( ) ; String list [ ] = src . list ( ) ; for ( String fileName : list ) { String dest1 = dest . getPath ( ) + "/" + fileName ; String src1 = src . getPath ( ) + "/" + fileName ; File src1_ = new File ( src1 ) ; File dest1_ = new File ( dest1 ) ; if ( ! src1_ . isHidden ( ) ) { copyFiles ( src1_ , dest1_ ) ; } } } else { FileInputStream fin = new FileInputStream ( src ) ; FileOutputStream fout = new FileOutputStream ( dest ) ; int c ; while ( ( c = fin . read ( ) ) >= 0 ) { fout . write ( c ) ; } fin . close ( ) ; fout . close ( ) ; } } | The method copyFiles being defined |
19,725 | public static int collapseJTreeNode ( javax . swing . JTree tree , javax . swing . tree . TreeModel model , Object node , int row , int depth ) { if ( node != null && ! model . isLeaf ( node ) ) { tree . collapseRow ( row ) ; if ( depth != 0 ) { for ( int index = 0 ; row + 1 < tree . getRowCount ( ) && index < model . getChildCount ( node ) ; index ++ ) { row ++ ; Object child = model . getChild ( node , index ) ; if ( child == null ) { break ; } javax . swing . tree . TreePath path ; while ( ( path = tree . getPathForRow ( row ) ) != null && path . getLastPathComponent ( ) != child ) { row ++ ; } if ( path == null ) { break ; } row = collapseJTreeNode ( tree , model , child , row , depth - 1 ) ; } } } return row ; } | Expands a given node in a JTree . |
19,726 | public static String getDocumentAsXmlString ( Document doc ) throws TransformerConfigurationException , TransformerException { DOMSource domSource = new DOMSource ( doc ) ; TransformerFactory tf = TransformerFactory . newInstance ( ) ; try { tf . setAttribute ( "indent-number" , 4 ) ; } catch ( IllegalArgumentException e ) { } Transformer transformer = tf . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . METHOD , "xml" ) ; transformer . setOutputProperty ( OutputKeys . ENCODING , "UTF-8" ) ; transformer . setOutputProperty ( "{http://xml.apache.org/xslt}indent-amount" , "4" ) ; transformer . setOutputProperty ( OutputKeys . INDENT , "yes" ) ; java . io . StringWriter sw = new java . io . StringWriter ( ) ; StreamResult sr = new StreamResult ( sw ) ; transformer . transform ( domSource , sr ) ; return sw . toString ( ) ; } | Return the XMLDocument formatted as a String |
19,727 | public boolean connect ( ) { if ( client . isConnected ( ) ) { logger . warn ( "Already connected" ) ; return true ; } try { logger . info ( "Connecting to remote host " + remoteHost ) ; client . connect ( remoteHost ) ; client . rlogin ( localUser , remoteUser , terminalType ) ; writer = new OutputStreamWriter ( client . getOutputStream ( ) ) ; outputReaderThread = new Thread ( new OutputReader ( ) ) ; outputReaderThread . start ( ) ; if ( interactive ) { standardInputReaderThread = new Thread ( new StandardInputReader ( ) ) ; standardInputReaderThread . start ( ) ; } try { Thread . sleep ( 200 ) ; } catch ( InterruptedException ex ) { } if ( client . isConnected ( ) ) { return true ; } else { logger . fatal ( "Client has been immediately disconnected from remote host:" + remoteHost ) ; return false ; } } catch ( IOException e ) { logger . fatal ( "Could not connect to remote host:" + remoteHost , e ) ; return false ; } } | Create a rlogin connection to the specified remote host . |
19,728 | public boolean reboot ( ) { if ( ! sendCommand ( "reboot" ) ) { return false ; } try { Thread . sleep ( 1000 ) ; } catch ( InterruptedException ex ) { } disconnect ( ) ; try ( Socket socket = new Socket ( ) ) { socket . bind ( null ) ; socket . connect ( new InetSocketAddress ( remoteHost , RLoginClient . DEFAULT_PORT ) , 1 ) ; } catch ( SocketTimeoutException e ) { logger . info ( "Rebooted host " + remoteHost + " successfully" ) ; return true ; } catch ( IOException e ) { logger . error ( "Something went wrong while rebooting host:" + remoteHost ) ; return false ; } logger . error ( "Host " + remoteHost + " did not reboot as expected! Please check that no other rlogin client is connected!" ) ; return false ; } | Reboot the remote host by sending the reboot command and check that the remote host is not accessible anymore . |
19,729 | public boolean sendCommand ( String command ) { if ( writer != null ) { try { logger . info ( "Sending command " + command + " to remote host " + remoteHost ) ; writer . write ( command ) ; writer . write ( '\r' ) ; writer . flush ( ) ; } catch ( IOException e ) { logger . fatal ( "Error while sending command " + command + " to remote host " + remoteHost , e ) ; return false ; } return true ; } else { return false ; } } | Send the specified command to the remote host |
19,730 | public void disconnect ( ) { try { if ( client . isConnected ( ) ) { client . disconnect ( ) ; } if ( standardInputReaderThread != null ) { standardInputReaderThread = null ; } if ( outputReaderThread != null ) { outputReaderThread . join ( ) ; outputReaderThread = null ; } writer = null ; } catch ( InterruptedException ex ) { } catch ( IOException e ) { logger . fatal ( "Error while disconnecting from rlogin session. Host: " + remoteHost , e ) ; } } | Disconnect the rlogin client from the remote host . |
19,731 | protected void paintDisabledText ( JLabel pLabel , Graphics pG , String pStr , int pTextX , int pTextY ) { Graphics2D g2 = ( Graphics2D ) pG ; pG . setColor ( Color . GRAY ) ; g2 . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , RenderingHints . VALUE_ANTIALIAS_ON ) ; pG . drawString ( pStr , pTextX , pTextY ) ; g2 . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , RenderingHints . VALUE_ANTIALIAS_OFF ) ; } | private static final int SPACE_INC = 12 ; |
19,732 | public void close ( ) { if ( mWithBody ) { mOut . println ( "</BODY>" ) ; } mOut . println ( "</HTML>" ) ; mOut . close ( ) ; mOut = null ; } | Writes HTML body ending tag if needed and HTML footer and closes file . |
19,733 | public void printMethodsSummary ( ClassDoc classDoc ) { MethodDoc [ ] methodDocs = TestAPIDoclet . getTestAPIComponentMethods ( classDoc ) ; if ( methodDocs . length > 0 ) { mOut . println ( "<P>" ) ; mOut . println ( "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" CELLSPACING=\"0\" SUMMARY=\"\">" ) ; mOut . println ( "<TR BGCOLOR=\"#CCCCFF\"><TH ALIGN=\"left\" COLSPAN=\"2\"><FONT SIZE=\"+2\"><B>Methods " + "Summary</B></FONT></TH></TR>" ) ; for ( MethodDoc methodDoc : methodDocs ) { String methodName = methodDoc . name ( ) ; mOut . print ( "<TR><TD WIDTH=\"1%\"><CODE><B><A HREF=\"#" + methodName + methodDoc . flatSignature ( ) + "\">" + methodName + "</A></B></CODE></TD><TD>" ) ; Tag [ ] firstSentenceTags = methodDoc . firstSentenceTags ( ) ; if ( firstSentenceTags . length == 0 ) { System . err . println ( "Warning: method " + methodName + " of " + methodDoc . containingClass ( ) . simpleTypeName ( ) + " has no description" ) ; } printInlineTags ( firstSentenceTags , classDoc ) ; mOut . println ( "</TD>" ) ; } mOut . println ( "</TABLE>" ) ; } } | Prints summary of Test API methods excluding old - style verbs in HTML format . |
19,734 | private String getTypeString ( Type type ) { String typeQualifiedName = type . qualifiedTypeName ( ) . replaceFirst ( "^java\\.lang\\." , "" ) ; typeQualifiedName = typeQualifiedName . replaceFirst ( "^com\\.qspin\\.qtaste\\.testsuite\\.(QTaste\\w*Exception)" , "$1" ) ; String typeDocFileName = null ; if ( typeQualifiedName . startsWith ( "com.qspin." ) ) { String javaDocDir = typeQualifiedName . startsWith ( "com.qspin.qtaste." ) ? QTaste_JAVADOC_URL_PREFIX : SUT_JAVADOC_URL_PREFIX ; typeDocFileName = javaDocDir + typeQualifiedName . replace ( '.' , '/' ) + ".html" ; } String typeString = typeQualifiedName ; if ( typeDocFileName != null ) { typeString = "<A HREF=\"" + typeDocFileName + "\">" + typeString + "</A>" ; } if ( type . asParameterizedType ( ) != null ) { ParameterizedType parametrizedType = type . asParameterizedType ( ) ; final Type [ ] parameterTypes = parametrizedType . typeArguments ( ) ; if ( parameterTypes . length > 0 ) { String [ ] parametersTypeStrings = new String [ parameterTypes . length ] ; for ( int i = 0 ; i < parameterTypes . length ; i ++ ) { parametersTypeStrings [ i ] = getTypeString ( parameterTypes [ i ] ) ; } typeString += "<" + Strings . join ( parametersTypeStrings , "," ) + ">" ; } } typeString += type . dimension ( ) ; return typeString ; } | Returns type string . |
19,735 | private void printInlineTags ( Tag [ ] tags , ClassDoc classDoc ) { for ( Tag tag : tags ) { if ( ( tag instanceof SeeTag ) && tag . name ( ) . equals ( "@link" ) ) { SeeTag seeTag = ( SeeTag ) tag ; boolean sameClass = seeTag . referencedClass ( ) == classDoc ; String fullClassName = seeTag . referencedClassName ( ) ; String memberName = seeTag . referencedMemberName ( ) ; String className = fullClassName . substring ( fullClassName . lastIndexOf ( '.' ) + 1 ) ; List < String > nameParts = new ArrayList < > ( ) ; if ( ! sameClass ) { nameParts . add ( className ) ; } if ( memberName != null ) { nameParts . add ( memberName ) ; } String name = Strings . join ( nameParts , "." ) ; if ( fullClassName . lastIndexOf ( '.' ) >= 0 ) { String packageName = fullClassName . substring ( 0 , fullClassName . lastIndexOf ( '.' ) ) ; String urlPrefix = "" ; if ( ! sameClass && packageName . startsWith ( "com.qspin." ) && ! packageName . equals ( "com.qspin.qtaste.testapi.api" ) ) { String javaDocDir = packageName . startsWith ( "com.qspin.qtaste." ) ? QTaste_JAVADOC_URL_PREFIX : SUT_JAVADOC_URL_PREFIX ; urlPrefix = javaDocDir + packageName . replace ( '.' , '/' ) + "/" ; } String url = ( sameClass ? "" : urlPrefix + className + ".html" ) + ( memberName != null ? "#" + memberName : "" ) ; mOut . print ( "<A HREF=\"" + url + "\">" + name + "</A>" ) ; } else { mOut . print ( name ) ; } } else { mOut . print ( tag . text ( ) ) ; } } } | Prints inline tags in HTML format . |
19,736 | private void updateSize ( ) { int newLineCount = ActionUtils . getLineCount ( pane ) ; if ( newLineCount == lineCount ) { return ; } lineCount = newLineCount ; int h = ( int ) pane . getPreferredSize ( ) . getHeight ( ) ; int d = ( int ) Math . log10 ( lineCount ) + 1 ; if ( d < 1 ) { d = 1 ; } int w = d * charWidth + r_margin + l_margin ; format = "%" + d + "d" ; setPreferredSize ( new Dimension ( w , h ) ) ; getParent ( ) . doLayout ( ) ; } | Update the size of the line numbers based on the length of the document |
19,737 | public JScrollPane getScrollPane ( JTextComponent editorPane ) { Container p = editorPane . getParent ( ) ; while ( p != null ) { if ( p instanceof JScrollPane ) { return ( JScrollPane ) p ; } p = p . getParent ( ) ; } return null ; } | Get the JscrollPane that contains an editor pane or null if none . |
19,738 | public static void copy ( File source , File dest ) throws IOException { if ( dest . isDirectory ( ) ) { dest = new File ( dest + File . separator + source . getName ( ) ) ; } FileChannel in = null , out = null ; try { in = new FileInputStream ( source ) . getChannel ( ) ; out = new FileOutputStream ( dest ) . getChannel ( ) ; long size = in . size ( ) ; MappedByteBuffer buf = in . map ( FileChannel . MapMode . READ_ONLY , 0 , size ) ; out . write ( buf ) ; } finally { if ( in != null ) { in . close ( ) ; } if ( out != null ) { out . close ( ) ; } } } | Fast and simple file copy . |
19,739 | public static String readFileContent ( String filename ) throws FileNotFoundException , IOException { BufferedReader reader = new BufferedReader ( new FileReader ( filename ) ) ; StringBuilder content = new StringBuilder ( ) ; String line ; final String eol = System . getProperty ( "line.separator" ) ; while ( ( line = reader . readLine ( ) ) != null ) { content . append ( line ) ; content . append ( eol ) ; } reader . close ( ) ; return content . toString ( ) ; } | Reads file content . |
19,740 | public static String [ ] listResourceFiles ( Class < ? > clazz , String resourceDirName ) throws URISyntaxException , IOException { if ( ! resourceDirName . endsWith ( "/" ) ) { resourceDirName = resourceDirName + "/" ; } URL dirURL = clazz . getResource ( resourceDirName ) ; if ( dirURL == null ) { throw new IOException ( "Resource directory " + resourceDirName + " not found" ) ; } if ( dirURL . getProtocol ( ) . equals ( "file" ) ) { File [ ] entries = new File ( dirURL . toURI ( ) ) . listFiles ( File :: isFile ) ; String [ ] fileNames = new String [ entries . length ] ; for ( int i = 0 ; i < entries . length ; i ++ ) { fileNames [ i ] = entries [ i ] . toString ( ) ; } return fileNames ; } if ( dirURL . getProtocol ( ) . equals ( "jar" ) ) { String jarPath = dirURL . getPath ( ) . substring ( 5 , dirURL . getPath ( ) . indexOf ( "!" ) ) ; try ( JarFile jar = new JarFile ( jarPath ) ) { Enumeration < JarEntry > entries = jar . entries ( ) ; List < String > result = new ArrayList < > ( ) ; String relativeResourceDirName = resourceDirName . startsWith ( "/" ) ? resourceDirName . substring ( 1 ) : resourceDirName ; while ( entries . hasMoreElements ( ) ) { String name = entries . nextElement ( ) . getName ( ) ; if ( name . startsWith ( relativeResourceDirName ) && ! name . equals ( relativeResourceDirName ) ) { String entry = name . substring ( relativeResourceDirName . length ( ) ) ; int checkSubdir = entry . indexOf ( "/" ) ; if ( checkSubdir < 0 ) { result . add ( entry ) ; } } } return result . toArray ( new String [ result . size ( ) ] ) ; } } throw new UnsupportedOperationException ( "Cannot list files for URL " + dirURL ) ; } | List directory files in a resource folder . Not recursive . Works for regular files and also JARs . |
19,741 | public boolean accept ( File f ) { if ( f != null ) { if ( f . isDirectory ( ) ) { return false ; } String extension = getExtension ( f ) ; if ( extension != null && filters . get ( getExtension ( f ) ) != null ) { return true ; } } return false ; } | Retourne true si le fichier doit etre montre dans le repertoire false s il ne doit pas l etre . |
19,742 | public String getExtension ( File f ) { if ( f != null ) { String filename = f . getName ( ) ; int i = filename . lastIndexOf ( '.' ) ; if ( i > 0 && i < filename . length ( ) - 1 ) { return filename . substring ( i + 1 ) . toLowerCase ( ) ; } } return null ; } | Retourne l extention du nom du fichier . |
19,743 | public List < Object > getProperty ( String key ) { List < ? > nodes = fetchNodeList ( key ) ; if ( nodes . size ( ) == 0 ) { return null ; } else { List < Object > list = new ArrayList < > ( ) ; for ( Object node : nodes ) { ConfigurationNode configurationNode = ( ConfigurationNode ) node ; if ( configurationNode . getValue ( ) != null ) { list . add ( configurationNode . getValue ( ) ) ; } } if ( list . size ( ) < 1 ) { return null ; } else { return list ; } } } | Fetches the specified property . This task is delegated to the associated expression engine . |
19,744 | public void loadAddOns ( ) { List < String > addonToLoad = getAddOnClasses ( ) ; for ( File f : new File ( StaticConfiguration . PLUGINS_HOME ) . listFiles ( ) ) { if ( f . isFile ( ) && f . getName ( ) . toUpperCase ( ) . endsWith ( ".JAR" ) ) { AddOnMetadata meta = AddOnMetadata . createAddOnMetadata ( f ) ; if ( meta != null ) { mAddons . add ( meta ) ; LOGGER . debug ( "load " + meta . getMainClass ( ) ) ; if ( addonToLoad . contains ( meta . getMainClass ( ) ) ) { loadAddOn ( meta ) ; } } } } } | Loads and registers all add - ons references in the engine configuration file . |
19,745 | boolean registerAddOn ( AddOn pAddOn ) { if ( ! mRegisteredAddOns . containsKey ( pAddOn . getAddOnId ( ) ) ) { mRegisteredAddOns . put ( pAddOn . getAddOnId ( ) , pAddOn ) ; if ( pAddOn . hasConfiguration ( ) ) { addConfiguration ( pAddOn . getAddOnId ( ) , pAddOn . getConfigurationPane ( ) ) ; } LOGGER . info ( "The add-on " + pAddOn . getAddOnId ( ) + " has been registered." ) ; return true ; } else { LOGGER . warn ( "The add-on " + pAddOn . getAddOnId ( ) + " is alreadry registered." ) ; return false ; } } | Registers the add - on . If the add - on is not loaded loads it . |
19,746 | public AddOn getAddOn ( String pAddOnId ) { if ( mRegisteredAddOns . containsKey ( pAddOnId ) ) { return mRegisteredAddOns . get ( pAddOnId ) ; } else { LOGGER . warn ( "Add-on " + pAddOnId + " is not loaded." ) ; return null ; } } | Returns the registered add - on identified by the identifier . |
19,747 | public Boolean executeCommand ( int timeout , String componentName , Object ... data ) throws QTasteException { setData ( data ) ; long maxTime = System . currentTimeMillis ( ) + 1000 * timeout ; while ( System . currentTimeMillis ( ) < maxTime ) { Stage targetPopup = null ; for ( Stage stage : findPopups ( ) ) { } try { Thread . sleep ( 1000 ) ; } catch ( InterruptedException e ) { LOGGER . warn ( "Exception during the component search sleep..." ) ; } } if ( component == null ) { throw new QTasteTestFailException ( "The text field component is not found." ) ; } if ( component . isDisabled ( ) ) { throw new QTasteTestFailException ( "The text field component is not enabled." ) ; } if ( ! checkComponentIsVisible ( component ) ) { throw new QTasteTestFailException ( "The text field component is not visible!" ) ; } prepareActions ( ) ; Platform . runLater ( this ) ; return true ; } | Commander which sets a value in the input field of a popup . |
19,748 | public static String tabsToSpaces ( String in , int tabSize ) { StringBuilder buf = new StringBuilder ( ) ; int width = 0 ; for ( int i = 0 ; i < in . length ( ) ; i ++ ) { switch ( in . charAt ( i ) ) { case '\t' : int count = tabSize - ( width % tabSize ) ; width += count ; while ( -- count >= 0 ) { buf . append ( ' ' ) ; } break ; case '\n' : width = 0 ; buf . append ( in . charAt ( i ) ) ; break ; default : width ++ ; buf . append ( in . charAt ( i ) ) ; break ; } } return buf . toString ( ) ; } | Converts tabs to consecutive spaces in the specified string . |
19,749 | public static String toTitleCase ( String str ) { if ( str . length ( ) == 0 ) { return str ; } else { return Character . toUpperCase ( str . charAt ( 0 ) ) + str . substring ( 1 ) . toLowerCase ( ) ; } } | Converts the specified string to title case by capitalizing the first letter . |
19,750 | protected String getManifestAttributeValue ( Attributes . Name attributeName ) { try { String value = attributes . getValue ( attributeName ) ; return value != null ? value : "undefined" ; } catch ( NullPointerException e ) { return "undefined" ; } catch ( IllegalArgumentException e ) { logger . error ( "Invalid attribute name when reading jar manifest for reading version information: " + e . getMessage ( ) ) ; return "undefined" ; } } | Gets the value of an attribute of the manifest . |
19,751 | private static String getQTasteRoot ( ) { String qtasteRoot = System . getenv ( "QTASTE_ROOT" ) ; if ( qtasteRoot == null ) { System . err . println ( "QTASTE_ROOT environment variable is not defined" ) ; System . exit ( 1 ) ; } try { qtasteRoot = new File ( qtasteRoot ) . getCanonicalPath ( ) ; } catch ( IOException e ) { System . err . println ( "QTASTE_ROOT environment variable is invalid (" + qtasteRoot + ")" ) ; System . exit ( 1 ) ; } return qtasteRoot ; } | Get QTaste root directory from QTASTE_ROOT environment variable . |
19,752 | protected static List < Stage > findPopups ( ) throws QTasteTestFailException { List < Stage > popupFound = new ArrayList < > ( ) ; for ( Stage stage : getStages ( ) ) { Parent root = stage . getScene ( ) . getRoot ( ) ; if ( isAPopup ( stage ) ) { DialogPane dialog = ( DialogPane ) root ; LOGGER . trace ( "Find a popup with the title '" + stage . getTitle ( ) + "'." ) ; popupFound . add ( stage ) ; } } return popupFound ; } | Finds all popups . A Component is a popup if it s a DialogPane modal and not resizable . |
19,753 | protected boolean activateAndFocusWindow ( Stage window ) { if ( ! window . isFocused ( ) ) { if ( ! window . isShowing ( ) ) { LOGGER . trace ( "cannot activate and focus the window '" + window . getTitle ( ) + "' cause its window is not showing" ) ; return false ; } LOGGER . trace ( "try to activate and focus the window '" + window . getTitle ( ) + "' cause its window is not focused" ) ; StageFocusedListener stageFocusedListener = new StageFocusedListener ( window ) ; window . focusedProperty ( ) . addListener ( stageFocusedListener ) ; PlatformImpl . runAndWait ( ( ) -> { window . toFront ( ) ; window . requestFocus ( ) ; } ) ; boolean windowFocused = stageFocusedListener . waitUntilWindowFocused ( ) ; window . focusedProperty ( ) . removeListener ( stageFocusedListener ) ; LOGGER . trace ( "window focused ? " + windowFocused ) ; if ( ! window . isFocused ( ) ) { LOGGER . warn ( "The window activation/focus process failed!!!" ) ; return false ; } LOGGER . trace ( "The window activation/focus process is completed!!!" ) ; } else { LOGGER . trace ( "the window '" + window . getTitle ( ) + "' is already focused" ) ; } return true ; } | Try to activate and focus the stage window . |
19,754 | protected static List < JDialog > findPopups ( ) { List < JDialog > popupFound = new ArrayList < > ( ) ; for ( Window window : getDisplayableWindows ( ) ) { if ( isAPopup ( window ) ) { JDialog dialog = ( JDialog ) window ; LOGGER . trace ( "Find a popup with the title '" + dialog . getTitle ( ) + "'." ) ; popupFound . add ( dialog ) ; } } return popupFound ; } | Finds all popups . A Component is a popup if it s a JDialog modal and not resizable . |
19,755 | public static String execute ( String fileName , String ... arguments ) throws PyException { return execute ( fileName , true , arguments ) ; } | Executes a python script and return its output . |
19,756 | public static String execute ( String fileName , boolean redirectOutput , String ... arguments ) throws PyException { Properties properties = new Properties ( ) ; properties . setProperty ( "python.home" , StaticConfiguration . JYTHON_HOME ) ; properties . setProperty ( "python.path" , StaticConfiguration . FORMATTER_DIR ) ; PythonInterpreter . initialize ( System . getProperties ( ) , properties , new String [ ] { "" } ) ; try ( PythonInterpreter interp = new PythonInterpreter ( new org . python . core . PyStringMap ( ) , new org . python . core . PySystemState ( ) ) ) { StringWriter output = null ; if ( redirectOutput ) { output = new StringWriter ( ) ; interp . setOut ( output ) ; interp . setErr ( output ) ; } interp . cleanup ( ) ; interp . exec ( "import sys;sys.argv[1:]= [r'" + StringUtils . join ( arguments , "','" ) + "']" ) ; interp . exec ( "__name__ = '__main__'" ) ; interp . exec ( "execfile(r'" + fileName + "')" ) ; return redirectOutput ? output . toString ( ) : null ; } } | Executes a python script returning its output or not . |
19,757 | public static byte [ ] toNullTerminatedFixedSizeByteArray ( String s , int length ) { if ( s . length ( ) >= length ) { s = s . substring ( 0 , length - 1 ) ; } while ( s . length ( ) < length ) { s += '\0' ; } return s . getBytes ( ) ; } | Converts a string to a null - terminated fixed size byte array . |
19,758 | public static String fromNullTerminatedByteArray ( byte [ ] array ) { int stringSize = array . length ; for ( int i = 0 ; i < array . length ; i ++ ) { if ( array [ i ] == 0 ) { stringSize = i ; break ; } } return new String ( array , 0 , stringSize ) ; } | Converts a null - terminated byte array into a string . |
19,759 | public synchronized void register ( ) throws Exception { if ( mbeanName != null ) { throw new Exception ( "Agent already registered" ) ; } mbeanName = new ObjectName ( getClass ( ) . getPackage ( ) . getName ( ) + ":type=" + getClass ( ) . getSimpleName ( ) ) ; logger . info ( "Registering JMX agent " + mbeanName ) ; ManagementFactory . getPlatformMBeanServer ( ) . registerMBean ( this , mbeanName ) ; logger . info ( "JMX agent " + mbeanName + " registered" ) ; } | Register the JMX agent |
19,760 | public synchronized void unregister ( ) throws Exception { if ( mbeanName == null ) { throw new Exception ( "Agent not registered" ) ; } logger . info ( "Unregistering JMX agent " + mbeanName ) ; ManagementFactory . getPlatformMBeanServer ( ) . unregisterMBean ( mbeanName ) ; logger . info ( "JMX agent " + mbeanName + " unregistered" ) ; } | Unregister the JMX agent |
19,761 | public synchronized void sendNotification ( PropertyChangeEvent pEvt ) { String oldValue = pEvt . getOldValue ( ) == null ? "null" : pEvt . getOldValue ( ) . toString ( ) ; String newValue = pEvt . getNewValue ( ) == null ? "null" : pEvt . getNewValue ( ) . toString ( ) ; String sourceName = pEvt . getSource ( ) . getClass ( ) . getCanonicalName ( ) ; String message = sourceName + ":" + pEvt . getPropertyName ( ) + " changed from " + oldValue + " to " + newValue ; Notification n = new AttributeChangeNotification ( sourceName , notifSequenceNumber ++ , System . currentTimeMillis ( ) , message , pEvt . getPropertyName ( ) , "java.lang.String" , oldValue , newValue ) ; sendNotification ( n ) ; logger . trace ( "Sent notification: " + message ) ; } | Send a JMX notification of a property change event |
19,762 | public int exec ( String cmd , Map < String , String > env ) throws IOException , InterruptedException { return exec ( cmd , env , System . out , System . err , null ) ; } | Executes the a command specified in parameter . |
19,763 | public int exec ( String cmd , Map < String , String > env , OutputStream stdout , OutputStream stderr , ByteArrayOutputStream output , File dir ) throws IOException , InterruptedException { if ( output == null ) { output = new ByteArrayOutputStream ( ) ; } try { String [ ] envp ; if ( env != null ) { envp = new String [ env . size ( ) ] ; int i = 0 ; for ( Map . Entry < String , String > envMapEntry : env . entrySet ( ) ) { envp [ i ++ ] = envMapEntry . getKey ( ) + "=" + envMapEntry . getValue ( ) ; } } else { envp = null ; } process = Runtime . getRuntime ( ) . exec ( cmd , envp , dir ) ; process . getOutputStream ( ) . close ( ) ; MyReader t1 = new MyReader ( process . getInputStream ( ) , stdout , output ) ; MyReader t2 = new MyReader ( process . getErrorStream ( ) , stderr , output ) ; t1 . start ( ) ; t2 . start ( ) ; int exitCode = process . waitFor ( ) ; process = null ; t1 . cancel ( ) ; t2 . cancel ( ) ; t1 . join ( ) ; t2 . join ( ) ; return exitCode ; } finally { process = null ; } } | Executes the a command specified in the specified directory . |
19,764 | public static synchronized void generate ( ) { LOGGER . debug ( "Generating documentation of test documentation included in pythonlib directories." ) ; try { IS_RUNNING = true ; List < File > pythonLibDirectories = findPythonLibDirectories ( ROOT_SCRIPT_DIRECTORY ) ; List < File > pythonScriptFiles = findPythonScripts ( pythonLibDirectories ) ; for ( File script : pythonScriptFiles ) { if ( hasToGenerateDocumentation ( script ) ) { GenerateTestStepsModulesDoc . generate ( script . getAbsolutePath ( ) ) ; } } ALREADY_RUN = true ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; } finally { IS_RUNNING = false ; } } | Generates the documentation of scripts located in a pythonlib directory . |
19,765 | private static List < File > findPythonScripts ( List < File > pythonLibDirectories ) { List < File > scripts = new ArrayList < > ( ) ; for ( File dir : pythonLibDirectories ) { if ( dir . exists ( ) ) { scripts . addAll ( Arrays . asList ( dir . listFiles ( PYTHON_SCRIPT_FILE_FILTER ) ) ) ; } } return scripts ; } | Searches for all python script files contains in the directories . |
19,766 | public void checkPropertyValueOrTransition ( String propertyValueOrTransition , double maxTime ) throws QTasteDataException , QTasteTestFailException { long beginTime_ms = System . currentTimeMillis ( ) ; long maxTime_ms = Math . round ( maxTime * 1000 ) ; propertyValueOrTransition = propertyValueOrTransition . toLowerCase ( ) ; String [ ] splitted = propertyValueOrTransition . split ( " *: *" , 2 ) ; if ( splitted . length != 2 ) { throw new QTasteDataException ( "Invalid syntax" ) ; } String property = splitted [ 0 ] ; if ( property . length ( ) == 0 ) { throw new QTasteDataException ( "Invalid syntax" ) ; } String transition = splitted [ 1 ] ; boolean mustBeAtBegin = transition . matches ( "^\\[.*" ) ; if ( mustBeAtBegin ) { transition = transition . replaceFirst ( "^\\[ *" , "" ) ; } boolean mustBeAtEnd = transition . matches ( ".*\\]$" ) ; if ( mustBeAtEnd ) { transition = transition . replaceFirst ( " *\\]$" , "" ) ; } String [ ] values = transition . split ( " *-> *" ) ; if ( ( values . length != 1 ) && ( values . length != 2 ) ) { throw new QTasteDataException ( "Invalid syntax" ) ; } String expectedValueOrTransition = propertyValueOrTransition . replaceFirst ( ".*?: *" , "" ) ; long remainingTime_ms = maxTime_ms - ( System . currentTimeMillis ( ) - beginTime_ms ) ; checkPropertyValueOrTransition ( property , values , mustBeAtBegin , mustBeAtEnd , remainingTime_ms , expectedValueOrTransition ) ; } | Checks that a property reaches a given value or do a given values transition within given time . If found remove old values from history . |
19,767 | private synchronized void readObject ( java . io . ObjectInputStream in ) throws IOException , ClassNotFoundException { in . defaultReadObject ( ) ; hash = new Hashtable < > ( ) ; for ( NameValue < N , V > nameValue : order ) { putInHash ( nameValue . name , nameValue . value ) ; } } | and rebuild hash hashtable |
19,768 | public boolean removeNotificationListener ( String mbeanName , NotificationListener listener ) throws Exception { if ( isConnected ( ) ) { ObjectName objectName = new ObjectName ( mbeanName ) ; mbsc . removeNotificationListener ( objectName , listener , null , null ) ; jmxc . removeConnectionNotificationListener ( listener ) ; return true ; } else { return false ; } } | Removes listener as notification and connection notification listener . |
19,769 | public static String getIndent ( String line ) { if ( line == null || line . length ( ) == 0 ) { return "" ; } int i = 0 ; while ( i < line . length ( ) && line . charAt ( i ) == '\t' ) { i ++ ; } return line . substring ( 0 , i ) ; } | Get the indentation of a line of text . This is the subString from beginning of line to the first non - space char |
19,770 | public void scheduleTask ( PyObject task , double delay ) { mTimer . schedule ( new PythonCallTimerTask ( task ) , Math . round ( delay * 1000 ) ) ; } | Schedules the specified task for execution after the specified delay . |
19,771 | private static void logAndThrowException ( String message , PyException e ) throws Exception { LOGGER . error ( message , e ) ; throw new Exception ( message + ":\n" + PythonHelper . getMessage ( e ) ) ; } | Logs message and exception and throws Exception . |
19,772 | protected static String getSubstitutedTemplateContent ( String templateContent , NamesValuesList < String , String > namesValues ) { String templateContentSubst = templateContent ; for ( NameValue < String , String > nameValue : namesValues ) { templateContentSubst = templateContentSubst . replace ( nameValue . name , nameValue . value ) ; } return templateContentSubst ; } | Substitutes names by values in template and return result . |
19,773 | public synchronized HTMLEditorKit . Parser getParser ( ) { if ( parser == null ) { try { Class < ? > c = Class . forName ( "javax.swing.text.html.parser.ParserDelegator" ) ; parser = ( HTMLEditorKit . Parser ) c . newInstance ( ) ; } catch ( Exception e ) { } } return parser ; } | Methods that allow customization of the parser and the callback |
19,774 | private void iorAnalysis ( ) throws DevFailed { if ( ! iorString . startsWith ( "IOR:" ) ) { throw DevFailedUtils . newDevFailed ( "CORBA_ERROR" , iorString + " not an IOR" ) ; } final ORB orb = ORBManager . getOrb ( ) ; final ParsedIOR pior = new ParsedIOR ( ( org . jacorb . orb . ORB ) orb , iorString ) ; final org . omg . IOP . IOR ior = pior . getIOR ( ) ; typeId = ior . type_id ; final List < Profile > profiles = pior . getProfiles ( ) ; for ( final Profile profile : profiles ) { if ( profile instanceof IIOPProfile ) { final IIOPProfile iiopProfile = ( ( IIOPProfile ) profile ) . to_GIOP_1_0 ( ) ; iiopVersion = ( int ) iiopProfile . version ( ) . major + "." + ( int ) iiopProfile . version ( ) . minor ; final String name = ( ( IIOPAddress ) iiopProfile . getAddress ( ) ) . getOriginalHost ( ) ; java . net . InetAddress iadd = null ; try { iadd = java . net . InetAddress . getByName ( name ) ; } catch ( final UnknownHostException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } hostName = iadd . getHostName ( ) ; port = ( ( IIOPAddress ) iiopProfile . getAddress ( ) ) . getPort ( ) ; if ( port < 0 ) { port += 65536 ; } } else { throw DevFailedUtils . newDevFailed ( "CORBA_ERROR" , iorString + " not an IOR" ) ; } } } | Make the IOR analyse |
19,775 | public void analyse_methods ( ) throws DevFailed { this . exe_method = analyse_method_exe ( device_class_name , exe_method_name ) ; if ( state_method_name != null ) this . state_method = analyse_method_state ( device_class_name , state_method_name ) ; } | Analyse the method given at construction time . |
19,776 | protected Method find_method ( Method [ ] meth_list , String meth_name ) throws DevFailed { int i ; Method meth_found = null ; for ( i = 0 ; i < meth_list . length ; i ++ ) { if ( meth_name . equals ( meth_list [ i ] . getName ( ) ) ) { for ( int j = i + 1 ; j < meth_list . length ; j ++ ) { if ( meth_name . equals ( meth_list [ j ] . getName ( ) ) ) { StringBuffer mess = new StringBuffer ( "Method overloading is not supported for command (Method name = " ) ; mess . append ( meth_name ) ; mess . append ( ")" ) ; Except . throw_exception ( "API_OverloadingNotSupported" , mess . toString ( ) , "TemplCommand.find_method()" ) ; } } meth_found = meth_list [ i ] ; break ; } } if ( i == meth_list . length ) { StringBuffer mess = new StringBuffer ( "Command " ) ; mess . append ( name ) ; mess . append ( ": Can't find method " ) ; mess . append ( meth_name ) ; Except . throw_exception ( "API_MethodNotFound" , mess . toString ( ) , "TemplCommand.find_method()" ) ; } return meth_found ; } | Retrieve a Method object from a Method list from its name . |
19,777 | protected int get_tango_type ( Class type_cl ) throws DevFailed { int type = 0 ; if ( type_cl . isArray ( ) == true ) { String type_name = type_cl . getComponentType ( ) . getName ( ) ; if ( type_name . equals ( "byte" ) ) type = Tango_DEVVAR_CHARARRAY ; else if ( type_name . equals ( "short" ) ) type = Tango_DEVVAR_SHORTARRAY ; else if ( type_name . equals ( "int" ) ) type = Tango_DEVVAR_LONGARRAY ; else if ( type_name . equals ( "float" ) ) type = Tango_DEVVAR_FLOATARRAY ; else if ( type_name . equals ( "double" ) ) type = Tango_DEVVAR_DOUBLEARRAY ; else if ( type_name . equals ( "java.lang.String" ) ) type = Tango_DEVVAR_STRINGARRAY ; else { StringBuffer mess = new StringBuffer ( "Argument array of " ) ; mess . append ( type_name ) ; mess . append ( " not supported" ) ; Except . throw_exception ( "API_MethodArgument" , mess . toString ( ) , "TemplCommandIn.get_tango_type()" ) ; } } else { String type_name = type_cl . getName ( ) ; if ( type_name . equals ( "boolean" ) ) type = Tango_DEV_BOOLEAN ; else if ( type_name . equals ( "short" ) ) type = Tango_DEV_SHORT ; else if ( type_name . equals ( "int" ) ) type = Tango_DEV_LONG ; else if ( type_name . equals ( "long" ) ) type = Tango_DEV_LONG64 ; else if ( type_name . equals ( "float" ) ) type = Tango_DEV_FLOAT ; else if ( type_name . equals ( "double" ) ) type = Tango_DEV_DOUBLE ; else if ( type_name . equals ( "java.lang.String" ) ) type = Tango_DEV_STRING ; else if ( type_name . equals ( "Tango.DevVarLongStringArray" ) ) type = Tango_DEVVAR_LONGSTRINGARRAY ; else if ( type_name . equals ( "Tango.DevVarDoubleStringArray" ) ) type = Tango_DEVVAR_DOUBLESTRINGARRAY ; else if ( type_name . equals ( "Tango.State" ) ) type = Tango_DEV_STATE ; else { StringBuffer mess = new StringBuffer ( "Argument " ) ; mess . append ( type_name ) ; mess . append ( " not supported" ) ; Except . throw_exception ( "API_MethodArgument" , mess . toString ( ) , "TemplCommandIn.get_tango_type()" ) ; } } return type ; } | Get the TANGO type for a command argument . |
19,778 | public boolean is_allowed ( DeviceImpl dev , Any data_in ) { if ( state_method == null ) return true ; else { try { java . lang . Object [ ] meth_param = new java . lang . Object [ 1 ] ; meth_param [ 0 ] = data_in ; java . lang . Object obj = state_method . invoke ( dev , meth_param ) ; return ( Boolean ) obj ; } catch ( InvocationTargetException e ) { return false ; } catch ( IllegalArgumentException e ) { return false ; } catch ( IllegalAccessException e ) { return false ; } } } | Invoke the command allowed method given at object creation time . |
19,779 | public static Object extract ( final DeviceData deviceDataArgout ) throws DevFailed { Object argout = null ; switch ( deviceDataArgout . getType ( ) ) { case TangoConst . Tango_DEV_SHORT : argout = Short . valueOf ( deviceDataArgout . extractShort ( ) ) ; break ; case TangoConst . Tango_DEV_USHORT : argout = Integer . valueOf ( deviceDataArgout . extractUShort ( ) ) . shortValue ( ) ; break ; case TangoConst . Tango_DEV_CHAR : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "out type Tango_DEV_CHAR not supported" , "CommandHelper.extract(deviceDataArgout)" ) ; break ; case TangoConst . Tango_DEV_UCHAR : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "out type Tango_DEV_UCHAR not supported" , "CommandHelper.extract(deviceDataArgout)" ) ; break ; case TangoConst . Tango_DEV_LONG : argout = Integer . valueOf ( deviceDataArgout . extractLong ( ) ) ; break ; case TangoConst . Tango_DEV_ULONG : argout = Long . valueOf ( deviceDataArgout . extractULong ( ) ) ; break ; case TangoConst . Tango_DEV_LONG64 : argout = Long . valueOf ( deviceDataArgout . extractLong64 ( ) ) ; break ; case TangoConst . Tango_DEV_ULONG64 : argout = Long . valueOf ( deviceDataArgout . extractULong64 ( ) ) ; break ; case TangoConst . Tango_DEV_INT : argout = Integer . valueOf ( deviceDataArgout . extractLong ( ) ) ; break ; case TangoConst . Tango_DEV_FLOAT : argout = Float . valueOf ( deviceDataArgout . extractFloat ( ) ) ; break ; case TangoConst . Tango_DEV_DOUBLE : argout = Double . valueOf ( deviceDataArgout . extractDouble ( ) ) ; break ; case TangoConst . Tango_DEV_STRING : argout = deviceDataArgout . extractString ( ) ; break ; case TangoConst . Tango_DEV_BOOLEAN : argout = Boolean . valueOf ( deviceDataArgout . extractBoolean ( ) ) ; break ; case TangoConst . Tango_DEV_STATE : argout = deviceDataArgout . extractDevState ( ) ; break ; case TangoConst . Tango_DEVVAR_DOUBLESTRINGARRAY : argout = deviceDataArgout . extractDoubleStringArray ( ) ; break ; case TangoConst . Tango_DEVVAR_LONGSTRINGARRAY : argout = deviceDataArgout . extractLongStringArray ( ) ; break ; default : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + deviceDataArgout . getType ( ) + " not supported" , "CommandHelper.extract(Short value,deviceDataArgout)" ) ; break ; } return argout ; } | Extract data to DeviceData to an Object |
19,780 | public void setLoggingLevel ( final String deviceName , final int loggingLevel ) { System . out . println ( "set logging level " + deviceName + "-" + LoggingLevel . getLevelFromInt ( loggingLevel ) ) ; logger . debug ( "set logging level to {} on {}" , LoggingLevel . getLevelFromInt ( loggingLevel ) , deviceName ) ; if ( rootLoggingLevel < loggingLevel ) { setRootLoggingLevel ( loggingLevel ) ; } loggingLevels . put ( deviceName , loggingLevel ) ; for ( final DeviceAppender appender : deviceAppenders . values ( ) ) { if ( deviceName . equalsIgnoreCase ( appender . getDeviceName ( ) ) ) { appender . setLevel ( loggingLevel ) ; break ; } } for ( final FileAppender appender : fileAppenders . values ( ) ) { if ( deviceName . equalsIgnoreCase ( appender . getDeviceName ( ) ) ) { appender . setLevel ( loggingLevel ) ; break ; } } } | Set the logging level of a device |
19,781 | public void setRootLoggingLevel ( final int loggingLevel ) { rootLoggingLevel = loggingLevel ; if ( rootLoggerBack != null ) { rootLoggerBack . setLevel ( LoggingLevel . getLevelFromInt ( loggingLevel ) ) ; } } | Set the level of the root logger |
19,782 | public void setLoggingLevel ( final int loggingLevel , final Class < ? > ... deviceClassNames ) { if ( rootLoggingLevel < loggingLevel ) { setRootLoggingLevel ( loggingLevel ) ; } System . out . println ( "set logging to " + LoggingLevel . getLevelFromInt ( loggingLevel ) ) ; final Logger tangoLogger = LoggerFactory . getLogger ( "org.tango.server" ) ; if ( tangoLogger instanceof ch . qos . logback . classic . Logger ) { final ch . qos . logback . classic . Logger logbackLogger = ( ch . qos . logback . classic . Logger ) tangoLogger ; logbackLogger . setLevel ( LoggingLevel . getLevelFromInt ( loggingLevel ) ) ; } final Logger blackboxLogger = LoggerFactory . getLogger ( Constants . CLIENT_REQUESTS_LOGGER ) ; if ( blackboxLogger instanceof ch . qos . logback . classic . Logger ) { final ch . qos . logback . classic . Logger logbackLogger = ( ch . qos . logback . classic . Logger ) blackboxLogger ; logbackLogger . setLevel ( LoggingLevel . getLevelFromInt ( loggingLevel ) ) ; } for ( int i = 0 ; i < deviceClassNames . length ; i ++ ) { final Logger deviceLogger = LoggerFactory . getLogger ( deviceClassNames [ i ] ) ; if ( deviceLogger instanceof ch . qos . logback . classic . Logger ) { final ch . qos . logback . classic . Logger logbackLogger = ( ch . qos . logback . classic . Logger ) deviceLogger ; logbackLogger . setLevel ( LoggingLevel . getLevelFromInt ( loggingLevel ) ) ; } } } | Set the level of all loggers of JTangoServer |
19,783 | public void addDeviceAppender ( final String deviceTargetName , final Class < ? > deviceClassName , final String loggingDeviceName ) throws DevFailed { if ( rootLoggerBack != null ) { logger . debug ( "add device appender {} on {}" , deviceTargetName , loggingDeviceName ) ; final DeviceAppender appender = new DeviceAppender ( deviceTargetName , loggingDeviceName ) ; deviceAppenders . put ( loggingDeviceName . toLowerCase ( Locale . ENGLISH ) , appender ) ; rootLoggerBack . addAppender ( appender ) ; setLoggingLevel ( LoggingLevel . DEBUG . toInt ( ) , deviceClassName ) ; setLoggingLevel ( loggingDeviceName , LoggingLevel . DEBUG . toInt ( ) ) ; appender . start ( ) ; } } | Logging of device sent to logviewer device |
19,784 | public void addFileAppender ( final String fileName , final String deviceName ) throws DevFailed { if ( rootLoggerBack != null ) { logger . debug ( "add file appender of {} in {}" , deviceName , fileName ) ; final String deviceNameLower = deviceName . toLowerCase ( Locale . ENGLISH ) ; final File f = new File ( fileName ) ; if ( ! f . exists ( ) ) { try { f . createNewFile ( ) ; } catch ( final IOException e ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . CANNOT_OPEN_FILE , "impossible to open file " + fileName ) ; } } if ( ! f . canWrite ( ) ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . CANNOT_OPEN_FILE , "impossible to open file " + fileName ) ; } System . out . println ( "create file " + f ) ; final LoggerContext loggerContext = ( LoggerContext ) LoggerFactory . getILoggerFactory ( ) ; final FileAppender rfAppender = new FileAppender ( deviceNameLower ) ; fileAppenders . put ( deviceNameLower , rfAppender ) ; rfAppender . setName ( "FILE-" + deviceNameLower ) ; rfAppender . setLevel ( rootLoggingLevel ) ; rfAppender . setFile ( fileName ) ; rfAppender . setAppend ( true ) ; rfAppender . setContext ( loggerContext ) ; final FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy ( ) ; rollingPolicy . setParent ( rfAppender ) ; rollingPolicy . setContext ( loggerContext ) ; rollingPolicy . setFileNamePattern ( fileName + "%i" ) ; rollingPolicy . setMaxIndex ( 1 ) ; rollingPolicy . setMaxIndex ( 3 ) ; rollingPolicy . start ( ) ; final SizeBasedTriggeringPolicy < ILoggingEvent > triggeringPolicy = new SizeBasedTriggeringPolicy < ILoggingEvent > ( ) ; triggeringPolicy . setMaxFileSize ( FileSize . valueOf ( "5 mb" ) ) ; triggeringPolicy . setContext ( loggerContext ) ; triggeringPolicy . start ( ) ; final PatternLayoutEncoder encoder = new PatternLayoutEncoder ( ) ; encoder . setContext ( loggerContext ) ; encoder . setPattern ( "%-5level %d %X{deviceName} - %thread | %logger{25}.%M:%L - %msg%n" ) ; encoder . start ( ) ; rfAppender . setEncoder ( encoder ) ; rfAppender . setRollingPolicy ( rollingPolicy ) ; rfAppender . setTriggeringPolicy ( triggeringPolicy ) ; rfAppender . start ( ) ; rootLoggerBack . addAppender ( rfAppender ) ; rfAppender . start ( ) ; } } | Add an file appender for a device |
19,785 | public void exportAll ( ) throws DevFailed { DatabaseFactory . getDatabase ( ) . loadCache ( serverName , hostName ) ; final DeviceClassBuilder clazz = new DeviceClassBuilder ( AdminDevice . class , Constants . ADMIN_SERVER_CLASS_NAME ) ; deviceClassList . add ( clazz ) ; final DeviceImpl dev = buildDevice ( Constants . ADMIN_DEVICE_DOMAIN + "/" + serverName , clazz ) ; ( ( AdminDevice ) dev . getBusinessObject ( ) ) . setTangoExporter ( this ) ; ( ( AdminDevice ) dev . getBusinessObject ( ) ) . setClassList ( deviceClassList ) ; exportDevices ( ) ; TangoCacheManager . initPoolConf ( ) ; DatabaseFactory . getDatabase ( ) . clearCache ( ) ; } | Build all devices of all classes that are is this executable |
19,786 | public void exportDevices ( ) throws DevFailed { for ( final Entry < String , Class < ? > > entry : tangoClasses . entrySet ( ) ) { final String tangoClass = entry . getKey ( ) ; final Class < ? > deviceClass = entry . getValue ( ) ; logger . debug ( "loading class {}" , deviceClass . getCanonicalName ( ) ) ; final DeviceClassBuilder deviceClassBuilder = new DeviceClassBuilder ( deviceClass , tangoClass ) ; deviceClassList . add ( deviceClassBuilder ) ; final String [ ] deviceList = DatabaseFactory . getDatabase ( ) . getDeviceList ( serverName , tangoClass ) ; logger . debug ( "devices found {}" , Arrays . toString ( deviceList ) ) ; for ( final String deviceName : deviceList ) { buildDevice ( deviceName , deviceClassBuilder ) ; } } } | Export all devices except admin device |
19,787 | public void unexportDevices ( ) throws DevFailed { xlogger . entry ( ) ; final List < DeviceClassBuilder > clazzToRemove = new ArrayList < DeviceClassBuilder > ( ) ; for ( final DeviceClassBuilder clazz : deviceClassList ) { if ( ! clazz . getDeviceClass ( ) . equals ( AdminDevice . class ) ) { for ( final DeviceImpl device : clazz . getDeviceImplList ( ) ) { logger . debug ( "unexport device {}" , device . getName ( ) ) ; ORBUtils . unexportDevice ( device ) ; } clazz . clearDevices ( ) ; clazzToRemove . add ( clazz ) ; } } for ( final DeviceClassBuilder deviceClassBuilder : clazzToRemove ) { deviceClassList . remove ( deviceClassBuilder ) ; } xlogger . exit ( ) ; } | Unexport all except admin device |
19,788 | public void update ( ) throws DevFailed { xlogger . entry ( ) ; final Map < String , String [ ] > property = PropertiesUtils . getDeviceProperties ( deviceName ) ; if ( property != null && property . size ( ) != 0 ) { try { propertyMethod . invoke ( businessObject , property ) ; } catch ( final IllegalArgumentException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } catch ( final IllegalAccessException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } catch ( final SecurityException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } catch ( final InvocationTargetException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } } xlogger . exit ( ) ; } | update all properties and values of this device |
19,789 | private synchronized void add ( final String ... attributes ) throws DevFailed { userAttributesNames = new String [ attributes . length ] ; devices = new DeviceProxy [ attributes . length ] ; int i = 0 ; for ( final String attributeName : attributes ) { final String deviceName = TangoUtil . getfullDeviceNameForAttribute ( attributeName ) . toLowerCase ( Locale . ENGLISH ) ; final String fullAttribute = TangoUtil . getfullAttributeNameForAttribute ( attributeName ) . toLowerCase ( Locale . ENGLISH ) ; userAttributesNames [ i ] = fullAttribute ; try { final DeviceProxy device = ProxyFactory . getInstance ( ) . createDeviceProxy ( deviceName ) ; devices [ i ++ ] = device ; if ( ! devicesMap . containsKey ( deviceName ) ) { devicesMap . put ( deviceName , device ) ; } } catch ( final DevFailed e ) { if ( throwExceptions ) { throw e ; } else { devices [ i ++ ] = null ; if ( ! devicesMap . containsKey ( deviceName ) ) { devicesMap . put ( deviceName , null ) ; } } } final String attribute = fullAttribute . split ( "/" ) [ 3 ] ; if ( ! attributesMap . containsKey ( deviceName ) ) { final List < String > attributesNames = new ArrayList < String > ( ) ; attributesNames . add ( attribute ) ; attributesMap . put ( deviceName , attributesNames ) ; } else { attributesMap . get ( deviceName ) . add ( attribute ) ; } } } | Add a list of devices in the group or add a list of patterns |
19,790 | public static Object getWritePart ( final Object array , final AttrWriteType writeType ) { if ( writeType . equals ( AttrWriteType . READ_WRITE ) ) { return Array . get ( array , 1 ) ; } else { return Array . get ( array , 0 ) ; } } | Extract the write part of a scalar attribute |
19,791 | @ SuppressWarnings ( "unchecked" ) public static < T > T castToType ( final Class < T > type , final Object val ) throws DevFailed { T result ; if ( val == null ) { result = null ; } else if ( type . isAssignableFrom ( val . getClass ( ) ) ) { result = ( T ) val ; } else { LOGGER . debug ( "converting {} to {}" , val . getClass ( ) . getCanonicalName ( ) , type . getCanonicalName ( ) ) ; Object array = val ; if ( ! val . getClass ( ) . isArray ( ) && type . isArray ( ) ) { array = Array . newInstance ( val . getClass ( ) , 1 ) ; Array . set ( array , 0 , val ) ; } final Transmorph transmorph = new Transmorph ( creatConv ( ) ) ; try { result = transmorph . convert ( array , type ) ; } catch ( final ConverterException e ) { LOGGER . error ( "convertion error" , e ) ; throw DevFailedUtils . newDevFailed ( e ) ; } } return result ; } | Convert an object to another object . |
19,792 | public static Object extractReadOrWrite ( final Part part , final DeviceAttribute da , final Object readWrite ) throws DevFailed { final Object result ; final int dimRead ; if ( da . getDimY ( ) != 0 ) { dimRead = da . getDimX ( ) * da . getDimY ( ) ; } else { dimRead = da . getDimX ( ) ; } if ( Array . getLength ( readWrite ) < dimRead ) { result = readWrite ; } else if ( Part . READ . equals ( part ) ) { result = Array . newInstance ( readWrite . getClass ( ) . getComponentType ( ) , dimRead ) ; System . arraycopy ( readWrite , 0 , result , 0 , dimRead ) ; } else { result = Array . newInstance ( readWrite . getClass ( ) . getComponentType ( ) , Array . getLength ( readWrite ) - dimRead ) ; System . arraycopy ( readWrite , dimRead , result , 0 , Array . getLength ( result ) ) ; } return result ; } | Extract read or write part of a Tango attribute . For spectrum and image |
19,793 | public Any execute ( DeviceImpl device , Any in_any ) throws DevFailed { Util . out4 . println ( "GetLoggingLevelCmd::execute(): arrived" ) ; String [ ] dvsa = null ; try { dvsa = extract_DevVarStringArray ( in_any ) ; } catch ( DevFailed df ) { Util . out3 . println ( "GetLoggingLevelCmd::execute() ) ; Except . re_throw_exception ( df , "API_IncompatibleCmdArgumentType" , "Imcompatible command argument type, expected type is : DevVarStringArray" , "GetLoggingLevelCmd.execute" ) ; } Any out_any = insert ( Logging . instance ( ) . get_logging_level ( dvsa ) ) ; Util . out4 . println ( "Leaving GetLoggingLevelCmd.execute()" ) ; return out_any ; } | Executes the GetLoggingLevelCmd TANGO command |
19,794 | public static String getFirstFullTangoHost ( ) throws DevFailed { final String TANGO_HOST_ERROR = "API_GetTangoHostFailed" ; String host = getFirstHost ( ) ; try { final InetAddress iadd = InetAddress . getByName ( host ) ; host = iadd . getCanonicalHostName ( ) ; } catch ( final UnknownHostException e ) { throw DevFailedUtils . newDevFailed ( TANGO_HOST_ERROR , e . toString ( ) ) ; } return host + ':' + getFirstPort ( ) ; } | Returns the TANGO_HOST with full qualified name . |
19,795 | private Vector get_hierarchy ( ) { synchronized ( this ) { final Vector h = new Vector ( ) ; final Iterator it = elements . iterator ( ) ; while ( it . hasNext ( ) ) { final GroupElement e = ( GroupElement ) it . next ( ) ; if ( e instanceof GroupDeviceElement ) { h . add ( e ) ; } else { h . add ( ( ( Group ) e ) . get_hierarchy ( ) ) ; } } return h ; } } | Returns the group s hierarchy |
19,796 | private int get_size_i ( final boolean fwd ) { int size = 0 ; final Iterator it = elements . iterator ( ) ; while ( it . hasNext ( ) ) { final GroupElement e = ( GroupElement ) it . next ( ) ; if ( e instanceof GroupDeviceElement || fwd ) { size += e . get_size ( true ) ; } } return size ; } | Returns the group s size - internal impl |
19,797 | private boolean add_i ( final GroupElement e ) { if ( e == null || e == this ) { System . out . println ( "Group::add_i::failed to add " + e . get_name ( ) + " (null or self)" ) ; return false ; } final GroupElement ge = find_i ( e . get_name ( ) , e instanceof Group ? false : true ) ; if ( ge != null && ge != this ) { System . out . println ( "Group::add_i::failed to add " + e . get_name ( ) + " (already attached)" ) ; return false ; } elements . add ( e ) ; e . set_parent ( this ) ; return true ; } | Adds an element to the group |
19,798 | public Any insert ( boolean data ) throws DevFailed { Any out_any = alloc_any ( ) ; out_any . insert_boolean ( data ) ; return out_any ; } | Create a CORBA Any object and insert a boolean data in it . |
19,799 | public Any insert ( short data ) throws DevFailed { Any out_any = alloc_any ( ) ; out_any . insert_short ( data ) ; return out_any ; } | Create a CORBA Any object and insert a short data in it . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.