本文整理汇总了Java中org.apache.commons.collections4.IteratorUtils.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java IteratorUtils.toArray方法的具体用法?Java IteratorUtils.toArray怎么用?Java IteratorUtils.toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.collections4.IteratorUtils
的用法示例。
在下文中一共展示了IteratorUtils.toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExcluded
import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
/**
* Returns the set of input variables to be excluded from this combination.
*/
public String[] getExcluded()
{
return
IteratorUtils.toArray
( IteratorUtils.transformedIterator
( excludedVars_.iterator(),
new Transformer<VarNamePattern,String>()
{
public String transform( VarNamePattern pattern)
{
return pattern.toString();
}
}),
String.class);
}
示例2: isTautology
import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
/**
* Returns true if the given disjunction is universally true.
*/
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 && compared < maxCompared;
compared++)
{
IAssertion assertCompared = assertions[ compared];
for( int other = compared + 1;
!tautology && other < max;
tautology = assertCompared.negates( assertions[ other++]));
}
}
return tautology;
}
示例3: writeFunction
import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
/**
* Writes the given function test definition.
*/
protected void writeFunction( FunctionTestDef function)
{
xmlWriter_.writeTagStart( FUNCTION_TAG);
xmlWriter_.writeAttribute( NAME_ATR, function.getName());
xmlWriter_.writeTagEnd();
xmlWriter_.indent();
writeAnnotations( function);
TestCase[] testCases = IteratorUtils.toArray( function.getTestCases(), TestCase.class);
Arrays.sort( testCases);
for( int i = 0; i < testCases.length; i++)
{
writeTestCase( testCases[i]);
}
xmlWriter_.unindent();
xmlWriter_.writeElementEnd( FUNCTION_TAG);
}
示例4: writeInputs
import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
/**
* Writes the input value definitions for all variables of the given type.
*/
protected void writeInputs( TestCase testCase, String type)
{
xmlWriter_.writeTagStart( INPUT_TAG);
xmlWriter_.writeAttribute( TYPE_ATR, type);
xmlWriter_.writeTagEnd();
xmlWriter_.indent();
VarBinding[] bindings = IteratorUtils.toArray( testCase.getVarBindings( type), VarBinding.class);
Arrays.sort( bindings);
for( int i = 0; i < bindings.length; i++)
{
writeBinding( bindings[i]);
}
xmlWriter_.unindent();
xmlWriter_.writeElementEnd( INPUT_TAG);
}
示例5: areDifferentValues
import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
@Override
public boolean areDifferentValues(final Iterator<?> sourceValue, final Iterator<?> targetValue) {
if (sourceValue == targetValue) {
return false;
}
if (sourceValue == null || targetValue == null) {
return true;
} else {
final Object[] sourceValuesArray = IteratorUtils.toArray(sourceValue);
final Object[] targetValuesArray = IteratorUtils.toArray(targetValue);
return !Arrays.deepEquals(sourceValuesArray, targetValuesArray);
}
}
示例6: writeAnnotations
import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
/**
* Writes the given annotation definitions.
*/
protected void writeAnnotations( Annotated annotated)
{
String[] annotations = IteratorUtils.toArray( annotated.getAnnotations(), String.class);
Arrays.sort( annotations);
for( int i = 0; i < annotations.length; i++)
{
xmlWriter_.writeTagStart( HAS_TAG);
xmlWriter_.writeAttribute( NAME_ATR, annotations[i]);
xmlWriter_.writeAttribute( VALUE_ATR, annotated.getAnnotation( annotations[i]));
xmlWriter_.writeEmptyElementEnd();
}
}
示例7: testGetGeneratorSet_4
import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
/**
* Tests {@link GeneratorSetDocReader#getGeneratorSet getGeneratorSet()} using the following inputs.
* <P>
* <TABLE border="1" cellpadding="8">
* <TR align="left"><TH colspan=2> 4. getGeneratorSet (Success) </TH></TR>
* <TR align="left"><TH> Input Choice </TH> <TH> Value </TH></TR>
* <TR><TD> TupleGenerator.Count </TD> <TD> One </TD></TR>
* <TR><TD> TupleGenerator.Function </TD> <TD> Default </TD></TR>
* <TR><TD> TupleGenerator.Seed </TD> <TD> Defined </TD></TR>
* <TR><TD> TupleGenerator.Tuples </TD> <TD> Defined </TD></TR>
* <TR><TD> Combiner.Count </TD> <TD> One </TD></TR>
* <TR><TD> Combiner.Tuples </TD> <TD> Default </TD></TR>
* <TR><TD> Include.Count </TD> <TD> One </TD></TR>
* <TR><TD> Include.Var </TD> <TD> Valid </TD></TR>
* <TR><TD> Exclude.Count </TD> <TD> None </TD></TR>
* <TR><TD> Exclude.Var </TD> <TD> NA </TD></TR>
* </TABLE>
* </P>
*/
@Test
public void testGetGeneratorSet_4()
{
IGeneratorSet generatorSet = generatorSetResources_.read( "generator-set-4.xml");
ITestCaseGenerator[] generators = IteratorUtils.toArray( generatorSet.getGenerators(), ITestCaseGenerator.class);
assertEquals( "Generators", 1, generators.length);
TupleGenerator tupleGenerator;
String functionName;
TupleCombiner[] combiners;
TupleCombiner combiner;
VarSet varSet;
IVarDef varDef;
tupleGenerator = (TupleGenerator ) generators[0];
functionName = "F4";
assertEquals( "Found default generator for function=" + functionName, true, tupleGenerator == generatorSet.getGenerator( functionName));
assertEquals( "Default generator, seed", new Long( 12345L), tupleGenerator.getRandomSeed());
assertEquals( "Default generator, defaultTupleSize", 3, tupleGenerator.getDefaultTupleSize());
combiners = tupleGenerator.getCombiners().toArray( new TupleCombiner[ tupleGenerator.getCombiners().size()]);
assertEquals( "Default generator, combiners", 1, tupleGenerator.getCombiners().size());
combiner = combiners[0];
assertEquals( "Combiner[0], tupleSize", tupleGenerator.getDefaultTupleSize(), combiner.getTupleSize());
varSet = new VarSet( "A").addMember( new VarSet( "X").addMember( new VarDef( "Y")));
varDef = varSet.getDescendant( "X");
assertEquals( "Combiner[0], var=" + varDef + ", eligible", false, combiner.isEligible( varDef));
varDef = new VarDef( "B");
assertEquals( "Combiner[0], var=" + varDef + ", eligible", false, combiner.isEligible( varDef));
varDef = new VarDef( "X");
assertEquals( "Combiner[0], var=" + varDef + ", eligible", true, combiner.isEligible( varDef));
}
示例8: testOnceTuples
import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
@Test
public void testOnceTuples()
{
IGeneratorSet generatorSet = generatorSetResources_.read( "generator-set-once.xml");
ITestCaseGenerator[] generators = IteratorUtils.toArray( generatorSet.getGenerators(), ITestCaseGenerator.class);
assertEquals( "Generators", 1, generators.length);
TupleGenerator tupleGenerator;
TupleCombiner[] combiners;
TupleCombiner combiner;
tupleGenerator = (TupleGenerator ) generators[0];
combiners = tupleGenerator.getCombiners().toArray( new TupleCombiner[ tupleGenerator.getCombiners().size()]);
assertEquals( "Default generator, combiners", 1, tupleGenerator.getCombiners().size());
combiner = combiners[0];
assertSetEquals
( "Other tuples",
new TupleRef[]
{
new TupleRef()
.addVarBinding( new VarBinding( "X1", "V1"))
.addVarBinding( new VarBinding( "X2", "V2"))
.addVarBinding( new VarBinding( "X3", "V3")),
new TupleRef()
.addVarBinding( new VarBinding( "X4", "V4"))
.addVarBinding( new VarBinding( "X5", "V5"))
.addVarBinding( new VarBinding( "X6", "V6"))
},
combiner.getOnceTuples());
}
示例9: evaluateNodes
import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
public XdmNode[] evaluateNodes(String expr, IndependentContext context, @Nullable XdmItem contextItem) throws SaxonApiException {
XdmValue value = this.evaluate(expr, context, contextItem);
return ((value != null) ? IteratorUtils.toArray(CrigttIteratorUtils.instances(value.iterator(), XdmNode.class), XdmNode.class) : new XdmNode[0]);
}
示例10: testGetGeneratorSet_1
import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
/**
* Tests {@link GeneratorSetDocReader#getGeneratorSet getGeneratorSet()} using the following inputs.
* <P>
* <TABLE border="1" cellpadding="8">
* <TR align="left"><TH colspan=2> 1. getGeneratorSet (Success) </TH></TR>
* <TR align="left"><TH> Input Choice </TH> <TH> Value </TH></TR>
* <TR><TD> TupleGenerator.Count </TD> <TD> One </TD></TR>
* <TR><TD> TupleGenerator.Function </TD> <TD> Defined </TD></TR>
* <TR><TD> TupleGenerator.Seed </TD> <TD> Defined </TD></TR>
* <TR><TD> TupleGenerator.Tuples </TD> <TD> Defined </TD></TR>
* <TR><TD> Combiner.Count </TD> <TD> One </TD></TR>
* <TR><TD> Combiner.Tuples </TD> <TD> Default </TD></TR>
* <TR><TD> Include.Count </TD> <TD> None </TD></TR>
* <TR><TD> Include.Var </TD> <TD> NA </TD></TR>
* <TR><TD> Exclude.Count </TD> <TD> Many </TD></TR>
* <TR><TD> Exclude.Var </TD> <TD> Valid </TD></TR>
* </TABLE>
* </P>
*/
@Test
public void testGetGeneratorSet_1()
{
IGeneratorSet generatorSet = generatorSetResources_.read( "generator-set-1.xml");
ITestCaseGenerator[] generators = IteratorUtils.toArray( generatorSet.getGenerators(), ITestCaseGenerator.class);
assertEquals( "Generators", 1, generators.length);
TupleGenerator tupleGenerator;
String functionName;
TupleCombiner[] combiners;
TupleCombiner combiner;
VarSet varSet;
IVarDef varDef;
tupleGenerator = (TupleGenerator ) generators[0];
assertEquals( "Generator 0, seed", new Long( 1234L), tupleGenerator.getRandomSeed());
assertEquals( "Generator 0, defaultTupleSize", 3, tupleGenerator.getDefaultTupleSize());
functionName = "F1";
assertEquals( "getGenerator, function=" + functionName, tupleGenerator, generatorSet.getGenerator( functionName));
functionName = null;
assertEquals( "getGenerator, function=" + functionName, null, generatorSet.getGenerator( functionName));
combiners = tupleGenerator.getCombiners().toArray( new TupleCombiner[ tupleGenerator.getCombiners().size()]);
assertEquals( "Generator 0, combiners", 1, combiners.length);
combiner = combiners[0];
varSet =
new VarSet( "include1")
.addMember( new VarSet( "B").addMember( new VarDef( "C")));
varDef = varSet.getDescendant( "B.C");
assertEquals( "Combiner[0], var=" + varDef + ", eligible", true, combiner.isEligible( varDef));
varDef = new VarDef( "include2");
assertEquals( "Combiner[0], var=" + varDef + ", eligible", true, combiner.isEligible( varDef));
varSet =
new VarSet( "exclude1")
.addMember( new VarDef( "var"))
.addMember( new VarDef( "var2"));
varDef = varSet.getDescendant( "var");
assertEquals( "Combiner[0], var=" + varDef + ", eligible", false, combiner.isEligible( varDef));
varDef = varSet.getDescendant( "var2");
assertEquals( "Combiner[0], var=" + varDef + ", eligible", true, combiner.isEligible( varDef));
varSet =
new VarSet( "exclude2")
.addMember( new VarSet( "var").addMember( new VarSet( "A").addMember( new VarDef( "B"))))
.addMember( new VarDef( "var2"));
varDef = varSet.getDescendant( "var.A.B");
assertEquals( "Combiner[0], var=" + varDef + ", eligible", false, combiner.isEligible( varDef));
}
示例11: convertNot
import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
@Test
public void convertNot()
{
// Given...
ICondition condition =
new Not()
.add( new AnyOf().add( new ContainsAny( "A", "B")).add( new ContainsAny( "C")));
// When...
IConjunct conjunct = Cnf.convert( condition);
// Then...
IDisjunct[] disjuncts = IteratorUtils.toArray( conjunct.getDisjuncts(), IDisjunct.class);
assertEquals( "Disjuncts", 3, disjuncts.length);
assertEquals( "Satisfied: A, B, C", false, conjunct.satisfied( new PropertySet( "A", "B", "C")));
assertEquals( "Satisfied: A, B, !C", false, conjunct.satisfied( new PropertySet( "A", "B")));
assertEquals( "Satisfied: A, !B, C", false, conjunct.satisfied( new PropertySet( "A", "C")));
assertEquals( "Satisfied: A, !B, !C", false, conjunct.satisfied( new PropertySet( "A")));
assertEquals( "Satisfied: !A, B, C", false, conjunct.satisfied( new PropertySet( "B", "C")));
assertEquals( "Satisfied: !A, !B, C", false, conjunct.satisfied( new PropertySet( "C")));
assertEquals( "Satisfied: !A, B, !C", false, conjunct.satisfied( new PropertySet( "B")));
assertEquals( "Satisfied: !A, !B, !C", true, conjunct.satisfied( new PropertySet()));
// Given...
condition = new Not( condition);
// When...
conjunct = Cnf.convert( condition);
// Then...
disjuncts = IteratorUtils.toArray( conjunct.getDisjuncts(), IDisjunct.class);
assertEquals( "Disjuncts", 1, disjuncts.length);
assertEquals( "Satisfied: A, B, C", true, conjunct.satisfied( new PropertySet( "A", "B", "C")));
assertEquals( "Satisfied: A, B, !C", true, conjunct.satisfied( new PropertySet( "A", "B")));
assertEquals( "Satisfied: A, !B, C", true, conjunct.satisfied( new PropertySet( "A", "C")));
assertEquals( "Satisfied: A, !B, !C", true, conjunct.satisfied( new PropertySet( "A")));
assertEquals( "Satisfied: !A, B, C", true, conjunct.satisfied( new PropertySet( "B", "C")));
assertEquals( "Satisfied: !A, !B, C", true, conjunct.satisfied( new PropertySet( "C")));
assertEquals( "Satisfied: !A, B, !C", true, conjunct.satisfied( new PropertySet( "B")));
assertEquals( "Satisfied: !A, !B, !C", false, conjunct.satisfied( new PropertySet()));
}
示例12: testTreeTraversal
import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
/**
* Test when traversing a tree of {@link VarSet variable sets}.
*/
@Test
public void testTreeTraversal()
{
// Given...
FunctionInputDef inputDef = new FunctionInputDef( "testTreeTraversal");
VarSet varSet;
VarSet member;
varSet = new VarSet( "1");
varSet.addMember( new VarSet( "1"));
varSet.addMember( new VarSet( "2"));
inputDef.addVarDef( varSet);
member = (VarSet) varSet.getMember( "1");
member.addMember( new VarSet( "1"));
member.addMember( new VarDef( "2"));
member = (VarSet) member.getMember( "1");
member.addMember( new VarDef( "1"));
member.addMember( new VarDef( "2"));
member = (VarSet) varSet.getMember( "2");
member.addMember( new VarDef( "1"));
varSet = new VarSet( "2");
varSet.addMember( new VarDef( "1"));
varSet.addMember( new VarSet( "2"));
inputDef.addVarDef( varSet);
member = (VarSet) varSet.getMember( "2");
member.addMember( new VarDef( "1"));
member.addMember( new VarDef( "2"));
// When...
String[] varDefNames =
IteratorUtils.toArray
( IteratorUtils.transformedIterator
( new VarDefIterator( inputDef),
new Transformer<VarDef,String>()
{
public String transform( VarDef varDef)
{
return varDef.getPathName();
}
}),
String.class);
// Then...
assertArrayEquals
( "VarDef sequence",
new String[]{ "1.1.1.1", "1.1.1.2", "1.1.2", "1.2.1", "2.1", "2.2.1", "2.2.2"},
varDefNames);
}
示例13: testGetSystemTestDef_1
import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
/**
* Tests {@link SystemTestDocReader#getSystemTestDef getSystemTestDef()} using the following inputs.
* <P>
* <TABLE border="1" cellpadding="8">
* <TR align="left"><TH colspan=2> 1. getSystemTestDef (Success) </TH></TR>
* <TR align="left"><TH> Input Choice </TH> <TH> Value </TH></TR>
* <TR><TD> TestCases.System </TD> <TD> Defined </TD></TR>
* <TR><TD> Function.Count </TD> <TD> None </TD></TR>
* <TR><TD> Function.Name </TD> <TD> NA </TD></TR>
* <TR><TD> TestCase.Count </TD> <TD> NA </TD></TR>
* <TR><TD> TestCase.Id </TD> <TD> NA </TD></TR>
* <TR><TD> TestCase.Failure </TD> <TD> NA </TD></TR>
* <TR><TD> Input.Count </TD> <TD> NA </TD></TR>
* <TR><TD> Input.Type </TD> <TD> NA </TD></TR>
* <TR><TD> Var.Count </TD> <TD> NA </TD></TR>
* <TR><TD> Var.Name </TD> <TD> NA </TD></TR>
* <TR><TD> Var.Value </TD> <TD> NA </TD></TR>
* <TR><TD> Var.Failure </TD> <TD> NA </TD></TR>
* </TABLE>
* </P>
*/
@Test
public void testGetSystemTestDef_1()
{
SystemTestDef systemTestDef = systemTestResources_.read( "system-test-def-1.xml");
assertEquals( "System name", "System-1", systemTestDef.getName());
FunctionTestDef[] functionTestDefs = IteratorUtils.toArray( systemTestDef.getFunctionTestDefs(), FunctionTestDef.class);
assertEquals( "Function test defs", 0, functionTestDefs.length);
}
示例14: testGetGeneratorSet_0
import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
/**
* Tests {@link GeneratorSetDocReader#getGeneratorSet getGeneratorSet()} using the following inputs.
* <P>
* <TABLE border="1" cellpadding="8">
* <TR align="left"><TH colspan=2> 0. getGeneratorSet (Success) </TH></TR>
* <TR align="left"><TH> Input Choice </TH> <TH> Value </TH></TR>
* <TR><TD> TupleGenerator.Count </TD> <TD> None </TD></TR>
* <TR><TD> TupleGenerator.Function </TD> <TD> NA </TD></TR>
* <TR><TD> TupleGenerator.Seed </TD> <TD> NA </TD></TR>
* <TR><TD> TupleGenerator.Tuples </TD> <TD> NA </TD></TR>
* <TR><TD> Combiner.Count </TD> <TD> NA </TD></TR>
* <TR><TD> Combiner.Tuples </TD> <TD> NA </TD></TR>
* <TR><TD> Include.Count </TD> <TD> NA </TD></TR>
* <TR><TD> Include.Var </TD> <TD> NA </TD></TR>
* <TR><TD> Exclude.Count </TD> <TD> NA </TD></TR>
* <TR><TD> Exclude.Var </TD> <TD> NA </TD></TR>
* </TABLE>
* </P>
*/
@Test
public void testGetGeneratorSet_0()
{
IGeneratorSet generatorSet = generatorSetResources_.read( "generator-set-0.xml");
ITestCaseGenerator[] generators = IteratorUtils.toArray( generatorSet.getGenerators(), ITestCaseGenerator.class);
assertEquals( "Generators", 0, generators.length);
}
示例15: testGetSystemInputDef_4
import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
/**
* Tests {@link SystemInputDocReader#getSystemInputDef getSystemInputDef()} using the following inputs.
* <P>
* <TABLE border="1" cellpadding="8">
* <TR align="left"><TH colspan=2> 4. getSystemInputDef (Success) </TH></TR>
* <TR align="left"><TH> Input Choice </TH> <TH> Value </TH></TR>
* <TR><TD> System.Name </TD> <TD> Defined </TD></TR>
* <TR><TD> Function.Count </TD> <TD> Many </TD></TR>
* <TR><TD> Function.Name </TD> <TD> Defined </TD></TR>
* <TR><TD> Type.Count </TD> <TD> One </TD></TR>
* <TR><TD> Type.Name </TD> <TD> Defined </TD></TR>
* <TR><TD> Var.Count </TD> <TD> One </TD></TR>
* <TR><TD> Var.Name </TD> <TD> Defined </TD></TR>
* <TR><TD> Var.WhenProperties </TD> <TD> None </TD></TR>
* <TR><TD> Var.WhenNotProperties </TD> <TD> None </TD></TR>
* <TR><TD> Var.Condition </TD> <TD> AnyOf </TD></TR>
* <TR><TD> Var.ValidValues </TD> <TD> Many </TD></TR>
* <TR><TD> Var.FailureValues </TD> <TD> Many </TD></TR>
* <TR><TD> Var.OnceValue </TD> <TD> Yes </TD></TR>
* <TR><TD> Value.Name </TD> <TD> Defined </TD></TR>
* <TR><TD> Value.WhenProperties </TD> <TD> None </TD></TR>
* <TR><TD> Value.WhenNotProperties </TD> <TD> None </TD></TR>
* <TR><TD> Value.Condition </TD> <TD> AnyOf </TD></TR>
* <TR><TD> Value.Properties </TD> <TD> None </TD></TR>
* <TR><TD> Property.Count </TD> <TD> None </TD></TR>
* <TR><TD> Property.Properties </TD> <TD> NA </TD></TR>
* <TR><TD> VarSet.Count </TD> <TD> None </TD></TR>
* <TR><TD> VarSet.Name </TD> <TD> NA </TD></TR>
* <TR><TD> VarSet.WhenProperties </TD> <TD> NA </TD></TR>
* <TR><TD> VarSet.WhenNotProperties </TD> <TD> NA </TD></TR>
* <TR><TD> VarSet.Condition </TD> <TD> NA </TD></TR>
* <TR><TD> VarSet.Members </TD> <TD> NA </TD></TR>
* <TR><TD> Condition.Properties </TD> <TD> One </TD></TR>
* <TR><TD> Condition.Members </TD> <TD> None </TD></TR>
* </TABLE>
* </P>
*/
@Test
public void testGetSystemInputDef_4()
{
SystemInputDef systemInputDef = systemInputResources_.read( "system-input-def-4.xml");
assertEquals( "System name", "System-4", systemInputDef.getName());
FunctionInputDef[] functionInputDefs = IteratorUtils.toArray( systemInputDef.getFunctionInputDefs(), FunctionInputDef.class);
assertEquals( "Function input defs", 2, functionInputDefs.length);
}