idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
121,400
protected Tuple2 < String , Seq < Object > > toScalaTuple ( String message , List < Object > params ) { return new Tuple2 < String , Seq < Object > > ( message , JavaConverters . collectionAsScalaIterableConverter ( params ) . asScala ( ) . toSeq ( ) ) ; }
A helper method to create the tuple expected by PasswordValidator from a Java String and List objects .
121,401
private void validate ( ) { if ( isValid != null ) { return ; } ParsingValidator v = new ParsingValidator ( useSchema ? Languages . W3C_XML_SCHEMA_NS_URI : Languages . XML_DTD_NS_URI ) ; List < Source > schemaSourceList = new ArrayList < Source > ( ) ; if ( systemId != null ) { schemaSourceList . add ( new StreamSource...
Actually perform validation .
121,402
private void invalidate ( String message ) { isValid = Boolean . FALSE ; messages . append ( message ) . append ( ' ' ) ; }
Set the validation status flag to false and capture the message for use later .
121,403
private StringBuilder getXSLTBase ( ) { StringBuilder result = new StringBuilder ( XML_DECLARATION ) . append ( XMLUnit . getXSLTStart ( ) ) ; String tmp = result . toString ( ) ; int close = tmp . lastIndexOf ( '>' ) ; if ( close == - 1 ) { close = tmp . length ( ) ; } result . insert ( close , getNamespaceDeclaration...
What every XSL transform needs
121,404
private void performTransform ( String xslt , Document document , Result result ) throws TransformerException , ConfigurationException , XpathException { try { StreamSource source = new StreamSource ( new StringReader ( xslt ) ) ; TransformerFactory tf = XMLUnit . newTransformerFactory ( ) ; ErrorListener el = new Erro...
Perform the actual transformation work required
121,405
protected Node getXPathResultNode ( String select , Document document ) throws ConfigurationException , TransformerException , XpathException { return getXPathResultAsDocument ( select , document ) . getDocumentElement ( ) ; }
Testable method to execute the copy - of transform and return the root node of the resulting Document .
121,406
protected Document getXPathResultAsDocument ( String select , Document document ) throws ConfigurationException , TransformerException , XpathException { DOMResult result = new DOMResult ( ) ; performTransform ( getCopyTransformation ( select ) , document , result ) ; return ( Document ) result . getNode ( ) ; }
Execute the copy - of transform and return the resulting Document . Used for XMLTestCase comparison
121,407
private String getNamespaceDeclarations ( ) { StringBuilder nsDecls = new StringBuilder ( ) ; String quoteStyle = "'" ; for ( Iterator keys = ctx . getPrefixes ( ) ; keys . hasNext ( ) ; ) { String prefix = ( String ) keys . next ( ) ; String uri = ctx . getNamespaceURI ( prefix ) ; if ( uri == null ) { continue ; } if...
returns namespace declarations for all namespaces known to the current context .
121,408
protected boolean similar ( Text control , Text test ) { if ( control == null ) { return test == null ; } else if ( test == null ) { return false ; } return control . getNodeValue ( ) . equals ( test . getNodeValue ( ) ) ; }
Determine whether the text nodes contain similar values
121,409
protected Text extractText ( Element fromElement ) { fromElement . normalize ( ) ; NodeList fromNodeList = fromElement . getChildNodes ( ) ; Node currentNode ; for ( int i = 0 ; i < fromNodeList . getLength ( ) ; ++ i ) { currentNode = fromNodeList . item ( i ) ; if ( currentNode . getNodeType ( ) == Node . TEXT_NODE )...
Extract the normalized text from within an element
121,410
public static DifferenceEvaluator first ( final DifferenceEvaluator ... evaluators ) { return new DifferenceEvaluator ( ) { public ComparisonResult evaluate ( Comparison comparison , ComparisonResult orig ) { for ( DifferenceEvaluator ev : evaluators ) { ComparisonResult evaluated = ev . evaluate ( comparison , orig ) ...
Combines multiple DifferenceEvaluators so that the first one that changes the outcome wins .
121,411
public static DifferenceEvaluator chain ( final DifferenceEvaluator ... evaluators ) { return new DifferenceEvaluator ( ) { public ComparisonResult evaluate ( Comparison comparison , ComparisonResult orig ) { ComparisonResult finalResult = orig ; for ( DifferenceEvaluator ev : evaluators ) { ComparisonResult evaluated ...
Combines multiple DifferenceEvaluators so that the result of the first Evaluator will be passed to the next Evaluator .
121,412
public static String getMergedNestedText ( Node n ) { StringBuilder sb = new StringBuilder ( ) ; for ( Node child : new IterableNodeList ( n . getChildNodes ( ) ) ) { if ( child instanceof Text || child instanceof CDATASection ) { String s = child . getNodeValue ( ) ; if ( s != null ) { sb . append ( s ) ; } } } return...
Tries to merge all direct Text and CDATA children of the given Node and concatenates their value .
121,413
public static Map < QName , String > getAttributes ( Node n ) { Map < QName , String > map = new LinkedHashMap < QName , String > ( ) ; NamedNodeMap m = n . getAttributes ( ) ; if ( m != null ) { final int len = m . getLength ( ) ; for ( int i = 0 ; i < len ; i ++ ) { Attr a = ( Attr ) m . item ( i ) ; map . put ( getQ...
Obtains an element s attributes as Map .
121,414
private static void handleWsRec ( Node n , boolean normalize ) { if ( n instanceof CharacterData || n instanceof ProcessingInstruction ) { String s = n . getNodeValue ( ) . trim ( ) ; if ( normalize ) { s = normalize ( s ) ; } n . setNodeValue ( s ) ; } List < Node > toRemove = new LinkedList < Node > ( ) ; for ( Node ...
Trims textual content of this node removes empty text and CDATA children recurses into its child nodes .
121,415
static String normalize ( String s ) { StringBuilder sb = new StringBuilder ( ) ; boolean changed = false ; boolean lastCharWasWS = false ; final int len = s . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { char c = s . charAt ( i ) ; if ( Character . isWhitespace ( c ) ) { if ( ! lastCharWasWS ) { sb . append ( SPA...
Normalize a string .
121,416
public static void assertXMLEqual ( String msg , Diff diff , boolean assertion ) { if ( assertion != diff . similar ( ) ) { fail ( getFailMessage ( msg , diff ) ) ; } }
Assert that the result of an XML comparison is or is not similar .
121,417
public static void assertXMLIdentical ( String msg , Diff diff , boolean assertion ) { if ( assertion != diff . identical ( ) ) { fail ( getFailMessage ( msg , diff ) ) ; } }
Assert that the result of an XML comparison is or is not identical
121,418
public static void assertXpathsEqual ( String controlXpath , String testXpath , Document document ) throws XpathException { assertXpathsEqual ( controlXpath , document , testXpath , document ) ; }
Assert that the node lists of two Xpaths in the same document are equal
121,419
public static void assertXpathsEqual ( String controlXpath , Document controlDocument , String testXpath , Document testDocument ) throws XpathException { assertXpathEquality ( controlXpath , controlDocument , testXpath , testDocument , true ) ; }
Assert that the node lists of two Xpaths in two documents are equal
121,420
public static void assertXpathsNotEqual ( String controlXpath , String testXpath , Document document ) throws XpathException { assertXpathsNotEqual ( controlXpath , document , testXpath , document ) ; }
Assert that the node lists of two Xpaths in the same document are NOT equal
121,421
public static void assertXpathsNotEqual ( String controlXpath , InputSource controlDocument , String testXpath , InputSource testDocument ) throws SAXException , IOException , XpathException { assertXpathsNotEqual ( controlXpath , XMLUnit . buildControlDocument ( controlDocument ) , testXpath , XMLUnit . buildTestDocum...
Assert that the node lists of two Xpaths in two XML strings are NOT equal
121,422
public static void assertXpathsNotEqual ( String controlXpath , Document controlDocument , String testXpath , Document testDocument ) throws XpathException { assertXpathEquality ( controlXpath , controlDocument , testXpath , testDocument , false ) ; }
Assert that the node lists of two Xpaths in two documents are NOT equal
121,423
private static void assertXpathEquality ( String controlXpath , Document controlDocument , String testXpath , Document testDocument , boolean equal ) throws XpathException { XpathEngine xpath = XMLUnit . newXpathEngine ( ) ; Diff diff = new Diff ( asXpathResultDocument ( XMLUnit . newControlParser ( ) , xpath . getMatc...
Assert that the node lists of two Xpaths in two documents are equal or not .
121,424
public static void assertXpathValuesEqual ( String controlXpath , String testXpath , Document document ) throws XpathException { assertXpathValuesEqual ( controlXpath , document , testXpath , document ) ; }
Assert that the evaluation of two Xpaths in the same document are equal
121,425
public static void assertXpathValuesEqual ( String controlXpath , Document controlDocument , String testXpath , Document testDocument ) throws XpathException { XpathEngine xpath = XMLUnit . newXpathEngine ( ) ; assertEquals ( xpath . evaluate ( controlXpath , controlDocument ) , xpath . evaluate ( testXpath , testDocum...
Assert that the evaluation of two Xpaths in two documents are equal
121,426
public static void assertXpathValuesNotEqual ( String controlXpath , String testXpath , Document document ) throws XpathException { assertXpathValuesNotEqual ( controlXpath , document , testXpath , document ) ; }
Assert that the evaluation of two Xpaths in the same document are NOT equal
121,427
public static void assertXpathValuesNotEqual ( String controlXpath , Document controlDocument , String testXpath , Document testDocument ) throws XpathException { XpathEngine xpath = XMLUnit . newXpathEngine ( ) ; String control = xpath . evaluate ( controlXpath , controlDocument ) ; String test = xpath . evaluate ( te...
Assert that the evaluation of two Xpaths in two documents are NOT equal
121,428
public static void assertXpathEvaluatesTo ( String expectedValue , String xpathExpression , InputSource control ) throws SAXException , IOException , XpathException { Document document = XMLUnit . buildControlDocument ( control ) ; assertXpathEvaluatesTo ( expectedValue , xpathExpression , document ) ; }
Assert the value of an Xpath expression in an XML document .
121,429
public static void assertXpathNotExists ( String xPathExpression , Document inDocument ) throws XpathException { XpathEngine simpleXpathEngine = XMLUnit . newXpathEngine ( ) ; NodeList nodeList = simpleXpathEngine . getMatchingNodes ( xPathExpression , inDocument ) ; int matches = nodeList . getLength ( ) ; assertEqual...
Assert that a specific XPath does NOT exist in some given XML
121,430
private void provideSystemIdIfRequired ( Source source ) { if ( source != null && ( source . getSystemId ( ) == null || source . getSystemId ( ) . length ( ) == 0 ) ) { source . setSystemId ( getDefaultSystemId ( ) ) ; } }
Ensure that the source has a systemId
121,431
protected void transformTo ( final Result result ) throws TransformerException { withExceptionHandling ( new Trans < Object > ( ) { public Object transform ( ) { transformation . transformTo ( result ) ; return null ; } } ) ; }
Perform the actual transformation
121,432
public void setOutputProperties ( Properties outputProperties ) { for ( Enumeration e = outputProperties . propertyNames ( ) ; e . hasMoreElements ( ) ; ) { Object key = e . nextElement ( ) ; if ( key != null ) { String name = key . toString ( ) ; String value = outputProperties . getProperty ( name ) ; if ( value != n...
Override output properties specified in the transformation stylesheet
121,433
public void setParameter ( String name , Object value ) { parameters . put ( name , value ) ; transformation . addParameter ( name , value ) ; }
Add a parameter for the transformation
121,434
private void ensureContentAvailable ( ) throws IOException { if ( nodeContentBytes . size ( ) > 0 ) { return ; } try { Transform serializeTransform = new Transform ( rootNode ) ; if ( outputProperties != null ) { serializeTransform . setOutputProperties ( outputProperties ) ; } StreamResult byteResult = new StreamResul...
Do the actual work of serializing the node to bytes
121,435
public int read ( char [ ] cbuf , int off , int len ) throws IOException { int startPos = off ; int currentlyRead ; while ( off - startPos < len && ( currentlyRead = read ( ) ) != - 1 ) { cbuf [ off ++ ] = ( char ) currentlyRead ; } return off == startPos && len != 0 ? - 1 : off - startPos ; }
Read DOCTYPE - replaced content from the wrapped Reader
121,436
public void setNamespaceContext ( Map < String , String > prefix2uri ) { this . prefix2uri = prefix2uri == null ? Collections . < String , String > emptyMap ( ) : Collections . unmodifiableMap ( prefix2uri ) ; }
Establish a namespace context that will be used in for the XPath .
121,437
private void appendDifference ( StringBuilder appendTo , Difference difference ) { appendTo . append ( ' ' ) . append ( difference ) . append ( '\n' ) ; }
Append a meaningful message to the buffer of messages
121,438
public StringBuffer appendMessage ( StringBuffer toAppendTo ) { compare ( ) ; if ( messages . length ( ) == 0 ) { messages . append ( "[identical]" ) ; } return toAppendTo . append ( messages . toString ( ) ) ; }
Append the message from the result of this Diff instance to a specified StringBuffer
121,439
private DifferenceEngineContract getDifferenceEngine ( ) { if ( differenceEngine == null ) { if ( XMLUnit . getIgnoreAttributeOrder ( ) && ( ! usesUnknownElementQualifier ( ) || XMLUnit . getCompareUnmatched ( ) ) ) { return new NewDifferenceEngine ( this , matchTrackerDelegate ) ; } return new DifferenceEngine ( this ...
Lazily initializes the difference engine if it hasn t been set via a constructor .
121,440
public SingleNodeAssert hasAttribute ( String attributeName ) { isNotNull ( ) ; final Map . Entry < QName , String > entry = attributeForName ( attributeName ) ; if ( entry == null ) { throwAssertionError ( shouldHaveAttribute ( actual . getNodeName ( ) , attributeName ) ) ; } return this ; }
Verifies that node has attribute with given name .
121,441
public SingleNodeAssert hasAttribute ( String attributeName , String attributeValue ) { isNotNull ( ) ; final Map . Entry < QName , String > attribute = attributeForName ( attributeName ) ; if ( attribute == null || ! attribute . getValue ( ) . equals ( attributeValue ) ) { throwAssertionError ( shouldHaveAttributeWith...
Verifies that node has attribute with given name and value .
121,442
public SingleNodeAssert doesNotHaveAttribute ( String attributeName ) { isNotNull ( ) ; final Map . Entry < QName , String > entry = attributeForName ( attributeName ) ; if ( entry != null ) { throwAssertionError ( shouldNotHaveAttribute ( actual . getNodeName ( ) , attributeName ) ) ; } return this ; }
Verifies that node has not attribute with given name .
121,443
protected final ComparisonState compare ( Comparison comp ) { Object controlValue = comp . getControlDetails ( ) . getValue ( ) ; Object testValue = comp . getTestDetails ( ) . getValue ( ) ; boolean equal = controlValue == null ? testValue == null : controlValue . equals ( testValue ) ; ComparisonResult initial = equa...
Compares the detail values for object equality lets the difference evaluator and comparison controller evaluate the result notifies all listeners and returns the outcome .
121,444
public static void setIgnoreWhitespace ( boolean ignore ) { ignoreWhitespace = ignore ; getControlDocumentBuilderFactory ( ) . setIgnoringElementContentWhitespace ( ignore ) ; getTestDocumentBuilderFactory ( ) . setIgnoringElementContentWhitespace ( ignore ) ; }
Whether to ignore whitespace when comparing node values .
121,445
public static Document buildControlDocument ( String fromXML ) throws SAXException , IOException { return buildDocument ( newControlParser ( ) , new StringReader ( fromXML ) ) ; }
Utility method to build a Document using the control DocumentBuilder to parse the specified String .
121,446
public static Document buildDocument ( DocumentBuilder withBuilder , Reader fromReader ) throws SAXException , IOException { return buildDocument ( withBuilder , new InputSource ( fromReader ) ) ; }
Utility method to build a Document using a specific DocumentBuilder and reading characters from a specific Reader .
121,447
public static Document buildDocument ( DocumentBuilder withBuilder , InputSource fromSource ) throws IOException , SAXException { return withBuilder . parse ( fromSource ) ; }
Utility method to build a Document using a specific DocumentBuilder and a specific InputSource
121,448
public static void setURIResolver ( URIResolver resolver ) { if ( uriResolver != resolver ) { uriResolver = resolver ; transformerFactory = null ; getTransformerFactory ( ) ; } }
Sets the URIResolver to use during transformations .
121,449
public static SAXParserFactory getSAXParserFactory ( ) { if ( saxParserFactory == null ) { saxParserFactory = SAXParserFactory . newInstance ( ) ; saxParserFactory . setNamespaceAware ( true ) ; } return saxParserFactory ; }
Get the SAX parser to use in tests .
121,450
public static Document getWhitespaceStrippedDocument ( Document forDoc ) { String factory = getTransformerFactory ( ) . getClass ( ) . getName ( ) ; if ( XSLTConstants . JAVA5_XSLTC_FACTORY_NAME . equals ( factory ) ) { return stripWhiteSpaceWithoutXSLT ( forDoc ) ; } else { return stripWhiteSpaceUsingXSLT ( forDoc ) ;...
Returns a new Document instance that is identical to the one passed in with element content whitespace removed .
121,451
public static Diff compareXML ( InputSource control , InputSource test ) throws SAXException , IOException { return new Diff ( control , test ) ; }
Compare XML documents provided by two InputSource classes
121,452
public static Diff compareXML ( String control , String test ) throws SAXException , IOException { return new Diff ( control , test ) ; }
Compare two XML documents provided as strings
121,453
public static XpathEngine newXpathEngine ( ) { XpathEngine eng = new org . custommonkey . xmlunit . jaxp13 . Jaxp13XpathEngine ( ) ; if ( namespaceContext != null ) { eng . setNamespaceContext ( namespaceContext ) ; } return eng ; }
Obtains an XpathEngine to use in XPath tests .
121,454
public static void setIgnoreDiffBetweenTextAndCDATA ( boolean b ) { ignoreDiffBetweenTextAndCDATA = b ; getControlDocumentBuilderFactory ( ) . setCoalescing ( b ) ; getTestDocumentBuilderFactory ( ) . setCoalescing ( b ) ; }
Whether CDATA sections and Text nodes should be considered the same .
121,455
public static void setXSLTVersion ( String s ) { try { Number n = NumberFormat . getInstance ( Locale . US ) . parse ( s ) ; if ( n . doubleValue ( ) < 0 ) { throw new ConfigurationException ( s + " doesn't reperesent a" + " positive number." ) ; } } catch ( ParseException e ) { throw new ConfigurationException ( e ) ;...
Sets the XSLT version to set on stylesheets used internally .
121,456
public static void setExpandEntityReferences ( boolean b ) { expandEntities = b ; getControlDocumentBuilderFactory ( ) . setExpandEntityReferences ( b ) ; getTestDocumentBuilderFactory ( ) . setExpandEntityReferences ( b ) ; }
Whether the parser shall be instructed to expand entity references .
121,457
public ValidationAssert isValid ( ) { ValidationResult validationResult = validate ( ) ; if ( ! validationResult . isValid ( ) ) { throwAssertionError ( shouldBeValid ( actual . getSystemId ( ) , validationResult . getProblems ( ) ) ) ; } return this ; }
Verifies that actual value is valid against given schema
121,458
public void isInvalid ( ) { ValidationResult validateResult = validate ( ) ; if ( validateResult . isValid ( ) ) { throwAssertionError ( shouldBeInvalid ( actual . getSystemId ( ) ) ) ; } }
Verifies that actual value is not valid against given schema
121,459
protected boolean equalsNamespace ( Node control , Node test ) { String controlNS = control . getNamespaceURI ( ) ; String testNS = test . getNamespaceURI ( ) ; if ( controlNS == null ) { return testNS == null ; } return controlNS . equals ( testNS ) ; }
Determine whether two nodes are defined by the same namespace URI
121,460
protected String getNonNamespacedNodeName ( Node node ) { String name = node . getLocalName ( ) ; if ( name == null ) { return node . getNodeName ( ) ; } return name ; }
Strip any namespace information off a node name
121,461
int read ( ) throws IOException { int nextInt = - 1 ; if ( ! hasSplit ) { split ( ) ; } if ( beforeDoctype != null ) { nextInt = beforeDoctype . read ( ) ; if ( nextInt == - 1 ) { beforeDoctype = null ; } } if ( nextInt == - 1 && decl != null ) { nextInt = decl . read ( ) ; if ( nextInt == - 1 ) { decl = null ; } } if ...
Reads the next character from the declaration .
121,462
private void split ( ) throws IOException { hasSplit = true ; IntegerBuffer before = new IntegerBuffer ( ) ; IntegerBuffer after = new IntegerBuffer ( ) ; int current ; boolean ready = false ; boolean stillNeedToSeeDoctype = true ; while ( ! ready && ( current = original . read ( ) ) != - 1 ) { if ( Character . isWhite...
Reads enough of the original Readable to know where to place the declaration . Fills beforeDecl and afterDecl from the data read ahead . Swallows the original DOCTYPE if there is one .
121,463
public void visited ( Node node ) { switch ( node . getNodeType ( ) ) { case Node . ATTRIBUTE_NODE : visitedAttribute ( getNodeName ( node ) ) ; break ; case Node . ELEMENT_NODE : visitedNode ( node , getNodeName ( node ) ) ; break ; case Node . COMMENT_NODE : visitedNode ( node , XPATH_COMMENT_IDENTIFIER ) ; break ; c...
Call when visiting a node whose xpath location needs tracking
121,464
public void preloadChildList ( List nodeList ) { Iterable < Node > nodes = Linqy . cast ( nodeList ) ; preloadChildren ( nodes ) ; }
Preload the items in a List by visiting each in turn Required for pieces of test XML whose node children can be visited out of sequence by a DifferenceEngine comparison
121,465
private static String getNodeName ( Node n ) { String nodeName = n . getLocalName ( ) ; if ( nodeName == null || nodeName . length ( ) == 0 ) { nodeName = n . getNodeName ( ) ; } return nodeName ; }
extracts the local name of a node .
121,466
private void preloadChildren ( Iterable < Node > nodeList ) { levels . getLast ( ) . trackNodesAsWellAsValues ( true ) ; for ( Node n : nodeList ) { visited ( n ) ; } levels . getLast ( ) . trackNodesAsWellAsValues ( false ) ; }
Preload the nodes by visiting each in turn . Required for pieces of test XML whose node children can be visited out of sequence by a DifferenceEngine comparison
121,467
public void addSchemaSource ( Source s ) { sources . add ( s ) ; validator . setSchemaSources ( sources . toArray ( new Source [ 0 ] ) ) ; }
Adds a source for the schema defintion .
121,468
public List < SAXParseException > getInstanceErrors ( Source instance ) { try { return problemToExceptionList ( validator . validateInstance ( instance ) . getProblems ( ) ) ; } catch ( XMLUnitException e ) { throw new XMLUnitRuntimeException ( e . getMessage ( ) , e . getCause ( ) ) ; } }
Obtain a list of all errors in the given instance .
121,469
public XmlAssert isValidAgainst ( Schema schema ) { isNotNull ( ) ; ValidationAssert . create ( actual , schema ) . isValid ( ) ; return this ; }
Check if actual value is valid against given schema
121,470
public XmlAssert isNotValidAgainst ( Schema schema ) { isNotNull ( ) ; ValidationAssert . create ( actual , schema ) . isInvalid ( ) ; return this ; }
Check if actual value is not valid against given schema
121,471
public XmlAssert isValidAgainst ( Object ... schemaSources ) { isNotNull ( ) ; ValidationAssert . create ( actual , schemaSources ) . isValid ( ) ; return this ; }
Check if actual value is valid against schema provided by given sources
121,472
public XmlAssert isNotValidAgainst ( Object ... schemaSources ) { isNotNull ( ) ; ValidationAssert . create ( actual , schemaSources ) . isInvalid ( ) ; return this ; }
Check if actual value is not valid against schema provided by given sources
121,473
public void navigateToAttribute ( QName attribute ) { path . addLast ( path . getLast ( ) . attributes . get ( attribute ) ) ; }
Moves from the current node to the given attribute .
121,474
public void addAttributes ( Iterable < ? extends QName > attributes ) { Level current = path . getLast ( ) ; for ( QName attribute : attributes ) { current . attributes . put ( attribute , new Level ( ATTR + getName ( attribute ) ) ) ; } }
Adds knowledge about the current node s attributes .
121,475
public void addAttribute ( QName attribute ) { Level current = path . getLast ( ) ; current . attributes . put ( attribute , new Level ( ATTR + getName ( attribute ) ) ) ; }
Adds knowledge about a single attribute of the current node .
121,476
public void setChildren ( Iterable < ? extends NodeInfo > children ) { Level current = path . getLast ( ) ; current . children . clear ( ) ; appendChildren ( children ) ; }
Adds knowledge about the current node s children replacing existing knowledge .
121,477
public void appendChildren ( Iterable < ? extends NodeInfo > children ) { Level current = path . getLast ( ) ; int comments , pis , texts ; comments = pis = texts = 0 ; Map < String , Integer > elements = new HashMap < String , Integer > ( ) ; for ( Level l : current . children ) { String childName = l . expression ; i...
Adds knowledge about the current node s children appending to the knowledge already present .
121,478
public String getParentXPath ( ) { Iterator < Level > levelIterator = path . descendingIterator ( ) ; if ( levelIterator . hasNext ( ) ) { levelIterator . next ( ) ; } return getXPath ( levelIterator ) ; }
Stringifies the XPath of the current node s parent .
121,479
private static int add1OrIncrement ( String name , Map < String , Integer > map ) { Integer old = map . get ( name ) ; int index = old == null ? 1 : old . intValue ( ) + 1 ; map . put ( name , Integer . valueOf ( index ) ) ; return index ; }
Increments the value name maps to or adds 1 as value if name isn t present inside the map .
121,480
public String getDescription ( Comparison difference ) { final ComparisonType type = difference . getType ( ) ; String description = type . getDescription ( ) ; final Detail controlDetails = difference . getControlDetails ( ) ; final Detail testDetails = difference . getTestDetails ( ) ; final String controlTarget = ge...
Return a short String of the Comparison including the XPath and the shorten value of the effected control and test Node .
121,481
protected String getFullFormattedXml ( final Node node , ComparisonType type , boolean formatXml ) { StringBuilder sb = new StringBuilder ( ) ; final Node nodeToConvert ; if ( type == ComparisonType . CHILD_NODELIST_SEQUENCE ) { nodeToConvert = node . getParentNode ( ) ; } else if ( node instanceof Document ) { Documen...
Formats the node using a format suitable for the node type and comparison .
121,482
protected String getFormattedNodeXml ( final Node nodeToConvert , boolean formatXml ) { String formattedNodeXml ; try { final int numberOfBlanksToIndent = formatXml ? 2 : - 1 ; final Transformer transformer = createXmlTransformer ( numberOfBlanksToIndent ) ; final StringWriter buffer = new StringWriter ( ) ; transforme...
Formats a node with the help of an identity XML transformation .
121,483
protected Transformer createXmlTransformer ( int numberOfBlanksToIndent ) throws TransformerConfigurationException { TransformerFactoryConfigurer . Builder b = TransformerFactoryConfigurer . builder ( ) . withExternalStylesheetLoadingDisabled ( ) . withDTDLoadingDisabled ( ) ; if ( numberOfBlanksToIndent >= 0 ) { b = b...
Create a default Transformer to format a XML - Node to a String .
121,484
public void fireComparisonPerformed ( Comparison comparison , ComparisonResult outcome ) { fire ( comparison , outcome , compListeners ) ; if ( outcome == ComparisonResult . EQUAL ) { fire ( comparison , outcome , matchListeners ) ; } else { fire ( comparison , outcome , diffListeners ) ; } }
Propagates the result of a comparision to all registered listeners .
121,485
public void append ( int [ ] i ) { while ( currentSize + i . length > buffer . length ) { grow ( ) ; } System . arraycopy ( i , 0 , buffer , currentSize , i . length ) ; currentSize += i . length ; }
Appends an array of ints .
121,486
public int indexOf ( int [ ] sequence ) { int index = - 1 ; for ( int i = 0 ; index == - 1 && i <= currentSize - sequence . length ; i ++ ) { if ( buffer [ i ] == sequence [ 0 ] ) { boolean matches = true ; for ( int j = 1 ; matches && j < sequence . length ; j ++ ) { if ( buffer [ i + j ] != sequence [ j ] ) { matches...
finds sequence in current buffer .
121,487
public static < E > List < E > asList ( Iterable < E > i ) { if ( i instanceof Collection ) { return new ArrayList < E > ( ( Collection < E > ) i ) ; } ArrayList < E > a = new ArrayList < E > ( ) ; for ( E e : i ) { a . add ( e ) ; } return a ; }
Turns the iterable into a list .
121,488
public static < E > Iterable < E > cast ( final Iterable i ) { return map ( i , new Mapper < Object , E > ( ) { public E apply ( Object o ) { return ( E ) o ; } } ) ; }
Turns an iterable into its type - safe cousin .
121,489
public static < E > Iterable < E > singleton ( final E single ) { return new Iterable < E > ( ) { public Iterator < E > iterator ( ) { return new OnceOnlyIterator < E > ( single ) ; } } ; }
An iterable containing a single element .
121,490
public static < F , T > Iterable < T > map ( final Iterable < F > from , final Mapper < ? super F , T > mapper ) { return new Iterable < T > ( ) { public Iterator < T > iterator ( ) { return new MappingIterator < F , T > ( from . iterator ( ) , mapper ) ; } } ; }
Create a new iterable by applying a mapper function to each element of a given sequence .
121,491
public static < T > Iterable < T > filter ( final Iterable < T > sequence , final Predicate < ? super T > filter ) { return new Iterable < T > ( ) { public Iterator < T > iterator ( ) { return new FilteringIterator < T > ( sequence . iterator ( ) , filter ) ; } } ; }
Exclude all elements from an iterable that don t match a given predicate .
121,492
public static int count ( Iterable seq ) { if ( seq instanceof Collection ) { return ( ( Collection ) seq ) . size ( ) ; } int c = 0 ; Iterator it = seq . iterator ( ) ; while ( it . hasNext ( ) ) { c ++ ; it . next ( ) ; } return c ; }
Count the number of elements in a sequence .
121,493
public static < T > boolean any ( final Iterable < T > sequence , final Predicate < ? super T > predicate ) { for ( T t : sequence ) { if ( predicate . test ( t ) ) { return true ; } } return false ; }
Determines whether a given predicate holds true for at least one element .
121,494
public void characters ( char [ ] data , int start , int length ) { if ( length >= 0 ) { String characterData = new String ( data , start , length ) ; trace ( "characters:" + characterData ) ; if ( currentElement == null ) { warn ( "Can't append text node to null currentElement" ) ; } else { Text textNode = currentDocu...
ContentHandler method .
121,495
private Element createElement ( String namespaceURI , String qName , Attributes attributes ) { Element newElement = currentDocument . createElement ( qName ) ; if ( namespaceURI != null && namespaceURI . length ( ) > 0 ) { newElement . setPrefix ( namespaceURI ) ; } for ( int i = 0 ; attributes != null && i < attribute...
Create a DOM Element for insertion into the current document
121,496
private void appendNode ( Node appendNode ) { if ( currentElement == null ) { currentDocument . appendChild ( appendNode ) ; } else { currentElement . appendChild ( appendNode ) ; } }
Append a node to the current document or the current element in the document
121,497
public static void appendNodeDetail ( StringBuffer buf , NodeDetail nodeDetail ) { appendNodeDetail ( buf , nodeDetail . getNode ( ) , true ) ; buf . append ( " at " ) . append ( nodeDetail . getXpathLocation ( ) ) ; }
Convert a Node into a simple String representation and append to StringBuffer
121,498
public void addOutputProperty ( String name , String value ) { if ( name == null ) { throw new IllegalArgumentException ( "name must not be null" ) ; } if ( value == null ) { throw new IllegalArgumentException ( "value must not be null" ) ; } output . setProperty ( name , value ) ; }
Add a named output property .
121,499
public void addParameter ( String name , Object value ) { if ( name == null ) { throw new IllegalArgumentException ( "name must not be null" ) ; } params . put ( name , value ) ; }
Add a named parameter .