idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
19,700
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 .
358
16
19,701
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 += "&lt;" + Strings . join ( parametersTypeStrings , "," ) + "&gt;" ; } } typeString += type . dimension ( ) ; return typeString ; }
Returns type string .
399
4
19,702
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 .
454
8
19,703
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
144
14
19,704
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 .
72
16
19,705
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 .
163
6
19,706
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 .
115
5
19,707
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 ( "!" ) ) ; //strip out only the JAR file try ( JarFile jar = new JarFile ( jarPath ) ) { Enumeration < JarEntry > entries = jar . entries ( ) ; //gives ALL entries in jar 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 ) ) { //filter according to the path String entry = name . substring ( relativeResourceDirName . length ( ) ) ; int checkSubdir = entry . indexOf ( "/" ) ; if ( checkSubdir < 0 ) { // not a subdirectory 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 .
496
21
19,708
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 .
69
30
19,709
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 .
80
13
19,710
@ Override 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 .
129
17
19,711
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 .
166
16
19,712
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 .
174
18
19,713
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 .
78
11
19,714
@ Override 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 ( ) ) { // if (!stage.isVisible() || !dialog.isEnabled()) { // String msg = "Ignore the dialog '" + dialog.getTitle() + "' cause:\n "; // if (!dialog.isVisible()) { // msg += "\t is not visible"; // } // if (!dialog.isEnabled()) { // msg += "\t is not enabled"; // } // LOGGER.info(msg); // continue; // } // if (activateAndFocusComponentWindow(dialog)) // { // targetPopup = dialog; // } // else // { // LOGGER.info("Ignore the dialog '" + dialog.getTitle() + "' cause:\n \t is not focused"); // } } // component = findTextComponent(targetPopup); // // if ( component != null && !component.isDisabled() && checkComponentIsVisible(component) ) // break; 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 .
425
14
19,715
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 ' ' : int count = tabSize - ( width % tabSize ) ; width += count ; while ( -- count >= 0 ) { buf . append ( ' ' ) ; } break ; case ' ' : 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 .
155
11
19,716
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 .
61
15
19,717
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 .
102
11
19,718
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 .
149
17
19,719
protected static List < Stage > findPopups ( ) throws QTasteTestFailException { //find all popups List < Stage > popupFound = new ArrayList <> ( ) ; for ( Stage stage : getStages ( ) ) { Parent root = stage . getScene ( ) . getRoot ( ) ; if ( isAPopup ( stage ) ) { //it's maybe a popup... a popup is modal and not resizable and has a DialogPane root 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 .
156
26
19,720
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 .
301
9
19,721
protected static List < JDialog > findPopups ( ) { //find all popups List < JDialog > popupFound = new ArrayList <> ( ) ; for ( Window window : getDisplayableWindows ( ) ) { // LOGGER.debug("parse window - type : " + window.getClass()); if ( isAPopup ( window ) ) { //it's maybe a popup... a popup is modal and not resizable and containt a JOptionPane component. 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 .
153
24
19,722
public static String execute ( String fileName , String ... arguments ) throws PyException { return execute ( fileName , true , arguments ) ; }
Executes a python script and return its output .
29
10
19,723
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 .
279
11
19,724
public static byte [ ] toNullTerminatedFixedSizeByteArray ( String s , int length ) { if ( s . length ( ) >= length ) { s = s . substring ( 0 , length - 1 ) ; } while ( s . length ( ) < length ) { s += ' ' ; } return s . getBytes ( ) ; }
Converts a string to a null - terminated fixed size byte array .
73
14
19,725
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 .
73
12
19,726
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
131
5
19,727
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
93
6
19,728
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
222
10
19,729
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 .
42
9
19,730
public int exec ( String cmd , Map < String , String > env , OutputStream stdout , OutputStream stderr , ByteArrayOutputStream output , File dir ) throws IOException , InterruptedException { //logger.debug("Executing '" + cmd + "'"); 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 ( ) ; //if (output.size() > 0) { // logger.debug("Executed command output:\n" + output.toString()); //} return exitCode ; } finally { process = null ; } }
Executes the a command specified in the specified directory .
348
11
19,731
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 .
167
13
19,732
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 .
93
13
19,733
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 .
399
27
19,734
private synchronized void readObject ( java . io . ObjectInputStream in ) throws IOException , ClassNotFoundException { in . defaultReadObject ( ) ; // rebuild hash hashtable hash = new Hashtable <> ( ) ; for ( NameValue < N , V > nameValue : order ) { putInHash ( nameValue . name , nameValue . value ) ; } }
and rebuild hash hashtable
79
5
19,735
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 .
85
10
19,736
public static String getIndent ( String line ) { if ( line == null || line . length ( ) == 0 ) { return "" ; } int i = 0 ; while ( i < line . length ( ) && line . charAt ( i ) == ' ' ) { 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
73
26
19,737
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 .
38
13
19,738
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 .
50
9
19,739
protected static String getSubstitutedTemplateContent ( String templateContent , NamesValuesList < String , String > namesValues ) { String templateContentSubst = templateContent ; // substitute the name/values for ( NameValue < String , String > nameValue : namesValues ) { templateContentSubst = templateContentSubst . replace ( nameValue . name , nameValue . value ) ; } return templateContentSubst ; }
Substitutes names by values in template and return result .
89
12
19,740
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
89
10
19,741
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" ) ; } } // code for old jacorb 2.3 // final List<IIOPProfile> profiles = pior.getProfiles(); // for (IIOPProfile profile : profiles) { // iiopVersion = (int) profile.version().major + "." + (int) // p.version().minor; // final String name = ((IIOPAddress) // profile.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) profile.getAddress()).getPort(); // if (port < 0) { // port += 65536; // } // } }
Make the IOR analyse
599
5
19,742
public void analyse_methods ( ) throws DevFailed { // // Analyse the execution method given by the user // this . exe_method = analyse_method_exe ( device_class_name , exe_method_name ) ; // // Analyse the state method if one is given by the user // if ( state_method_name != null ) this . state_method = analyse_method_state ( device_class_name , state_method_name ) ; }
Analyse the method given at construction time .
103
9
19,743
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 .
303
13
19,744
protected int get_tango_type ( Class type_cl ) throws DevFailed { int type = 0 ; // // For arrays // 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()" ) ; } } // // For all the other types // 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 .
694
11
19,745
public boolean is_allowed ( DeviceImpl dev , Any data_in ) { if ( state_method == null ) return true ; else { // // If the Method reference is not null, execute the method with the invoke // method // 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 .
149
12
19,746
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
714
9
19,747
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 ) ; } // setLoggingLevel(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
233
7
19,748
public void setRootLoggingLevel ( final int loggingLevel ) { rootLoggingLevel = loggingLevel ; if ( rootLoggerBack != null ) { rootLoggerBack . setLevel ( LoggingLevel . getLevelFromInt ( loggingLevel ) ) ; } }
Set the level of the root logger
56
7
19,749
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
415
12
19,750
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 ) ; // debug level by default setLoggingLevel ( LoggingLevel . DEBUG . toInt ( ) , deviceClassName ) ; setLoggingLevel ( loggingDeviceName , LoggingLevel . DEBUG . toInt ( ) ) ; appender . start ( ) ; } }
Logging of device sent to logviewer device
182
10
19,751
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 ) ; } // debug level by default // setLoggingLevel(deviceName, LoggingLevel.DEBUG.toInt()); 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.setContext(appender.getContext()); rfAppender . setFile ( fileName ) ; rfAppender . setAppend ( true ) ; rfAppender . setContext ( loggerContext ) ; final FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy ( ) ; // rolling policies need to know their parent // it's one of the rare cases, where a sub-component knows about its parent 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 ( ) ; // OPTIONAL: print logback internal status messages // StatusPrinter.print(loggerContext); } }
Add an file appender for a device
729
8
19,752
@ Override public void exportAll ( ) throws DevFailed { // load tango db cache DatabaseFactory . getDatabase ( ) . loadCache ( serverName , hostName ) ; // special case for admin device 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 ) ; // load server class exportDevices ( ) ; // init polling pool config TangoCacheManager . initPoolConf ( ) ; // clear tango db cache (used only for server start-up phase) DatabaseFactory . getDatabase ( ) . clearCache ( ) ; }
Build all devices of all classes that are is this executable
217
11
19,753
@ Override public void exportDevices ( ) throws DevFailed { // load server class 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 ) ; // export all its devices final String [ ] deviceList = DatabaseFactory . getDatabase ( ) . getDeviceList ( serverName , tangoClass ) ; logger . debug ( "devices found {}" , Arrays . toString ( deviceList ) ) ; // if (deviceList.length == 0) { // throw DevFailedUtils.newDevFailed(ExceptionMessages.DB_ACCESS, "No device defined in database for class " // + tangoClass); // } for ( final String deviceName : deviceList ) { buildDevice ( deviceName , deviceClassBuilder ) ; } } }
Export all devices except admin device
254
6
19,754
@ Override 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 ) ; } // unregisterServer(); // deviceClassList.clear(); xlogger . exit ( ) ; }
Unexport all except admin device
203
7
19,755
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
182
8
19,756
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
332
14
19,757
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
64
10
19,758
@ 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 ( ) ) ; // if input is not an array and we want to convert it to an array. // Put // the value in an array 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 .
281
8
19,759
public static Object extractReadOrWrite ( final Part part , final DeviceAttribute da , final Object readWrite ) throws DevFailed { // separate read and written values 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
232
16
19,760
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() --> Wrong argument type" ) ; 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
205
12
19,761
public static String getFirstFullTangoHost ( ) throws DevFailed { // TODO final String TANGO_HOST_ERROR = "API_GetTangoHostFailed" ; // Get the tango_host String host = getFirstHost ( ) ; try { // Get FQDN for host 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 .
151
13
19,762
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
107
5
19,763
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
85
8
19,764
private boolean add_i ( final GroupElement e ) { if ( e == null || e == this ) { // -DEBUG 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 ) { // -DEBUG 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
163
6
19,765
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 .
41
14
19,766
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 .
40
14
19,767
public Any insert ( int data ) throws DevFailed { Any out_any = alloc_any ( ) ; out_any . insert_long ( data ) ; return out_any ; }
Create a CORBA Any object and insert an int data in it .
40
14
19,768
public Any insert ( float data ) throws DevFailed { Any out_any = alloc_any ( ) ; out_any . insert_float ( data ) ; return out_any ; }
Create a CORBA Any object and insert a float data in it .
40
14
19,769
public Any insert ( double data ) throws DevFailed { Any out_any = alloc_any ( ) ; out_any . insert_double ( data ) ; return out_any ; }
Create a CORBA Any object and insert a double data in it .
40
14
19,770
public Any insert ( String data ) throws DevFailed { Any out_any = alloc_any ( ) ; out_any . insert_string ( data ) ; return out_any ; }
Create a CORBA Any object and insert a String in it .
40
13
19,771
public Any insert ( byte [ ] data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevVarCharArrayHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a byte array in it .
46
14
19,772
public Any insert ( short [ ] data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevVarShortArrayHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a short array in it .
46
14
19,773
public Any insert ( int [ ] data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevVarLongArrayHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a int array in it .
46
14
19,774
public Any insert ( float [ ] data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevVarFloatArrayHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a float array in it .
46
14
19,775
public Any insert ( double [ ] data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevVarDoubleArrayHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a double array in it .
46
14
19,776
public Any insert ( String [ ] data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevVarStringArrayHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a String array in it .
46
14
19,777
public Any insert ( DevVarLongStringArray data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevVarLongStringArrayHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a DevVarLongStringArray type in it .
49
18
19,778
public Any insert ( DevVarDoubleStringArray data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevVarDoubleStringArrayHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a DevVarDoubleStringArray type in it .
49
18
19,779
public Any insert ( DevState data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevStateHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a device state in it .
43
14
19,780
public boolean extract_DevBoolean ( Any in ) throws DevFailed { boolean data = false ; try { data = in . extract_boolean ( ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevBoolean" ) ; } return data ; }
Extract a boolean data from a CORBA Any object .
62
12
19,781
public short extract_DevShort ( Any in ) throws DevFailed { short data = 0 ; try { data = in . extract_short ( ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevShort" ) ; } return data ; }
Extract a short data from a CORBA Any object .
59
12
19,782
public float extract_DevFloat ( Any in ) throws DevFailed { float data = 0 ; try { data = in . extract_float ( ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevFloat" ) ; } return data ; }
Extract a float data from a CORBA Any object .
59
12
19,783
public double extract_DevDouble ( Any in ) throws DevFailed { double data = 0 ; try { data = in . extract_double ( ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevDouble" ) ; } return data ; }
Extract a double data from a CORBA Any object .
59
12
19,784
public String extract_DevString ( Any in ) throws DevFailed { String data = null ; try { //data = in.extract_string(); data = DevStringHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevString" ) ; } return data ; }
Extract a String from a CORBA Any object .
70
11
19,785
public short extract_DevUShort ( Any in ) throws DevFailed { short data = 0 ; try { data = in . extract_ushort ( ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevUShort" ) ; } return data ; }
Extract a DevUShort data from a CORBA Any object .
62
14
19,786
public byte [ ] extract_DevVarCharArray ( Any in ) throws DevFailed { byte [ ] data = null ; try { data = DevVarCharArrayHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevVarCharArray" ) ; } return data ; }
Extract a byte array from a CORBA Any object .
70
12
19,787
public short [ ] extract_DevVarShortArray ( Any in ) throws DevFailed { short [ ] data = null ; try { data = DevVarShortArrayHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevVarShortArray" ) ; } return data ; }
Extract a short array from a CORBA Any object .
70
12
19,788
public float [ ] extract_DevVarFloatArray ( Any in ) throws DevFailed { float [ ] data = null ; try { data = DevVarFloatArrayHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevVarFloatArray" ) ; } return data ; }
Extract a float array from a CORBA Any object .
70
12
19,789
public double [ ] extract_DevVarDoubleArray ( Any in ) throws DevFailed { double [ ] data = null ; try { data = DevVarDoubleArrayHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevVarDoubleArray" ) ; } return data ; }
Extract a double array from a CORBA Any object .
70
12
19,790
public short [ ] extract_DevVarUShortArray ( Any in ) throws DevFailed { short [ ] data = null ; try { data = DevVarUShortArrayHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevVarUShortArray" ) ; } return data ; }
Extract a DevVarUShortArray type from a CORBA Any object .
73
16
19,791
public String [ ] extract_DevVarStringArray ( Any in ) throws DevFailed { String [ ] data = null ; try { data = DevVarStringArrayHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevVarStringArray" ) ; } return data ; }
Extract a DevVarStringArray type from a CORBA Any object .
70
15
19,792
public DevVarLongStringArray extract_DevVarLongStringArray ( Any in ) throws DevFailed { DevVarLongStringArray data = null ; try { data = DevVarLongStringArrayHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevVarLongStringArray" ) ; } return data ; }
Extract a DevVarLongStringArray type from a CORBA Any object .
77
16
19,793
public DevVarDoubleStringArray extract_DevVarDoubleStringArray ( Any in ) throws DevFailed { DevVarDoubleStringArray data = null ; try { data = DevVarDoubleStringArrayHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevVarDoubleStringArray" ) ; } return data ; }
Extract a DevVarDoubleStringArray type from a CORBA Any object .
77
16
19,794
public DevState extract_DevState ( Any in ) throws DevFailed { DevState data = null ; try { data = DevStateHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevState" ) ; } return data ; }
Extract a DevState type from a CORBA Any object .
62
13
19,795
protected void pushAttributeValueEvent ( ZMQ . Socket eventSocket ) throws DevFailed { xlogger . entry ( ) ; eventTrigger . setError ( null ) ; eventTrigger . updateProperties ( ) ; if ( isSendEvent ( ) ) { sendAttributeValueEvent ( eventSocket ) ; } xlogger . exit ( ) ; }
Fire an event containing a value is condition is valid .
73
11
19,796
protected void pushAttributeDataReadyEvent ( final int counter , ZMQ . Socket eventSocket ) throws DevFailed { xlogger . entry ( ) ; try { final AttDataReady dataReady = new AttDataReady ( attribute . getName ( ) , attribute . getTangoType ( ) , counter ) ; synchronized ( eventSocket ) { EventUtilities . sendToSocket ( eventSocket , fullName , counter , EventUtilities . marshall ( dataReady ) ) ; } } catch ( final org . zeromq . ZMQException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } xlogger . exit ( ) ; }
Send a data ready event
142
5
19,797
protected void pushDevFailedEvent ( final DevFailed devFailed , ZMQ . Socket eventSocket ) throws DevFailed { xlogger . entry ( ) ; eventTrigger . updateProperties ( ) ; eventTrigger . setError ( devFailed ) ; if ( isSendEvent ( ) ) { try { synchronized ( eventSocket ) { EventUtilities . sendToSocket ( eventSocket , fullName , counter ++ , true , EventUtilities . marshall ( devFailed ) ) ; } } catch ( final org . zeromq . ZMQException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } } xlogger . exit ( ) ; }
Fire an event containing a DevFailed .
149
9
19,798
private boolean isSendEvent ( ) throws DevFailed { boolean send = false ; if ( ( eventTrigger . doCheck ( ) && eventTrigger . isSendEvent ( ) ) || ! eventTrigger . doCheck ( ) ) { send = true ; } return send ; }
check if send event
57
4
19,799
public Any execute ( DeviceImpl device , Any in_any ) throws DevFailed { Util . out4 . println ( "SetLoggingLevelCmd::execute(): arrived" ) ; DevVarLongStringArray dvlsa = null ; try { dvlsa = extract_DevVarLongStringArray ( in_any ) ; } catch ( DevFailed df ) { Util . out3 . println ( "SetLoggingLevelCmd::execute() --> Wrong argument type" ) ; Except . re_throw_exception ( df , "API_IncompatibleCmdArgumentType" , "Imcompatible command argument type, expected type is : DevVarLongStringArray" , "SetLoggingLevelCmd.execute" ) ; } Logging . instance ( ) . set_logging_level ( dvlsa ) ; return Util . return_empty_any ( "SetLoggingLevel" ) ; }
Executes the SetLoggingLevelCmd TANGO command
195
12