idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
119,600 | public static PluginFileDependency fileInTcMenu ( String file ) { return new PluginFileDependency ( file , PackagingType . WITHIN_TCMENU , Map . of ( ) ) ; } | Creates an instance of the class that indicates the file is within tcMenu itself . Don t use for new plugins prefer to package arduino code in the plugin or a new library . |
119,601 | public void initialise ( String root ) { functionCalls . clear ( ) ; variables . clear ( ) ; initCreator ( root ) ; } | Do not override this use initCreator |
119,602 | protected void addExportVariableIfPresent ( String variable , String typeName ) { String expVar = findPropertyValue ( variable ) . getLatestValue ( ) ; if ( expVar != null && ! expVar . isEmpty ( ) ) { addVariable ( new CodeVariableBuilder ( ) . exportOnly ( ) . variableType ( typeName ) . variableName ( expVar ) ) ; }... | Adds a variable for export only when a property is present |
119,603 | protected void addLibraryFiles ( String ... files ) { libraryFiles . addAll ( Arrays . stream ( files ) . map ( PluginFileDependency :: fileInTcMenu ) . collect ( Collectors . toList ( ) ) ) ; } | adds requirements on one or more files that must be copied into the project this is only for files that already exist in tcMenu library prefer to use the other version that takes PluiginFileDependency |
119,604 | public CreatorProperty findPropertyValue ( String name ) { return properties ( ) . stream ( ) . filter ( p -> name . equals ( p . getName ( ) ) ) . findFirst ( ) . orElse ( EMPTY ) ; } | Gets a property by it s name |
119,605 | public int findPropertyValueAsIntWithDefault ( String name , int defVal ) { return properties ( ) . stream ( ) . filter ( p -> name . equals ( p . getName ( ) ) ) . map ( CreatorProperty :: getLatestValueAsInt ) . findFirst ( ) . orElse ( defVal ) ; } | Find the integer value of a property or a default if it is not set |
119,606 | private Optional < String > getArduinoPathWithDialog ( ) { String savedPath = Preferences . userNodeForPackage ( ArduinoLibraryInstaller . class ) . get ( ARDUINO_CUSTOM_PATH , homeDirectory ) ; Path libsPath = Paths . get ( savedPath , "libraries" ) ; if ( Files . exists ( libsPath ) ) return Optional . of ( savedPath... | This method will be called internally by the above method when a non standard layout is detected . |
119,607 | public Optional < Path > findLibraryInstall ( String libraryName ) { return getArduinoDirectory ( ) . map ( path -> { Path libsDir = path . resolve ( "libraries" ) ; Path tcMenuDir = libsDir . resolve ( libraryName ) ; if ( Files . exists ( tcMenuDir ) ) { return tcMenuDir ; } return null ; } ) ; } | Find the library installation of a specific named library using standard conventions |
119,608 | public VersionInfo getVersionOfLibrary ( String name , boolean inEmbeddedDir ) throws IOException { Path startPath ; if ( inEmbeddedDir ) { startPath = Paths . get ( embeddedDirectory , name ) ; } else { Path ardDir = getArduinoDirectory ( ) . orElseThrow ( IOException :: new ) ; startPath = ardDir . resolve ( "librari... | Get the version of a library either from the packaged version or currently installed depending how it s called . |
119,609 | public boolean isLibraryUpToDate ( String name ) { Optional < Path > libInst = findLibraryInstall ( name ) ; if ( ! libInst . isPresent ( ) ) return false ; try { VersionInfo srcVer = getVersionOfLibrary ( name , true ) ; VersionInfo dstVer = getVersionOfLibrary ( name , false ) ; return dstVer . isSameOrNewerThan ( sr... | Check if the named library is the same version or new than the packaged version |
119,610 | public void copyLibraryFromPackage ( String libraryName ) throws IOException { Path ardDir = getArduinoDirectory ( ) . orElseThrow ( IOException :: new ) ; Path source = Paths . get ( embeddedDirectory ) . resolve ( libraryName ) ; Path dest = ardDir . resolve ( "libraries/" + libraryName ) ; if ( ! Files . exists ( de... | Copies the library from the packaged version into the installation directory . |
119,611 | private void copyLibraryRecursive ( Path input , Path output ) throws IOException { for ( Path dirItem : Files . list ( input ) . collect ( Collectors . toList ( ) ) ) { Path outputName = output . resolve ( dirItem . getFileName ( ) ) ; if ( Files . isDirectory ( dirItem ) ) { if ( ! Files . exists ( outputName ) ) Fil... | Recursive copier for the above copy method . It calls recursively for subdirectories to ensure a full copy |
119,612 | public void initialise ( MenuTree menuTree , RemoteMenuController remoteControl ) { this . menuTree = menuTree ; this . remoteControl = remoteControl ; executor . scheduleAtFixedRate ( this :: updatedFieldChecker , 1000 , 100 , TimeUnit . MILLISECONDS ) ; remoteControl . addListener ( new RemoteControllerListener ( ) {... | initialise is called by the App to start the application up . In here we register a listener for communication events and start the comms . |
119,613 | private int buildGrid ( SubMenuItem subMenu , int inset , int gridPosition ) { for ( MenuItem item : menuTree . getMenuItems ( subMenu ) ) { if ( item . hasChildren ( ) ) { Label itemLbl = new Label ( "SubMenu " + item . getName ( ) ) ; itemLbl . setPadding ( new Insets ( 12 , 10 , 12 , inset ) ) ; itemLbl . setStyle (... | Here we go through all the menu items and populate a GridPane with controls to display and edit each item . We start at ROOT and through every item in all submenus . This is a recursive function that is repeatedly called on sub menu s until we ve finished all items . |
119,614 | private void renderItemValue ( MenuItem item ) { Label lblForVal = itemIdToLabel . get ( item . getId ( ) ) ; if ( lblForVal == null ) return ; Optional < String > value = MenuItemHelper . visitWithResult ( item , new AbstractMenuItemVisitor < > ( ) { public void visit ( AnalogMenuItem item ) { MenuState < Integer > st... | When there s a change in value for an item this code takes care of rendering it . |
119,615 | private void updateConnectionDetails ( ) { Stage stage = ( Stage ) platformLabel . getScene ( ) . getWindow ( ) ; connectedLabel . setText ( connected ? "YES" : "NO" ) ; remoteInfo . ifPresent ( remote -> { remoteNameLabel . setText ( remote . getName ( ) ) ; versionLabel . setText ( remote . getMajorVersion ( ) + "." ... | When the connectivity changes we update the fields on the FX thread we must not update any UI fields on the connection thread . |
119,616 | public void makeAdjustments ( Consumer < String > logger , String inoFile , String projectName , List < String > callbacks ) throws IOException { this . logger = logger ; changed = false ; Path source = Paths . get ( inoFile ) ; if ( ! Files . exists ( source ) ) { logger . accept ( "No existing infoFile, generating an... | Is able to update and round trip an ino file for the items that tcMenu needs . |
119,617 | public FunctionCallBuilder requiresHeader ( String headerName , boolean useQuotes ) { headers . add ( new HeaderDefinition ( headerName , useQuotes , HeaderDefinition . PRIORITY_NORMAL ) ) ; return this ; } | Add a requirement that a header file needs to be included for this to work |
119,618 | public void addMenuItem ( SubMenuItem parent , MenuItem item ) { SubMenuItem subMenu = ( parent != null ) ? parent : ROOT ; synchronized ( subMenuItems ) { ArrayList < MenuItem > subMenuChildren = subMenuItems . computeIfAbsent ( subMenu , sm -> new ArrayList < > ( ) ) ; subMenuChildren . add ( item ) ; if ( item . has... | add a new menu item to a sub menu for the top level menu use ROOT . |
119,619 | public void addOrUpdateItem ( int parentId , MenuItem item ) { synchronized ( subMenuItems ) { getSubMenuById ( parentId ) . ifPresent ( subMenu -> { if ( getMenuItems ( subMenu ) . stream ( ) . anyMatch ( it -> it . getId ( ) == item . getId ( ) ) ) { replaceMenuById ( asSubMenu ( subMenu ) , item ) ; } else { addMenu... | This will either add or update an existing item depending if the ID is already present . |
119,620 | public Optional < SubMenuItem > getSubMenuById ( int parentId ) { return getAllSubMenus ( ) . stream ( ) . filter ( subMenu -> subMenu . getId ( ) == parentId ) . map ( m -> ( SubMenuItem ) m ) . findFirst ( ) ; } | gets a submenu by it s ID . Returns an optional that will be empty when not present |
119,621 | public Optional < MenuItem > getMenuById ( SubMenuItem root , int id ) { return getMenuItems ( root ) . stream ( ) . filter ( item -> item . getId ( ) == id ) . findFirst ( ) ; } | Gets the menu item with the specified ID in a given submenu . If you don t know the sub menu call the findMenuItem to obtain the parent . |
119,622 | public void replaceMenuById ( SubMenuItem subMenu , MenuItem toReplace ) { synchronized ( subMenuItems ) { ArrayList < MenuItem > list = subMenuItems . get ( subMenu ) ; int idx = - 1 ; for ( int i = 0 ; i < list . size ( ) ; ++ i ) { if ( list . get ( i ) . getId ( ) == toReplace . getId ( ) ) { idx = i ; } } if ( idx... | Replace the menu item that has a given parent with the one provided |
119,623 | public void moveItem ( SubMenuItem parent , MenuItem newItem , MoveType moveType ) { synchronized ( subMenuItems ) { ArrayList < MenuItem > items = subMenuItems . get ( parent ) ; int idx = items . indexOf ( newItem ) ; if ( idx < 0 ) return ; items . remove ( idx ) ; idx = ( moveType == MoveType . MOVE_UP ) ? -- idx :... | Moves the item either up or down in the list for that submenu |
119,624 | public SubMenuItem findParent ( MenuItem toFind ) { synchronized ( subMenuItems ) { SubMenuItem parent = MenuTree . ROOT ; for ( Map . Entry < MenuItem , ArrayList < MenuItem > > entry : subMenuItems . entrySet ( ) ) { for ( MenuItem item : entry . getValue ( ) ) { if ( item . getId ( ) == toFind . getId ( ) ) { parent... | Finds the submenu that the provided object belongs to . |
119,625 | public void removeMenuItem ( SubMenuItem parent , MenuItem item ) { SubMenuItem subMenu = ( parent != null ) ? parent : ROOT ; synchronized ( subMenuItems ) { ArrayList < MenuItem > subMenuChildren = subMenuItems . get ( subMenu ) ; if ( subMenuChildren == null ) { throw new UnsupportedOperationException ( "Menu elemen... | Remove the menu item for the provided menu item in the provided sub menu . |
119,626 | public List < MenuItem > getMenuItems ( MenuItem item ) { synchronized ( subMenuItems ) { ArrayList < MenuItem > menuItems = subMenuItems . get ( item ) ; return menuItems == null ? null : Collections . unmodifiableList ( menuItems ) ; } } | Get a list of all menu items for a given submenu |
119,627 | public < T > void changeItem ( MenuItem < T > item , MenuState < T > menuState ) { menuStates . put ( item . getId ( ) , menuState ) ; } | Change the value that s associated with a menu item . if you are changing a value just send a command to the device it will automatically update the tree . |
119,628 | @ SuppressWarnings ( "unchecked" ) public < T > MenuState < T > getMenuState ( MenuItem < T > item ) { return ( MenuState < T > ) menuStates . get ( item . getId ( ) ) ; } | Gets the menu state that s associated with a given menu item . This is the current value for the menu item . |
119,629 | @ SuppressWarnings ( "unchecked" ) public static < T extends Number > T convertNumberToTargetClass ( Number number , Class < T > targetClass ) throws IllegalArgumentException { Assert . notNull ( number , "Number must not be null" ) ; Assert . notNull ( targetClass , "Target class must not be null" ) ; if ( targetClass... | Convert the given number into an instance of the given target class . |
119,630 | public void addFilterBefore ( IRuleFilter filter , Class < ? extends IRuleFilter > beforeFilter ) { int index = getIndexOfClass ( filters , beforeFilter ) ; if ( index == - 1 ) { throw new FilterAddException ( "filter " + beforeFilter . getSimpleName ( ) + " has not been added" ) ; } filters . add ( index , filter ) ; ... | add filter before |
119,631 | public void addFilterAfter ( IRuleFilter filter , Class < ? extends IRuleFilter > afterFilter ) { int index = getIndexOfClass ( filters , afterFilter ) ; if ( index == - 1 ) { throw new FilterAddException ( "filter " + afterFilter . getSimpleName ( ) + " has not been added" ) ; } filters . add ( index + 1 , filter ) ; ... | add filter after |
119,632 | public void addRuleParserBefore ( IRuleParser parser , Class < ? extends IRuleParser > beforeParser ) { int index = getIndexOfClass ( ruleParsers , beforeParser ) ; if ( index == - 1 ) { throw new ParserAddException ( "parser " + beforeParser . getSimpleName ( ) + " has not been added" ) ; } ruleParsers . add ( index ,... | add parser before |
119,633 | public void addRuleParserAfter ( IRuleParser parser , Class < ? extends IRuleParser > afterParser ) { int index = getIndexOfClass ( ruleParsers , afterParser ) ; if ( index == - 1 ) { throw new ParserAddException ( "parser " + afterParser . getSimpleName ( ) + " has not been added" ) ; } ruleParsers . add ( index + 1 ,... | add parser after |
119,634 | private int getIndexOfClass ( List list , Class cls ) { for ( int i = 0 ; i < list . size ( ) ; i ++ ) { if ( list . get ( i ) . getClass ( ) . equals ( cls ) ) { return i ; } } return - 1 ; } | get class index of list |
119,635 | static Annotation [ ] findAndSortAnnotations ( Annotation annotation ) { final Annotation [ ] metaAnnotations = annotation . annotationType ( ) . getAnnotations ( ) ; Arrays . sort ( metaAnnotations , new Comparator < Annotation > ( ) { public int compare ( Annotation o1 , Annotation o2 ) { if ( o1 instanceof Chameleon... | We need to sort annotations so the first one processed is ChameleonTarget so these properties has bigger preference that the inherit ones . |
119,636 | public ChameleonTargetConfiguration importConfiguration ( ChameleonTargetConfiguration other ) { if ( this . container == null || this . container . isEmpty ( ) ) { this . container = other . getContainer ( ) ; } if ( this . version == null || this . version . isEmpty ( ) ) { this . version = other . getVersion ( ) ; }... | This methods copies attribute values that are not set in this object other object |
119,637 | private void createChameleonMarkerFile ( Path parent ) throws IOException { final Path chameleon = parent . resolve ( "chameleonrunner" ) ; Files . write ( chameleon , "Chameleon Runner was there" . getBytes ( ) ) ; } | representing different versions because then you have uncertainty on which configuration file is really used |
119,638 | public JsonObject prepare ( ) { if ( channel != null ) { slackMessage . addProperty ( CHANNEL , channel ) ; } if ( username != null ) { slackMessage . addProperty ( USERNAME , username ) ; } if ( icon != null ) { if ( icon . contains ( HTTP ) ) { slackMessage . addProperty ( ICON_URL , icon ) ; } else { slackMessage . ... | Convert SlackMessage to JSON |
119,639 | public static String dumpString ( byte [ ] b ) { StringBuilder d = new StringBuilder ( b . length * 2 ) ; for ( byte aB : b ) { char c = ( char ) aB ; if ( Character . isISOControl ( c ) ) { switch ( c ) { case '\r' : d . append ( "{CR}" ) ; break ; case '\n' : d . append ( "{LF}" ) ; break ; case '\000' : d . append (... | converts a byte array to printable characters |
119,640 | public Disjunction add ( IDisjunct disjunct ) { for ( Iterator < IAssertion > assertions = disjunct . getAssertions ( ) ; assertions . hasNext ( ) ; ) { add ( assertions . next ( ) ) ; } return this ; } | Adds all assertions for the given IDisjunct to this disjunction . |
119,641 | public static FormattedString of ( String format , Object object ) { return object == null ? new Null ( ) : "binary" . equals ( format ) ? new Base64 ( ( byte [ ] ) object ) : "byte" . equals ( format ) ? new Base64 ( ( byte [ ] ) object ) : "date" . equals ( format ) ? new Date ( ( java . util . Date ) object ) : "dat... | Creates a FormattedString for the given object . |
119,642 | public static List < FormattedString > of ( String format , List < ? > objects ) { return objects . stream ( ) . map ( object -> of ( format , object ) ) . collect ( toList ( ) ) ; } | Creates a FormattedString for each of the given objects . |
119,643 | public void write ( SystemInputDef systemInput ) { xmlWriter_ . writeDeclaration ( ) ; xmlWriter_ . element ( SYSTEM_TAG ) . attribute ( NAME_ATR , systemInput . getName ( ) ) . content ( ( ) -> { writeAnnotations ( systemInput ) ; toStream ( systemInput . getFunctionInputDefs ( ) ) . forEach ( this :: writeFunction ) ... | Writes the given system test definition the form of an XML document . |
119,644 | protected void writeFunction ( FunctionInputDef function ) { xmlWriter_ . element ( FUNCTION_TAG ) . attribute ( NAME_ATR , function . getName ( ) ) . content ( ( ) -> { writeAnnotations ( function ) ; for ( String varType : function . getVarTypes ( ) ) { writeInputs ( varType , toStream ( function . getVarDefs ( ) ) .... | Writes the given function input definition . |
119,645 | protected void writeInputs ( String varType , Stream < IVarDef > varDefs ) { xmlWriter_ . element ( INPUT_TAG ) . attribute ( TYPE_ATR , varType ) . content ( ( ) -> varDefs . forEach ( this :: writeVarDef ) ) . write ( ) ; } | Writes the given input variable list . |
119,646 | protected void writeVarDef ( IVarDef varDef ) { Stream < VarValueDef > values = varDef . getValues ( ) == null ? null : toStream ( varDef . getValues ( ) ) ; Stream < IVarDef > members = varDef . getMembers ( ) == null ? null : toStream ( varDef . getMembers ( ) ) ; String varTag = members == null ? VAR_TAG : VARSET_TA... | Writes the given variable definition . |
119,647 | protected void writeValue ( VarValueDef value ) { ConditionWriter conditionWriter = new ConditionWriter ( value . getCondition ( ) ) ; xmlWriter_ . element ( VALUE_TAG ) . attribute ( NAME_ATR , String . valueOf ( value . getName ( ) ) ) . attributeIf ( value . getType ( ) == FAILURE , FAILURE_ATR , "true" ) . attribut... | Writes the given variable input value definition . |
119,648 | protected void writeAnnotations ( IAnnotated annotated ) { toStream ( annotated . getAnnotations ( ) ) . sorted ( ) . forEach ( annotation -> { xmlWriter_ . element ( HAS_TAG ) . attribute ( NAME_ATR , annotation ) . attribute ( VALUE_ATR , annotated . getAnnotation ( annotation ) ) . write ( ) ; } ) ; } | Writes the given annotation definitions . |
119,649 | public Conjunction append ( IConjunct conjunct ) { for ( Iterator < IDisjunct > disjuncts = conjunct . getDisjuncts ( ) ; disjuncts . hasNext ( ) ; add ( disjuncts . next ( ) ) ) ; return this ; } | Appends another conjunction to this conjunction . |
119,650 | public static void assertIdentifier ( String id ) throws IllegalArgumentException { if ( ! isIdentifier ( id ) ) { throw new IllegalArgumentException ( ( id == null ? "null" : ( "\"" + String . valueOf ( id ) + "\"" ) ) + " is not a valid identifier" ) ; } } | Throws an exception if the given string is not a valid identifier . |
119,651 | public static boolean isVarValue ( Object val ) { return val == null || ! val . getClass ( ) . equals ( String . class ) || varValueRegex_ . matcher ( val . toString ( ) ) . matches ( ) ; } | Returns true if the given string is a valid variable value . |
119,652 | public static void assertVarValue ( Object val ) throws IllegalArgumentException { if ( ! isVarValue ( val ) ) { throw new IllegalArgumentException ( "\"" + String . valueOf ( val ) + "\"" + " is not a valid variable value" ) ; } } | Throws an exception if the given string is not a valid variable value . |
119,653 | public static void assertPath ( String pathName ) throws IllegalArgumentException { String ids [ ] = toPath ( pathName ) ; for ( int i = 0 ; i < ids . length ; i ++ ) { assertIdentifier ( ids [ i ] ) ; } } | Throws an exception if the given string is not a valid identifier path name . |
119,654 | public static void assertPropertyIdentifiers ( Collection < String > properties ) throws IllegalArgumentException { if ( properties != null ) { for ( String property : properties ) { assertIdentifier ( property ) ; } } } | Throws an exception if any member of the given set of properties is not a valid identifier . |
119,655 | public void addProperty ( String property ) { String candidate = StringUtils . trimToNull ( property ) ; if ( candidate != null ) { properties_ . add ( property ) ; } } | Adds a property to this set . |
119,656 | protected void setWriter ( Writer writer ) { writer_ = writer == null ? writerFor ( System . out ) : writer ; } | Changes the output stream for this writer . |
119,657 | private static Writer writerFor ( OutputStream stream ) { try { return stream == null ? null : new OutputStreamWriter ( stream , "UTF-8" ) ; } catch ( Exception e ) { throw new RuntimeException ( "Can't create writer" , e ) ; } } | Returns a Writer for the given output stream ; |
119,658 | public static Project asProject ( JsonObject json ) { return ProjectBuilder . with ( asSystemInputDef ( json . get ( INPUTDEF_KEY ) ) ) . systemInputRef ( asSystemInputRef ( json . get ( INPUTDEF_KEY ) ) ) . generators ( asGeneratorSet ( json . get ( GENERATORS_KEY ) ) ) . generatorsRef ( asGeneratorSetRef ( json . get... | Returns the Project represented by the given JSON object . |
119,659 | private static URI asRefBase ( JsonString uri ) { try { return uri == null ? null : new URI ( uri . getChars ( ) . toString ( ) ) ; } catch ( Exception e ) { throw new ProjectException ( String . format ( "Error defining reference base=%s" , uri ) , e ) ; } } | Returns the reference base URI represented by the given JSON string . |
119,660 | private static SystemInputDef asSystemInputDef ( JsonValue json ) { try { SystemInputDef systemInput = null ; if ( json != null && json . getValueType ( ) == OBJECT ) { systemInput = SystemInputJson . asSystemInputDef ( ( JsonObject ) json ) ; } return systemInput ; } catch ( Exception e ) { throw new ProjectException ... | Returns the system input definition represented by the given JSON value . |
119,661 | private static URI asSystemInputRef ( JsonValue json ) { try { URI uri = null ; if ( json != null && json . getValueType ( ) == STRING ) { uri = new URI ( ( ( JsonString ) json ) . getChars ( ) . toString ( ) ) ; } return uri ; } catch ( Exception e ) { throw new ProjectException ( "Error reading input definition" , e ... | Returns the system input definition URL represented by the given JSON value . |
119,662 | private static IGeneratorSet asGeneratorSet ( JsonValue json ) { try { IGeneratorSet generators = null ; if ( json != null && json . getValueType ( ) == OBJECT ) { generators = GeneratorSetJson . asGeneratorSet ( ( JsonObject ) json ) ; } return generators ; } catch ( Exception e ) { throw new ProjectException ( "Error... | Returns the generator set represented by the given JSON value . |
119,663 | public static JsonObject toJson ( Project project ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; Optional . ofNullable ( project . getBaseLocation ( ) ) . ifPresent ( uri -> builder . add ( REFBASE_KEY , String . valueOf ( uri ) ) ) ; if ( project . getSystemInputLocation ( ) != null ) { builder . add... | Returns the JSON object that represents the given project definition . |
119,664 | public void write ( IGeneratorSet generatorSet ) { writer_ . writeDeclaration ( ) ; writer_ . element ( GENERATORS_TAG ) . content ( ( ) -> { Arrays . stream ( generatorSet . getGeneratorFunctions ( ) ) . sorted ( ) . forEach ( function -> writeGenerator ( function , generatorSet . getGenerator ( function ) ) ) ; } ) .... | Writes the given generator definition in the form of an XML document . |
119,665 | protected void writeCombiner ( TupleCombiner combiner ) { writer_ . element ( COMBINE_TAG ) . attribute ( TUPLES_ATR , String . valueOf ( combiner . getTupleSize ( ) ) ) . content ( ( ) -> { Arrays . stream ( combiner . getIncluded ( ) ) . sorted ( ) . forEach ( this :: writeIncluded ) ; Arrays . stream ( combiner . ge... | Writes the given combiner definition . |
119,666 | protected void writeOnceTuple ( TupleRef tuple ) { writer_ . element ( ONCE_TAG ) . content ( ( ) -> toStream ( tuple . getVarBindings ( ) ) . forEach ( this :: writeVarBinding ) ) . write ( ) ; } | Writes the given once - only tuple definition . |
119,667 | protected void writeVarBinding ( VarBinding binding ) { writer_ . element ( VAR_TAG ) . attribute ( NAME_ATR , binding . getVar ( ) ) . attribute ( VALUE_ATR , String . valueOf ( binding . getValue ( ) ) ) . write ( ) ; } | Writes the given variable binding definition . |
119,668 | public VarBindingDef bind ( VarDef varDef , VarValueDef valueDef ) { if ( valueDef != null && ! varDef . isApplicable ( valueDef ) ) { throw new IllegalArgumentException ( "Value=" + valueDef + " is not defined for var=" + varDef ) ; } varDef_ = varDef ; valueDef_ = valueDef ; effCondition_ = null ; return this ; } | Changes this input variable binding . |
119,669 | public ICondition getEffectiveCondition ( ) { if ( effCondition_ == null ) { effCondition_ = getValueDef ( ) . getEffectiveCondition ( getVarDef ( ) . getEffectiveCondition ( ) ) ; } return effCondition_ ; } | Returns the effective condition that defines when this binding is applicable . |
119,670 | private VarDef getNextVarDef ( ) { if ( nextVarDef_ == null ) { if ( nextVarSet_ != null && nextVarSet_ . hasNext ( ) ) { nextVarDef_ = nextVarSet_ . next ( ) ; } else { nextVarSet_ = null ; Iterator < IVarDef > members = null ; IVarDef varDef ; for ( varDef = null ; varDefs_ . hasNext ( ) && ( members = ( varDef = var... | Returns the next |
119,671 | public static IGeneratorSet asGeneratorSet ( JsonObject json ) { GeneratorSet generatorSet = new GeneratorSet ( ) ; json . keySet ( ) . stream ( ) . forEach ( function -> { try { generatorSet . addGenerator ( validFunction ( function ) , asGenerator ( json . getJsonObject ( function ) ) ) ; } catch ( GeneratorSetExcept... | Returns the IGeneratorSet represented by the given JSON object . |
119,672 | private static TupleGenerator asGenerator ( JsonObject json ) { TupleGenerator tupleGenerator = new TupleGenerator ( ) ; Optional . ofNullable ( json . getJsonNumber ( TUPLES_KEY ) ) . ifPresent ( n -> tupleGenerator . setDefaultTupleSize ( n . intValue ( ) ) ) ; Optional . ofNullable ( json . getJsonNumber ( SEED_KEY ... | Returns the generator represented by the given JSON object . |
119,673 | private static TupleCombiner asCombiner ( JsonObject json ) { try { TupleCombiner tupleCombiner = new TupleCombiner ( ) ; Optional . ofNullable ( json . getJsonNumber ( TUPLES_KEY ) ) . ifPresent ( n -> tupleCombiner . setTupleSize ( n . intValue ( ) ) ) ; Optional . ofNullable ( json . getJsonArray ( INCLUDE_KEY ) ) .... | Returns the combiner represented by the given JSON object . |
119,674 | private static TupleRef asTupleRef ( JsonObject json ) { TupleRef tupleRef = new TupleRef ( ) ; json . keySet ( ) . stream ( ) . forEach ( var -> { try { tupleRef . addVarBinding ( new VarBinding ( var , ObjectUtils . toObject ( json . getString ( var ) ) ) ) ; } catch ( GeneratorSetException e ) { throw new GeneratorS... | Returns the TupleRef represented by the given JSON object . |
119,675 | private static String validFunction ( String string ) { return GeneratorSet . ALL . equals ( string ) ? string : validIdentifier ( string ) ; } | Reports a GeneratorSetException if the given string is not a valid function id . Otherwise returns this string . |
119,676 | private static String validIdentifier ( String string ) { try { DefUtils . assertIdentifier ( string ) ; } catch ( Exception e ) { throw new GeneratorSetException ( e . getMessage ( ) ) ; } return string ; } | Reports a GeneratorSetException if the given string is not a valid identifier . Otherwise returns this string . |
119,677 | public static JsonObject toJson ( IGeneratorSet generatorSet ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; for ( String function : generatorSet . getGeneratorFunctions ( ) ) { builder . add ( function , toJson ( generatorSet . getGenerator ( function ) ) ) ; } return builder . build ( ) ; } | Returns the JSON object that represents the given generator set . |
119,678 | private static JsonStructure toJson ( ITestCaseGenerator generator ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; if ( generator . getClass ( ) . equals ( TupleGenerator . class ) ) { TupleGenerator tupleGenerator = ( TupleGenerator ) generator ; builder . add ( TUPLES_KEY , tupleGenerator . getDefaul... | Returns the JSON object that represents the given generator . |
119,679 | private static JsonStructure toJson ( TupleCombiner combiner ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; builder . add ( TUPLES_KEY , combiner . getTupleSize ( ) ) ; JsonArrayBuilder includeBuilder = Json . createArrayBuilder ( ) ; Arrays . stream ( combiner . getIncluded ( ) ) . forEach ( var -> i... | Returns the JSON object that represents the given combiner . |
119,680 | private static JsonStructure toJson ( TupleRef tuple ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; toStream ( tuple . getVarBindings ( ) ) . forEach ( binding -> builder . add ( binding . getVar ( ) , String . valueOf ( binding . getValue ( ) ) ) ) ; return builder . build ( ) ; } | Returns the JSON object that represents the given once tuple . |
119,681 | public static Object toObject ( String value ) { return toObject ( value , ObjectUtils :: toBoolean , ObjectUtils :: toNumber , ObjectUtils :: toExternalString ) ; } | Returns the object represented by the given string . |
119,682 | public static Object toExternalObject ( Object value ) { return Optional . ofNullable ( toExternalNumber ( value ) ) . orElse ( toObject ( String . valueOf ( value ) ) ) ; } | Returns an object equal to the external form of the given value . |
119,683 | private static < T > Object toObject ( T value , Function < T , Object > ... converters ) { return Stream . of ( converters ) . map ( converter -> converter . apply ( value ) ) . filter ( Objects :: nonNull ) . findFirst ( ) . orElse ( null ) ; } | Returns the first non - null object produced by the given converters . Returns null if no such object found . |
119,684 | private static Object toBoolean ( String value ) { return "true" . equalsIgnoreCase ( value ) ? Boolean . TRUE : "false" . equalsIgnoreCase ( value ) ? Boolean . FALSE : null ; } | Returns the Boolean represented by the given string or null if not a boolean value . |
119,685 | private static Object toNumber ( String value ) { Object number ; try { number = toExternalNumber ( new BigDecimal ( value ) ) ; } catch ( Exception e ) { number = null ; } return number ; } | Returns the Number represented by the given string or null if not a numeric value . |
119,686 | private static Object toInt ( BigDecimal value ) { Object number ; try { number = value . scale ( ) == 0 ? Integer . valueOf ( value . intValueExact ( ) ) : null ; } catch ( Exception e ) { number = null ; } return number ; } | Returns the Integer represented by the given value or null if not an integer value . |
119,687 | private static Object toLong ( BigDecimal value ) { Object number ; try { number = value . scale ( ) == 0 ? Long . valueOf ( value . longValueExact ( ) ) : null ; } catch ( Exception e ) { number = null ; } return number ; } | Returns the Long represented by the given value or null if not an long value . |
119,688 | private static Object toExternalNumber ( Object value ) { Class < ? > valueType = value == null ? null : value . getClass ( ) ; return ! ( valueType != null && Number . class . isAssignableFrom ( valueType ) ) ? null : valueType . equals ( BigDecimal . class ) ? toExternalNumber ( ( BigDecimal ) value ) : valueType . e... | If the given value is a number returns an object equal to its external form . Otherwise returns null . |
119,689 | private static Object toExternalNumber ( BigDecimal number ) { return Optional . ofNullable ( toObject ( number , ObjectUtils :: toInt , ObjectUtils :: toLong ) ) . orElse ( number ) ; } | Returns an object equal to the external form of the given number value . |
119,690 | public String getPathName ( ) { if ( pathName_ == null ) { StringBuilder pathName = new StringBuilder ( ) ; IVarDef parent = getParent ( ) ; if ( parent != null ) { pathName . append ( parent . getPathName ( ) ) . append ( '.' ) ; } String name = getName ( ) ; if ( name != null ) { pathName . append ( name ) ; } pathNa... | Returns the hierarchical path name of this variable . |
119,691 | public String getType ( ) { IVarDef parent = getParent ( ) ; return parent == null ? type_ : parent . getType ( ) ; } | Returns the type identifier for this variable . |
119,692 | public ICondition getEffectiveCondition ( ) { if ( effCondition_ == null ) { effCondition_ = getEffectiveCondition ( Optional . ofNullable ( getParent ( ) ) . map ( IVarDef :: getEffectiveCondition ) . orElse ( null ) ) ; } return effCondition_ ; } | Returns the effective condition that defines when this variable is applicable based on the conditions for this variable and all of its ancestors . |
119,693 | public IVarDef . Position getPosition ( ) { if ( position_ == null ) { setPosition ( new Position ( getParent ( ) , seqNum_ ) ) ; } return position_ ; } | Returns the position of this variable definition . |
119,694 | protected void writeAttribute ( String name , String value ) { print ( " " ) ; print ( name ) ; print ( "=\"" ) ; print ( NumericEntityEscaper . below ( 0x20 ) . translate ( StringEscapeUtils . escapeXml11 ( value ) ) ) ; print ( "\"" ) ; } | Writes an attribute definition . |
119,695 | public boolean matches ( VarNamePattern varName ) { boolean matched = varName != null && ( varName . varNamePath_ == null ) == ( varNamePath_ == null ) && ! varName . wildcard_ && varName . minDepth_ >= minDepth_ ; if ( matched && varNamePath_ != null ) { int i ; for ( i = 0 ; i < minDepth_ && ( matched = varName . var... | Returns true if the given variable name matches this pattern . |
119,696 | public boolean isValid ( ) { boolean valid = varNamePath_ != null ; if ( valid ) { int i ; for ( i = 0 ; i < varNamePath_ . length && DefUtils . isIdentifier ( varNamePath_ [ i ] ) ; i ++ ) ; int membersLeft = varNamePath_ . length - i ; valid = membersLeft == 0 || ( membersLeft == 1 && ( varNamePath_ [ i ] . equals ( ... | Returns true if this pattern is valid . |
119,697 | private boolean isApplicable ( Iterator < IVarDef > varDefs ) { boolean applicable = false ; while ( varDefs . hasNext ( ) && ! ( applicable = isApplicable ( varDefs . next ( ) ) ) ) ; return applicable ; } | Returns true if this pattern is applicable to the given set of variables . |
119,698 | private boolean isApplicable ( IVarDef var ) { Iterator < IVarDef > members = var . getMembers ( ) ; return members == null ? matches ( var . getPathName ( ) ) : isApplicable ( members ) ; } | Returns true if this pattern is applicable to the given variable . |
119,699 | public static IConjunct negate ( IConjunct conjunct ) { AnyOf anyOf = new AnyOf ( ) ; for ( Iterator < IDisjunct > disjuncts = conjunct . getDisjuncts ( ) ; disjuncts . hasNext ( ) ; ) { Conjunction conjunction = new Conjunction ( ) ; for ( Iterator < IAssertion > assertions = disjuncts . next ( ) . getAssertions ( ) ;... | Returns the negation of the given CNF condition . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.