idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
37,200
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 .
37,201
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 .
37,202
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 .
37,203
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 .
37,204
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 .
37,205
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 .
37,206
protected void writeOnceTuple ( TupleRef tuple ) { writer_ . element ( ONCE_TAG ) . content ( ( ) -> toStream ( tuple . getVarBindings ( ) ) . forEach ( this :: writeVarBinding ) ) . write ( ) ; }
Writes the given once - only tuple definition .
37,207
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 .
37,208
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 .
37,209
public ICondition getEffectiveCondition ( ) { if ( effCondition_ == null ) { effCondition_ = getValueDef ( ) . getEffectiveCondition ( getVarDef ( ) . getEffectiveCondition ( ) ) ; } return effCondition_ ; }
Returns the effective condition that defines when this binding is applicable .
37,210
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
37,211
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 .
37,212
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 .
37,213
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 .
37,214
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 .
37,215
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 .
37,216
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 .
37,217
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 .
37,218
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 .
37,219
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 .
37,220
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 .
37,221
public static Object toObject ( String value ) { return toObject ( value , ObjectUtils :: toBoolean , ObjectUtils :: toNumber , ObjectUtils :: toExternalString ) ; }
Returns the object represented by the given string .
37,222
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 .
37,223
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 .
37,224
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 .
37,225
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 .
37,226
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 .
37,227
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 .
37,228
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 .
37,229
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 .
37,230
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 .
37,231
public String getType ( ) { IVarDef parent = getParent ( ) ; return parent == null ? type_ : parent . getType ( ) ; }
Returns the type identifier for this variable .
37,232
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 .
37,233
public IVarDef . Position getPosition ( ) { if ( position_ == null ) { setPosition ( new Position ( getParent ( ) , seqNum_ ) ) ; } return position_ ; }
Returns the position of this variable definition .
37,234
protected void writeAttribute ( String name , String value ) { print ( " " ) ; print ( name ) ; print ( "=\"" ) ; print ( NumericEntityEscaper . below ( 0x20 ) . translate ( StringEscapeUtils . escapeXml11 ( value ) ) ) ; print ( "\"" ) ; }
Writes an attribute definition .
37,235
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 .
37,236
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 .
37,237
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 .
37,238
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 .
37,239
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 .
37,240
public static IConjunct either ( IConjunct conjunct1 , IConjunct conjunct2 ) { IConjunct conjunct ; if ( conjunct1 . getDisjunctCount ( ) == 0 ) { conjunct = conjunct2 ; } else if ( conjunct2 . getDisjunctCount ( ) == 0 ) { conjunct = conjunct1 ; } else { Conjunction conjunction = new Conjunction ( ) ; for ( Iterator <...
Returns the logical OR of the given CNF conditions .
37,241
public static IConjunct refactor ( IConjunct conjunct ) { Iterator < IDisjunct > disjuncts = conjunct . getDisjuncts ( ) ; IAssertion assertion = null ; while ( disjuncts . hasNext ( ) && ( assertion = toAssertion ( disjuncts . next ( ) ) ) == null ) ; return assertion == null ? conjunct : simplify ( new Conjunction ( ...
Return refactored conjunction formed by removing superfluous terms .
37,242
public static IConjunct remainder ( IConjunct conjunct , IAssertion assertion ) { Conjunction rest = new Conjunction ( ) ; for ( Iterator < IDisjunct > disjuncts = conjunct . getDisjuncts ( ) ; disjuncts . hasNext ( ) ; ) { IDisjunct disjunct = disjuncts . next ( ) ; if ( ! disjunct . contains ( assertion ) ) { rest . ...
Returns the remainder after removing all terms that contain the given assertion .
37,243
public static IAssertion toAssertion ( IDisjunct disjunct ) { return disjunct . getAssertionCount ( ) == 1 ? disjunct . getAssertions ( ) . next ( ) : null ; }
If the given disjunction consists of a single assertion returns the equivalent assertion . Otherwise return null .
37,244
public static IConjunct simplify ( IConjunct conjunct ) { return conjunct . getDisjunctCount ( ) == 1 ? conjunct . getDisjuncts ( ) . next ( ) : conjunct ; }
Returns the simple form of the given conjunction .
37,245
public static IDisjunct simplify ( IDisjunct disjunct ) { IAssertion assertion = toAssertion ( disjunct ) ; return assertion == null ? disjunct : assertion ; }
Returns the simple form of the given disjunction .
37,246
public static boolean isTautology ( IDisjunct disjunct ) { boolean tautology = false ; if ( disjunct != null ) { IAssertion [ ] assertions = IteratorUtils . toArray ( disjunct . getAssertions ( ) , IAssertion . class ) ; int max = assertions . length ; int maxCompared = max - 1 ; for ( int compared = 0 ; ! tautology &&...
Returns true if the given disjunction is universally true .
37,247
public static boolean satisfiesSome ( IConjunct condition , PropertySet properties ) { boolean satisfies ; Iterator < IDisjunct > disjuncts ; for ( disjuncts = condition . getDisjuncts ( ) , satisfies = ! disjuncts . hasNext ( ) ; ! satisfies && disjuncts . hasNext ( ) ; satisfies = disjuncts . next ( ) . satisfied ( p...
Returns true if the given properties partially satisfy the given condition .
37,248
public static IConjunct getUnsatisfied ( IConjunct condition , PropertySet properties ) { Conjunction unsatisfied = new Conjunction ( ) ; for ( Iterator < IDisjunct > disjuncts = condition . getDisjuncts ( ) ; disjuncts . hasNext ( ) ; ) { IDisjunct disjunct = disjuncts . next ( ) ; if ( ! disjunct . satisfied ( proper...
Returns the part of the given condition unsatisfied by the given properties .
37,249
public FunctionInputDef addVarDef ( IVarDef varDef ) { assert varDef != null ; assert varDef . getName ( ) != null ; if ( findVarDef ( varDef . getName ( ) ) >= 0 ) { throw new IllegalStateException ( "Variable=" + varDef . getName ( ) + " already defined for function=" + getName ( ) ) ; } vars_ . add ( varDef ) ; retu...
Adds a new variable definition .
37,250
public FunctionInputDef removeVarDef ( String name ) { int i = findVarDef ( name ) ; if ( i >= 0 ) { vars_ . remove ( i ) ; } return this ; }
Removes a variable definition .
37,251
public IVarDef getVarDef ( String name ) { int i = findVarDef ( name ) ; return i >= 0 ? vars_ . get ( i ) : null ; }
Returns the variable definition with the given name .
37,252
protected int findVarDef ( String name ) { int varCount = name == null ? 0 : vars_ . size ( ) ; int i ; for ( i = 0 ; i < varCount && ! name . equals ( vars_ . get ( i ) . getName ( ) ) ; i ++ ) ; return i < varCount ? i : - 1 ; }
Returns the index of the variable definition with the given name .
37,253
public IVarDef findVarPath ( String pathName ) { String [ ] path = DefUtils . toPath ( pathName ) ; IVarDef var ; return path == null ? null : ( var = getVarDef ( StringUtils . trimToNull ( path [ 0 ] ) ) ) == null ? null : var . find ( Arrays . copyOfRange ( path , 1 , path . length ) ) ; }
Returns the variable definition with the given path name .
37,254
public VarDef findVarDefPath ( String pathName ) { IVarDef var = findVarPath ( pathName ) ; return var != null && var . getClass ( ) . equals ( VarDef . class ) ? ( VarDef ) var : null ; }
Returns the individual variable definition with the given path name .
37,255
public void addConfiguredParam ( Parameter param ) { options_ . getTransformParams ( ) . put ( param . getName ( ) , param . getValue ( ) ) ; }
Adds a transform parameter .
37,256
public void setTransformDef ( File transformDef ) { options_ . setTransformDef ( transformDef ) ; if ( transformDef != null ) { options_ . setTransformType ( Options . TransformType . CUSTOM ) ; } }
Changes the transform file .
37,257
public static VarBinding create ( IVarDef varDef , VarValueDef valueDef ) { VarBinding binding = valueDef . isNA ( ) ? new VarNaBinding ( varDef . getPathName ( ) , varDef . getType ( ) ) : new VarBinding ( varDef . getPathName ( ) , varDef . getType ( ) , valueDef . getName ( ) ) ; binding . setValueValid ( valueDef ....
Creates a new VarBinding object .
37,258
public static String getProjectName ( File inputDefFile ) { String projectName = null ; if ( inputDefFile != null ) { String inputBase = FilenameUtils . getBaseName ( inputDefFile . getName ( ) ) ; projectName = inputBase . toLowerCase ( ) . endsWith ( "-input" ) ? inputBase . substring ( 0 , inputBase . length ( ) - "...
Returns the name of the project for the given input definition file .
37,259
public static String getVersion ( ) { Properties tcasesProperties = new Properties ( ) ; String tcasesPropertyFileName = "/tcases.properties" ; InputStream tcasesPropertyFile = null ; try { tcasesPropertyFile = Tcases . class . getResourceAsStream ( tcasesPropertyFileName ) ; tcasesProperties . load ( tcasesPropertyFil...
Returns a description of the current version .
37,260
public static Map < String , Collection < VarBindingDef > > getPropertySources ( FunctionInputDef function ) { SetValuedMap < String , VarBindingDef > sources = MultiMapUtils . newSetValuedHashMap ( ) ; toStream ( new VarDefIterator ( function ) ) . flatMap ( var -> toStream ( var . getValues ( ) ) . map ( value -> new...
Maps every property in the given function input definition to the variable value definitions that contribute it .
37,261
public static Map < String , Collection < IConditional > > getPropertyReferences ( FunctionInputDef function ) { SetValuedMap < String , IConditional > refs = MultiMapUtils . newSetValuedHashMap ( ) ; conditionals ( function ) . forEach ( conditional -> propertiesReferenced ( conditional . getCondition ( ) ) . forEach ...
Maps every property in the given FunctionInputDef to the conditional elements that reference it .
37,262
public static Map < String , Collection < VarBindingDef > > getPropertiesUnused ( FunctionInputDef function ) { Map < String , Collection < VarBindingDef > > sources = getPropertySources ( function ) ; Collection < String > unused = CollectionUtils . subtract ( sources . keySet ( ) , getPropertyReferences ( function ) ...
For every property in the given function input definition that is defined but never referenced maps the property to the variable value definitions that contribute it .
37,263
public static Map < String , Collection < IConditional > > getPropertiesUndefined ( FunctionInputDef function ) { Map < String , Collection < IConditional > > refs = getPropertyReferences ( function ) ; Collection < String > undefined = CollectionUtils . subtract ( refs . keySet ( ) , getPropertySources ( function ) . ...
For every property in the given function input definition that is referenced but never defined maps the property to the conditional elements that reference it .
37,264
public static String getReferenceName ( IConditional conditional ) { return conditional instanceof IVarDef ? String . format ( "variable=%s" , ( ( IVarDef ) conditional ) . getPathName ( ) ) : conditional instanceof VarBindingDef ? String . format ( "variable=%s, value=%s" , ( ( VarBindingDef ) conditional ) . getVarDe...
Returns the full reference name for the given IConditional .
37,265
private static Stream < IConditional > conditionals ( FunctionInputDef function ) { return toStream ( function . getVarDefs ( ) ) . flatMap ( var -> conditionals ( var ) ) ; }
Returns the IConditional instances defined by the given function input definition .
37,266
private static Stream < IConditional > conditionals ( IVarDef var ) { return Stream . concat ( Stream . of ( var ) , Stream . concat ( Optional . ofNullable ( var . getMembers ( ) ) . map ( members -> toStream ( members ) . flatMap ( member -> conditionals ( member ) ) ) . orElse ( Stream . empty ( ) ) , Optional . ofN...
Returns the IConditional instances defined by the given variable definition .
37,267
public static < K , V > MapBuilder < K , V > of ( K key , V value ) { return new MapBuilder < K , V > ( ) . put ( key , value ) ; }
Returns a new MapBuilder with the given entry .
37,268
public MapBuilder < K , V > put ( K key , V value ) { map_ . put ( key , value ) ; return this ; }
Adds an entry to the map for this builder .
37,269
public MapBuilder < K , V > putIf ( K key , Optional < V > value ) { value . ifPresent ( v -> map_ . put ( key , v ) ) ; return this ; }
Adds an entry to the map for this builder if the given value is present .
37,270
public < T > List < T > reorder ( List < T > sequence ) { int elementCount = sequence . size ( ) ; if ( elementCount > 1 ) { List < T > elements = new ArrayList < T > ( sequence ) ; sequence . clear ( ) ; for ( ; elementCount > 0 ; elementCount -- ) { sequence . add ( elements . remove ( generator_ . nextInt ( elementC...
Returns the given list with its elements rearranged in a random order .
37,271
public < T > Iterator < T > reorder ( Iterator < T > sequence ) { return reorder ( IteratorUtils . toList ( sequence ) ) . iterator ( ) ; }
Returns an iterator that visits the elements of the given sequence in a random order .
37,272
public void setTupleSize ( int tupleSize ) { Integer onceSize = onceTuples_ . isEmpty ( ) ? null : getOnceTuples ( ) . next ( ) . size ( ) ; if ( ! ( onceSize == null || onceSize == tupleSize ) ) { throw new IllegalArgumentException ( "Tuple size=" + tupleSize + " is not compatible with existing once-only tuple size=" ...
Changes the tuple size for input variable combinations . A non - positive tupleSize specifies all permutations .
37,273
public String [ ] getIncluded ( ) { return IteratorUtils . toArray ( IteratorUtils . transformedIterator ( includedVars_ . iterator ( ) , VarNamePattern :: toString ) , String . class ) ; }
Returns the set of input variables to be included in this combination .
37,274
public String [ ] getExcluded ( ) { return IteratorUtils . toArray ( IteratorUtils . transformedIterator ( excludedVars_ . iterator ( ) , VarNamePattern :: toString ) , String . class ) ; }
Returns the set of input variables to be excluded from this combination .
37,275
public TupleCombiner addOnceTuple ( TupleRef tupleRef ) { if ( tupleRef != null ) { if ( tupleRef . size ( ) != getTupleSize ( ) ) { throw new IllegalArgumentException ( "Once-only tuple=" + tupleRef + " has size=" + tupleRef . size ( ) + ", expected size=" + getTupleSize ( ) ) ; } onceTuples_ . add ( tupleRef ) ; } re...
Adds a once - only tuple to this combination .
37,276
public Collection < Tuple > getTuples ( FunctionInputDef inputDef ) { List < VarDef > combinedVars = getCombinedVars ( inputDef ) ; return getCombinedTuples ( combinedVars , getTuples ( combinedVars , getTupleSize ( ) ) ) ; }
Returns all valid N - tuples of values for the included input variables .
37,277
public static Collection < Tuple > getTuples ( List < VarDef > varDefs , int tupleSize ) { if ( tupleSize < 1 ) { tupleSize = varDefs . size ( ) ; } int varEnd = varDefs . size ( ) - tupleSize + 1 ; if ( varEnd <= 0 ) { throw new IllegalArgumentException ( "Can't create " + tupleSize + "-tuples for " + varDefs . size (...
Returns all valid N - tuples of values for the given input variables . A non - positive tupleSize specifies all permutations .
37,278
private static Collection < Tuple > getTuples ( List < VarDef > varDefs , int varStart , int varEnd , int tupleSize ) { Collection < Tuple > tuples = new ArrayList < Tuple > ( ) ; for ( int i = varStart ; i < varEnd ; i ++ ) { VarDef nextVar = varDefs . get ( i ) ; Iterator < VarValueDef > values = nextVar . getValidVa...
Returns all valid tuples of values for the given input variables .
37,279
private Collection < Tuple > getCombinedTuples ( List < VarDef > combinedVars , Collection < Tuple > tuples ) { Set < Tuple > onceTuples = getOnceTupleDefs ( combinedVars ) ; if ( ! onceTuples . isEmpty ( ) ) { for ( Tuple tuple : tuples ) { tuple . setOnce ( onceTuples . contains ( tuple ) ) ; } } return tuples ; }
Returns all fully - combined N - tuples of values for the included input variables .
37,280
private Set < Tuple > getOnceTupleDefs ( final List < VarDef > combinedVars ) { try { return new HashSet < Tuple > ( IteratorUtils . toList ( IteratorUtils . transformedIterator ( getOnceTuples ( ) , tupleRef -> toTuple ( combinedVars , tupleRef ) ) ) ) ; } catch ( Exception e ) { throw new IllegalStateException ( "Inv...
Returns the set of once - only tuple definitions for this combiner .
37,281
private Tuple toTuple ( List < VarDef > combinedVars , TupleRef tupleRef ) { if ( tupleRef . size ( ) != getTupleSize ( ) ) { throw new IllegalStateException ( String . valueOf ( tupleRef ) + " does not match combiner tuple size=" + getTupleSize ( ) ) ; } Tuple tuple = new Tuple ( ) ; for ( Iterator < VarBinding > bind...
Converts a reference to a tuple of combined variables .
37,282
private VarDef findVarPath ( List < VarDef > combinedVars , String varPath ) { int i ; for ( i = 0 ; i < combinedVars . size ( ) && ! varPath . equals ( combinedVars . get ( i ) . getPathName ( ) ) ; i ++ ) ; return i < combinedVars . size ( ) ? combinedVars . get ( i ) : null ; }
Returns the member of the given variable list with the given path .
37,283
public List < VarDef > getCombinedVars ( FunctionInputDef inputDef ) { assertApplicable ( inputDef ) ; List < VarDef > combinedVars = new ArrayList < VarDef > ( ) ; for ( VarDefIterator varDefs = new VarDefIterator ( inputDef ) ; varDefs . hasNext ( ) ; ) { VarDef varDef = varDefs . next ( ) ; if ( isEligible ( varDef ...
Returns the set of input variables to be combined .
37,284
private boolean isExcluded ( VarNamePattern varNamePath ) { boolean excluded = false ; Iterator < VarNamePattern > excludedVars = getExcludedVars ( ) . iterator ( ) ; while ( excludedVars . hasNext ( ) && ! ( excluded = excludedVars . next ( ) . matches ( varNamePath ) ) ) ; return excluded ; }
Returns true if the given variable matches any excluded input variable .
37,285
private boolean isIncluded ( VarNamePattern varNamePath ) { boolean included = getIncludedVars ( ) . isEmpty ( ) ; if ( ! included ) { Iterator < VarNamePattern > includedVars = getIncludedVars ( ) . iterator ( ) ; while ( includedVars . hasNext ( ) && ! ( included = includedVars . next ( ) . matches ( varNamePath ) ) ...
Returns true if the given variable matches any included input variable .
37,286
private void assertApplicable ( FunctionInputDef inputDef , VarNamePattern varNamePattern ) throws IllegalArgumentException { if ( ! varNamePattern . isApplicable ( inputDef ) ) { throw new IllegalArgumentException ( "Can't find variable matching pattern=" + varNamePattern ) ; } }
Throws an exception if the given variable pattern is not applicable to the given input definition .
37,287
public boolean isEligible ( IVarDef varDef ) { VarNamePattern varNamePath = new VarNamePattern ( varDef . getPathName ( ) ) ; return ! isExcluded ( varNamePath ) && isIncluded ( varNamePath ) ; }
Returns true if the given input variable is eligible to be combined .
37,288
public void setTarget ( File target ) { try { OutputStream targetStream = target == null ? null : new FileOutputStream ( target ) ; setTarget ( targetStream ) ; } catch ( Exception e ) { throw new RuntimeException ( "Can't create target stream" , e ) ; } }
Changes the target for filter output .
37,289
private OutputStream initializeSource ( ) { try { PipedOutputStream pipeOut = new PipedOutputStream ( ) ; PipedInputStream pipeIn = new PipedInputStream ( pipeOut ) ; filterInput_ = pipeIn ; return new FilterSourceStream ( pipeOut ) ; } catch ( Exception e ) { throw new RuntimeException ( "Can't initialize source strea...
Initializes the source for filter input .
37,290
protected OutputStream getFilterOutput ( ) { OutputStream target = getTarget ( ) ; return target == null ? System . out : target ; }
Returns the stream that provides output from the filter .
37,291
private void start ( ) { try { initializeFilter ( getFilterInput ( ) , getFilterOutput ( ) ) ; failure_ = null ; thread_ = new Thread ( this , String . valueOf ( this ) ) ; thread_ . start ( ) ; } catch ( Exception e ) { throw new RuntimeException ( "Can't start filtering" , e ) ; } }
Starts filter output .
37,292
public void close ( ) { IOUtils . closeQuietly ( source_ ) ; try { complete ( ) ; } catch ( Exception e ) { logger_ . error ( "Can't complete filtering" , e ) ; } }
Terminates filter output .
37,293
private void complete ( ) throws IOException { if ( source_ != null ) { try { thread_ . join ( ) ; } catch ( Exception e ) { logger_ . error ( "Thread=" + thread_ + " not completed" , e ) ; } IOException failure = failure_ == null ? null : new IOException ( "Can't write filter output" , failure_ ) ; failure_ = null ; f...
Completes filter output .
37,294
public void setCondition ( ICondition condition ) { super . setCondition ( condition ) ; if ( members_ != null ) { for ( IVarDef member : members_ ) { member . setParent ( this ) ; } } }
Changes the condition that defines when this element is applicable .
37,295
public IVarDef find ( String ... path ) { return path == null || path . length == 0 ? this : getDescendant ( path ) ; }
Returns the descendant variable with the given name path relative to this variable .
37,296
public VarSet addMember ( IVarDef var ) { assert var != null ; assert var . getName ( ) != null ; if ( findMember ( var . getName ( ) ) >= 0 ) { throw new IllegalStateException ( "Member=" + var . getName ( ) + " already defined for varSet=" + getPathName ( ) ) ; } members_ . add ( var ) ; var . setParent ( this ) ; va...
Adds an input variable to this set .
37,297
public VarSet removeMember ( String name ) { int i = findMember ( name ) ; if ( i >= 0 ) { members_ . remove ( i ) . setParent ( null ) ; } return this ; }
Removes an input variable from this set .
37,298
public IVarDef getMember ( String name ) { int i = findMember ( name ) ; return i >= 0 ? members_ . get ( i ) : null ; }
Returns the member variable with the given name .
37,299
private IVarDef getDescendant ( String [ ] path ) { int pathLength = path == null ? 0 : path . length ; int parentPathLength = pathLength - 1 ; int i ; VarSet parent ; IVarDef descendant ; for ( i = 0 , parent = this , descendant = null ; i < parentPathLength && ( descendant = parent . getMember ( StringUtils . trimToN...
Returns the descendant variable with the given path relative to this set .