idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
39,000 | 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 |
39,001 | 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 ( nextInt == - 1 && afterDoctype != null ) { nextInt = afterDoctype . read ( ) ; if ( nextInt == - 1 ) { afterDoctype = null ; } } if ( nextInt == - 1 ) { nextInt = original . read ( ) ; } return nextInt ; } | Reads the next character from the declaration . |
39,002 | 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 . isWhitespace ( ( char ) current ) ) { before . append ( current ) ; } else if ( current == '<' ) { int [ ] elementOrDeclOr = readUntilCloseCharIsReached ( ) ; if ( elementOrDeclOr . length > 0 ) { if ( elementOrDeclOr [ 0 ] == '?' ) { before . append ( '<' ) ; before . append ( elementOrDeclOr ) ; } else if ( elementOrDeclOr [ 0 ] != '!' ) { after . append ( '<' ) ; after . append ( elementOrDeclOr ) ; stillNeedToSeeDoctype = false ; ready = true ; } else { IntegerBuffer b = new IntegerBuffer ( elementOrDeclOr . length ) ; b . append ( elementOrDeclOr ) ; if ( b . indexOf ( DOCTYPE_INTS ) == - 1 ) { after . append ( '<' ) ; after . append ( elementOrDeclOr ) ; } else { stillNeedToSeeDoctype = false ; } ready = true ; } } else { after . append ( '<' ) ; stillNeedToSeeDoctype = false ; ready = true ; } } else { after . append ( current ) ; stillNeedToSeeDoctype = false ; ready = true ; } } while ( stillNeedToSeeDoctype && ( current = original . read ( ) ) != - 1 ) { if ( Character . isWhitespace ( ( char ) current ) ) { after . append ( current ) ; } else if ( current == '<' ) { int [ ] elementOrDeclOr = readUntilCloseCharIsReached ( ) ; if ( elementOrDeclOr . length > 0 ) { if ( elementOrDeclOr [ 0 ] == '?' ) { after . append ( '<' ) ; after . append ( elementOrDeclOr ) ; } else if ( elementOrDeclOr [ 0 ] != '!' ) { after . append ( '<' ) ; after . append ( elementOrDeclOr ) ; stillNeedToSeeDoctype = false ; } else { IntegerBuffer b = new IntegerBuffer ( elementOrDeclOr . length ) ; b . append ( elementOrDeclOr ) ; if ( b . indexOf ( DOCTYPE_INTS ) == - 1 ) { after . append ( '<' ) ; after . append ( elementOrDeclOr ) ; } else { stillNeedToSeeDoctype = false ; } } } else { after . append ( '<' ) ; stillNeedToSeeDoctype = false ; } } else { after . append ( current ) ; stillNeedToSeeDoctype = false ; } } beforeDoctype = before . size ( ) > 0 ? new IntBufferReadable ( before ) : null ; afterDoctype = after . size ( ) > 0 ? new IntBufferReadable ( after ) : null ; } | 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 . |
39,003 | 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 ; case Node . PROCESSING_INSTRUCTION_NODE : visitedNode ( node , XPATH_PROCESSING_INSTRUCTION_IDENTIFIER ) ; break ; case Node . CDATA_SECTION_NODE : case Node . TEXT_NODE : visitedNode ( node , XPATH_CHARACTER_NODE_IDENTIFIER ) ; break ; default : break ; } } | Call when visiting a node whose xpath location needs tracking |
39,004 | 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 |
39,005 | 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 . |
39,006 | 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 |
39,007 | public void addSchemaSource ( Source s ) { sources . add ( s ) ; validator . setSchemaSources ( sources . toArray ( new Source [ 0 ] ) ) ; } | Adds a source for the schema defintion . |
39,008 | 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 . |
39,009 | public XmlAssert isValidAgainst ( Schema schema ) { isNotNull ( ) ; ValidationAssert . create ( actual , schema ) . isValid ( ) ; return this ; } | Check if actual value is valid against given schema |
39,010 | public XmlAssert isNotValidAgainst ( Schema schema ) { isNotNull ( ) ; ValidationAssert . create ( actual , schema ) . isInvalid ( ) ; return this ; } | Check if actual value is not valid against given schema |
39,011 | 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 |
39,012 | 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 |
39,013 | public void navigateToAttribute ( QName attribute ) { path . addLast ( path . getLast ( ) . attributes . get ( attribute ) ) ; } | Moves from the current node to the given attribute . |
39,014 | 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 . |
39,015 | 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 . |
39,016 | 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 . |
39,017 | 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 ; if ( childName . startsWith ( COMMENT ) ) { comments ++ ; } else if ( childName . startsWith ( PI ) ) { pis ++ ; } else if ( childName . startsWith ( TEXT ) ) { texts ++ ; } else { childName = childName . substring ( 0 , childName . indexOf ( OPEN ) ) ; add1OrIncrement ( childName , elements ) ; } } for ( NodeInfo child : children ) { Level l ; switch ( child . getType ( ) ) { case Node . COMMENT_NODE : l = new Level ( COMMENT + OPEN + ( ++ comments ) + CLOSE ) ; break ; case Node . PROCESSING_INSTRUCTION_NODE : l = new Level ( PI + OPEN + ( ++ pis ) + CLOSE ) ; break ; case Node . CDATA_SECTION_NODE : case Node . TEXT_NODE : l = new Level ( TEXT + OPEN + ( ++ texts ) + CLOSE ) ; break ; case Node . ELEMENT_NODE : String name = getName ( child . getName ( ) ) ; l = new Level ( name + OPEN + add1OrIncrement ( name , elements ) + CLOSE ) ; break ; default : l = new Level ( EMPTY ) ; break ; } current . children . add ( l ) ; } } | Adds knowledge about the current node s children appending to the knowledge already present . |
39,018 | 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 . |
39,019 | 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 . |
39,020 | 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 = getShortString ( controlDetails . getTarget ( ) , controlDetails . getXPath ( ) , type ) ; final String testTarget = getShortString ( testDetails . getTarget ( ) , testDetails . getXPath ( ) , type ) ; if ( type == ComparisonType . ATTR_NAME_LOOKUP ) { return String . format ( "Expected %s '%s' - comparing %s to %s" , description , controlDetails . getXPath ( ) , controlTarget , testTarget ) ; } return String . format ( "Expected %s '%s' but was '%s' - comparing %s to %s" , description , getValue ( controlDetails . getValue ( ) , type ) , getValue ( testDetails . getValue ( ) , type ) , controlTarget , testTarget ) ; } | Return a short String of the Comparison including the XPath and the shorten value of the effected control and test Node . |
39,021 | 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 ) { Document doc = ( Document ) node ; appendFullDocumentHeader ( sb , doc ) ; return sb . toString ( ) ; } else if ( node instanceof DocumentType ) { Document doc = node . getOwnerDocument ( ) ; appendFullDocumentHeader ( sb , doc ) ; return sb . toString ( ) ; } else if ( node instanceof Attr ) { nodeToConvert = ( ( Attr ) node ) . getOwnerElement ( ) ; } else if ( node instanceof org . w3c . dom . CharacterData ) { nodeToConvert = node . getParentNode ( ) ; } else { nodeToConvert = node ; } sb . append ( getFormattedNodeXml ( nodeToConvert , formatXml ) ) ; return sb . toString ( ) . trim ( ) ; } | Formats the node using a format suitable for the node type and comparison . |
39,022 | 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 ( ) ; transformer . transform ( new DOMSource ( nodeToConvert ) , new StreamResult ( buffer ) ) ; formattedNodeXml = buffer . toString ( ) ; } catch ( final Exception e ) { formattedNodeXml = "ERROR " + e . getMessage ( ) ; } return formattedNodeXml ; } | Formats a node with the help of an identity XML transformation . |
39,023 | protected Transformer createXmlTransformer ( int numberOfBlanksToIndent ) throws TransformerConfigurationException { TransformerFactoryConfigurer . Builder b = TransformerFactoryConfigurer . builder ( ) . withExternalStylesheetLoadingDisabled ( ) . withDTDLoadingDisabled ( ) ; if ( numberOfBlanksToIndent >= 0 ) { b = b . withSafeAttribute ( "indent-number" , numberOfBlanksToIndent ) ; } final TransformerFactory factory = b . build ( ) . configure ( TransformerFactory . newInstance ( ) ) ; final Transformer transformer = factory . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . OMIT_XML_DECLARATION , "yes" ) ; transformer . setOutputProperty ( OutputKeys . METHOD , "xml" ) ; if ( numberOfBlanksToIndent >= 0 ) { try { transformer . setOutputProperty ( "{http://xml.apache.org/xslt}indent-amount" , String . valueOf ( numberOfBlanksToIndent ) ) ; } catch ( final IllegalArgumentException ex ) { } transformer . setOutputProperty ( OutputKeys . INDENT , "yes" ) ; } return transformer ; } | Create a default Transformer to format a XML - Node to a String . |
39,024 | 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 . |
39,025 | 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 . |
39,026 | 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 = false ; } } if ( matches ) { index = i ; } } } return index ; } | finds sequence in current buffer . |
39,027 | 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 . |
39,028 | 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 . |
39,029 | 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 . |
39,030 | 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 . |
39,031 | 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 . |
39,032 | 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 . |
39,033 | 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 . |
39,034 | 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 = currentDocument . createTextNode ( characterData ) ; currentElement . appendChild ( textNode ) ; } } else { warn ( "characters called with negative length" ) ; } } | ContentHandler method . |
39,035 | 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 < attributes . getLength ( ) ; ++ i ) { newElement . setAttribute ( attributes . getQName ( i ) , attributes . getValue ( i ) ) ; } return newElement ; } | Create a DOM Element for insertion into the current document |
39,036 | 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 |
39,037 | 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 |
39,038 | 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 . |
39,039 | 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 . |
39,040 | public void transformTo ( Result r ) { if ( source == null ) { throw new IllegalStateException ( "source must not be null" ) ; } if ( r == null ) { throw new IllegalArgumentException ( "result must not be null" ) ; } try { TransformerFactory fac = factory ; if ( fac == null ) { fac = TransformerFactoryConfigurer . Default . configure ( TransformerFactory . newInstance ( ) ) ; } Transformer t ; if ( styleSheet != null ) { t = fac . newTransformer ( styleSheet ) ; } else { t = fac . newTransformer ( ) ; } if ( uriResolver != null ) { t . setURIResolver ( uriResolver ) ; } if ( errorListener != null ) { t . setErrorListener ( errorListener ) ; } t . setOutputProperties ( output ) ; for ( Map . Entry < String , Object > ent : params . entrySet ( ) ) { t . setParameter ( ent . getKey ( ) , ent . getValue ( ) ) ; } t . transform ( source , r ) ; } catch ( javax . xml . transform . TransformerConfigurationException e ) { throw new ConfigurationException ( e ) ; } catch ( javax . xml . transform . TransformerException e ) { throw new XMLUnitException ( e ) ; } } | Perform the transformation . |
39,041 | public String transformToString ( ) { StringWriter sw = new StringWriter ( ) ; transformTo ( new StreamResult ( sw ) ) ; return sw . toString ( ) ; } | Convenience method that returns the result of the transformation as a String . |
39,042 | public Document transformToDocument ( ) { DOMResult r = new DOMResult ( ) ; transformTo ( r ) ; return ( Document ) r . getNode ( ) ; } | Convenience method that returns the result of the transformation as a Document . |
39,043 | ComparisonState compareNodes ( final Node control , final XPathContext controlContext , final Node test , final XPathContext testContext ) { final Iterable < Node > controlChildren = Linqy . filter ( new IterableNodeList ( control . getChildNodes ( ) ) , getNodeFilter ( ) ) ; final Iterable < Node > testChildren = Linqy . filter ( new IterableNodeList ( test . getChildNodes ( ) ) , getNodeFilter ( ) ) ; return compare ( new Comparison ( ComparisonType . NODE_TYPE , control , getXPath ( controlContext ) , control . getNodeType ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , test . getNodeType ( ) , getParentXPath ( testContext ) ) ) . andThen ( new Comparison ( ComparisonType . NAMESPACE_URI , control , getXPath ( controlContext ) , control . getNamespaceURI ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , test . getNamespaceURI ( ) , getParentXPath ( testContext ) ) ) . andThen ( new Comparison ( ComparisonType . NAMESPACE_PREFIX , control , getXPath ( controlContext ) , control . getPrefix ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , test . getPrefix ( ) , getParentXPath ( testContext ) ) ) . andIfTrueThen ( control . getNodeType ( ) != Node . ATTRIBUTE_NODE , new Comparison ( ComparisonType . CHILD_NODELIST_LENGTH , control , getXPath ( controlContext ) , Linqy . count ( controlChildren ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , Linqy . count ( testChildren ) , getParentXPath ( testContext ) ) ) . andThen ( new DeferredComparison ( ) { public ComparisonState apply ( ) { return nodeTypeSpecificComparison ( control , controlContext , test , testContext ) ; } } ) . andIfTrueThen ( control . getNodeType ( ) != Node . ATTRIBUTE_NODE , compareChildren ( controlContext , controlChildren , testContext , testChildren ) ) ; } | Recursively compares two XML nodes . |
39,044 | private ComparisonState nodeTypeSpecificComparison ( Node control , XPathContext controlContext , Node test , XPathContext testContext ) { switch ( control . getNodeType ( ) ) { case Node . CDATA_SECTION_NODE : case Node . COMMENT_NODE : case Node . TEXT_NODE : if ( test instanceof CharacterData ) { return compareCharacterData ( ( CharacterData ) control , controlContext , ( CharacterData ) test , testContext ) ; } break ; case Node . DOCUMENT_NODE : if ( test instanceof Document ) { return compareDocuments ( ( Document ) control , controlContext , ( Document ) test , testContext ) ; } break ; case Node . ELEMENT_NODE : if ( test instanceof Element ) { return compareElements ( ( Element ) control , controlContext , ( Element ) test , testContext ) ; } break ; case Node . PROCESSING_INSTRUCTION_NODE : if ( test instanceof ProcessingInstruction ) { return compareProcessingInstructions ( ( ProcessingInstruction ) control , controlContext , ( ProcessingInstruction ) test , testContext ) ; } break ; case Node . DOCUMENT_TYPE_NODE : if ( test instanceof DocumentType ) { return compareDocTypes ( ( DocumentType ) control , controlContext , ( DocumentType ) test , testContext ) ; } break ; case Node . ATTRIBUTE_NODE : if ( test instanceof Attr ) { return compareAttributes ( ( Attr ) control , controlContext , ( Attr ) test , testContext ) ; } break ; default : break ; } return new OngoingComparisonState ( ) ; } | Dispatches to the node type specific comparison if one is defined for the given combination of nodes . |
39,045 | private ComparisonState compareCharacterData ( CharacterData control , XPathContext controlContext , CharacterData test , XPathContext testContext ) { return compare ( new Comparison ( ComparisonType . TEXT_VALUE , control , getXPath ( controlContext ) , control . getData ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , test . getData ( ) , getParentXPath ( testContext ) ) ) ; } | Compares textual content . |
39,046 | private ComparisonState compareDocuments ( final Document control , final XPathContext controlContext , final Document test , final XPathContext testContext ) { final DocumentType controlDt = filterNode ( control . getDoctype ( ) ) ; final DocumentType testDt = filterNode ( test . getDoctype ( ) ) ; return compare ( new Comparison ( ComparisonType . HAS_DOCTYPE_DECLARATION , control , getXPath ( controlContext ) , Boolean . valueOf ( controlDt != null ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , Boolean . valueOf ( testDt != null ) , getParentXPath ( testContext ) ) ) . andIfTrueThen ( controlDt != null && testDt != null , new DeferredComparison ( ) { public ComparisonState apply ( ) { return compareNodes ( controlDt , controlContext , testDt , testContext ) ; } } ) . andThen ( compareDeclarations ( control , controlContext , test , testContext ) ) ; } | Compares document node doctype and XML declaration properties |
39,047 | private ComparisonState compareDocTypes ( DocumentType control , XPathContext controlContext , DocumentType test , XPathContext testContext ) { return compare ( new Comparison ( ComparisonType . DOCTYPE_NAME , control , getXPath ( controlContext ) , control . getName ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , test . getName ( ) , getParentXPath ( testContext ) ) ) . andThen ( new Comparison ( ComparisonType . DOCTYPE_PUBLIC_ID , control , getXPath ( controlContext ) , control . getPublicId ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , test . getPublicId ( ) , getParentXPath ( testContext ) ) ) . andThen ( new Comparison ( ComparisonType . DOCTYPE_SYSTEM_ID , control , null , control . getSystemId ( ) , null , test , null , test . getSystemId ( ) , null ) ) ; } | Compares properties of the doctype declaration . |
39,048 | private DeferredComparison compareDeclarations ( final Document control , final XPathContext controlContext , final Document test , final XPathContext testContext ) { return new DeferredComparison ( ) { public ComparisonState apply ( ) { return compare ( new Comparison ( ComparisonType . XML_VERSION , control , getXPath ( controlContext ) , control . getXmlVersion ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , test . getXmlVersion ( ) , getParentXPath ( testContext ) ) ) . andThen ( new Comparison ( ComparisonType . XML_STANDALONE , control , getXPath ( controlContext ) , control . getXmlStandalone ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , test . getXmlStandalone ( ) , getParentXPath ( testContext ) ) ) . andThen ( new Comparison ( ComparisonType . XML_ENCODING , control , getXPath ( controlContext ) , control . getXmlEncoding ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , test . getXmlEncoding ( ) , getParentXPath ( testContext ) ) ) ; } } ; } | Compares properties of XML declaration . |
39,049 | private ComparisonState compareElements ( final Element control , final XPathContext controlContext , final Element test , final XPathContext testContext ) { return compare ( new Comparison ( ComparisonType . ELEMENT_TAG_NAME , control , getXPath ( controlContext ) , Nodes . getQName ( control ) . getLocalPart ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , Nodes . getQName ( test ) . getLocalPart ( ) , getParentXPath ( testContext ) ) ) . andThen ( new DeferredComparison ( ) { public ComparisonState apply ( ) { return compareElementAttributes ( control , controlContext , test , testContext ) ; } } ) ; } | Compares elements node properties in particular the element s name and its attributes . |
39,050 | private ComparisonState compareElementAttributes ( final Element control , final XPathContext controlContext , final Element test , final XPathContext testContext ) { final Attributes controlAttributes = splitAttributes ( control . getAttributes ( ) ) ; controlContext . addAttributes ( Linqy . map ( controlAttributes . remainingAttributes , QNAME_MAPPER ) ) ; final Attributes testAttributes = splitAttributes ( test . getAttributes ( ) ) ; testContext . addAttributes ( Linqy . map ( testAttributes . remainingAttributes , QNAME_MAPPER ) ) ; return compare ( new Comparison ( ComparisonType . ELEMENT_NUM_ATTRIBUTES , control , getXPath ( controlContext ) , controlAttributes . remainingAttributes . size ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , testAttributes . remainingAttributes . size ( ) , getParentXPath ( testContext ) ) ) . andThen ( new DeferredComparison ( ) { public ComparisonState apply ( ) { return compareXsiType ( controlAttributes . type , controlContext , testAttributes . type , testContext ) ; } } ) . andThen ( new Comparison ( ComparisonType . SCHEMA_LOCATION , control , getXPath ( controlContext ) , controlAttributes . schemaLocation != null ? controlAttributes . schemaLocation . getValue ( ) : null , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , testAttributes . schemaLocation != null ? testAttributes . schemaLocation . getValue ( ) : null , getParentXPath ( testContext ) ) ) . andThen ( new Comparison ( ComparisonType . NO_NAMESPACE_SCHEMA_LOCATION , control , getXPath ( controlContext ) , controlAttributes . noNamespaceSchemaLocation != null ? controlAttributes . noNamespaceSchemaLocation . getValue ( ) : null , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , testAttributes . noNamespaceSchemaLocation != null ? testAttributes . noNamespaceSchemaLocation . getValue ( ) : null , getParentXPath ( testContext ) ) ) . andThen ( new NormalAttributeComparer ( control , controlContext , controlAttributes , test , testContext , testAttributes ) ) ; } | Compares element s attributes . |
39,051 | private ComparisonState compareProcessingInstructions ( ProcessingInstruction control , XPathContext controlContext , ProcessingInstruction test , XPathContext testContext ) { return compare ( new Comparison ( ComparisonType . PROCESSING_INSTRUCTION_TARGET , control , getXPath ( controlContext ) , control . getTarget ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , test . getTarget ( ) , getParentXPath ( testContext ) ) ) . andThen ( new Comparison ( ComparisonType . PROCESSING_INSTRUCTION_DATA , control , getXPath ( controlContext ) , control . getData ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , test . getData ( ) , getParentXPath ( testContext ) ) ) ; } | Compares properties of a processing instruction . |
39,052 | private ComparisonState compareNodeLists ( Iterable < Node > controlSeq , final XPathContext controlContext , Iterable < Node > testSeq , final XPathContext testContext ) { ComparisonState chain = new OngoingComparisonState ( ) ; Iterable < Map . Entry < Node , Node > > matches = getNodeMatcher ( ) . match ( controlSeq , testSeq ) ; List < Node > controlList = Linqy . asList ( controlSeq ) ; List < Node > testList = Linqy . asList ( testSeq ) ; Set < Node > seen = new HashSet < Node > ( ) ; for ( Map . Entry < Node , Node > pair : matches ) { final Node control = pair . getKey ( ) ; seen . add ( control ) ; final Node test = pair . getValue ( ) ; seen . add ( test ) ; int controlIndex = controlList . indexOf ( control ) ; int testIndex = testList . indexOf ( test ) ; controlContext . navigateToChild ( controlIndex ) ; testContext . navigateToChild ( testIndex ) ; try { chain = chain . andThen ( new Comparison ( ComparisonType . CHILD_NODELIST_SEQUENCE , control , getXPath ( controlContext ) , Integer . valueOf ( controlIndex ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , Integer . valueOf ( testIndex ) , getParentXPath ( testContext ) ) ) . andThen ( new DeferredComparison ( ) { public ComparisonState apply ( ) { return compareNodes ( control , controlContext , test , testContext ) ; } } ) ; } finally { testContext . navigateToParent ( ) ; controlContext . navigateToParent ( ) ; } } return chain . andThen ( new UnmatchedControlNodes ( controlList , controlContext , seen , testContext ) ) . andThen ( new UnmatchedTestNodes ( testList , testContext , seen , controlContext ) ) ; } | Matches nodes of two node lists and invokes compareNode on each pair . |
39,053 | private ComparisonState compareAttributes ( Attr control , XPathContext controlContext , Attr test , XPathContext testContext ) { return compareAttributeExplicitness ( control , controlContext , test , testContext ) . apply ( ) . andThen ( new Comparison ( ComparisonType . ATTR_VALUE , control , getXPath ( controlContext ) , control . getValue ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , test . getValue ( ) , getParentXPath ( testContext ) ) ) ; } | Compares properties of an attribute . |
39,054 | private DeferredComparison compareAttributeExplicitness ( final Attr control , final XPathContext controlContext , final Attr test , final XPathContext testContext ) { return new DeferredComparison ( ) { public ComparisonState apply ( ) { return compare ( new Comparison ( ComparisonType . ATTR_VALUE_EXPLICITLY_SPECIFIED , control , getXPath ( controlContext ) , control . getSpecified ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , test . getSpecified ( ) , getParentXPath ( testContext ) ) ) ; } } ; } | Compares whether two attributes are specified explicitly . |
39,055 | private Attributes splitAttributes ( final NamedNodeMap map ) { Attr sLoc = ( Attr ) map . getNamedItemNS ( XMLConstants . W3C_XML_SCHEMA_INSTANCE_NS_URI , "schemaLocation" ) ; Attr nNsLoc = ( Attr ) map . getNamedItemNS ( XMLConstants . W3C_XML_SCHEMA_INSTANCE_NS_URI , "noNamespaceSchemaLocation" ) ; Attr type = ( Attr ) map . getNamedItemNS ( XMLConstants . W3C_XML_SCHEMA_INSTANCE_NS_URI , "type" ) ; List < Attr > rest = new LinkedList < Attr > ( ) ; final int len = map . getLength ( ) ; for ( int i = 0 ; i < len ; i ++ ) { Attr a = ( Attr ) map . item ( i ) ; if ( ! XMLConstants . XMLNS_ATTRIBUTE_NS_URI . equals ( a . getNamespaceURI ( ) ) && a != sLoc && a != nNsLoc && a != type && getAttributeFilter ( ) . test ( a ) ) { rest . add ( a ) ; } } return new Attributes ( sLoc , nNsLoc , type , rest ) ; } | Separates XML namespace related attributes from normal attributes . xb |
39,056 | private static Attr findMatchingAttr ( final List < Attr > attrs , final Attr attrToMatch ) { final boolean hasNs = attrToMatch . getNamespaceURI ( ) != null ; final String nsToMatch = attrToMatch . getNamespaceURI ( ) ; final String nameToMatch = hasNs ? attrToMatch . getLocalName ( ) : attrToMatch . getName ( ) ; for ( Attr a : attrs ) { if ( ( ( ! hasNs && a . getNamespaceURI ( ) == null ) || ( hasNs && nsToMatch . equals ( a . getNamespaceURI ( ) ) ) ) && ( ( hasNs && nameToMatch . equals ( a . getLocalName ( ) ) ) || ( ! hasNs && nameToMatch . equals ( a . getName ( ) ) ) ) ) { return a ; } } return null ; } | Find the attribute with the same namespace and local name as a given attribute in a list of attributes . |
39,057 | public DiffBuilder withComparisonListeners ( final ComparisonListener ... comparisonListeners ) { this . comparisonListeners . addAll ( Arrays . asList ( comparisonListeners ) ) ; return this ; } | Registers listeners that are notified of each comparison . |
39,058 | public int differenceFound ( Difference difference ) { final int returnValue = super . differenceFound ( difference ) ; switch ( returnValue ) { case RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL : return returnValue ; case RETURN_ACCEPT_DIFFERENCE : break ; case RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR : difference . setRecoverable ( true ) ; break ; case RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT : difference . setRecoverable ( false ) ; break ; default : throw new IllegalArgumentException ( returnValue + " is not a defined " + " DifferenceListener" + ".RETURN_... value" ) ; } allDifferences . add ( difference ) ; return returnValue ; } | DifferenceListener implementation . Add the difference to the list of all differences |
39,059 | protected final boolean areAttributesComparable ( Element control , Element test ) { String controlValue , testValue ; Attr [ ] qualifyingAttributes ; NamedNodeMap namedNodeMap = control . getAttributes ( ) ; if ( matchesAllAttributes ( qualifyingAttrNames ) ) { qualifyingAttributes = new Attr [ namedNodeMap . getLength ( ) ] ; for ( int n = 0 ; n < qualifyingAttributes . length ; ++ n ) { qualifyingAttributes [ n ] = ( Attr ) namedNodeMap . item ( n ) ; } } else { qualifyingAttributes = new Attr [ qualifyingAttrNames . length ] ; for ( int n = 0 ; n < qualifyingAttrNames . length ; ++ n ) { qualifyingAttributes [ n ] = ( Attr ) namedNodeMap . getNamedItem ( qualifyingAttrNames [ n ] ) ; } } String nsURI , name ; for ( int i = 0 ; i < qualifyingAttributes . length ; ++ i ) { if ( qualifyingAttributes [ i ] != null ) { nsURI = qualifyingAttributes [ i ] . getNamespaceURI ( ) ; controlValue = qualifyingAttributes [ i ] . getNodeValue ( ) ; name = qualifyingAttributes [ i ] . getName ( ) ; } else { nsURI = controlValue = "" ; name = qualifyingAttrNames [ i ] ; } if ( nsURI == null || nsURI . length ( ) == 0 ) { testValue = test . getAttribute ( name ) ; } else { testValue = test . getAttributeNS ( nsURI , qualifyingAttributes [ i ] . getLocalName ( ) ) ; } if ( controlValue == null ) { if ( testValue != null ) { return false ; } } else { if ( ! controlValue . equals ( testValue ) ) { return false ; } } } return true ; } | Determine whether the qualifying attributes are present in both elements and if so whether their values are the same |
39,060 | public static InputSource toInputSource ( Source s , TransformerFactory fac ) { try { InputSource is = SAXSource . sourceToInputSource ( s ) ; if ( is == null ) { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; StreamResult r = new StreamResult ( bos ) ; if ( fac == null ) { fac = TransformerFactoryConfigurer . NoExternalAccess . configure ( TransformerFactory . newInstance ( ) ) ; } Transformer t = fac . newTransformer ( ) ; t . transform ( s , r ) ; s = new StreamSource ( new ByteArrayInputStream ( bos . toByteArray ( ) ) ) ; is = SAXSource . sourceToInputSource ( s ) ; } return is ; } catch ( javax . xml . transform . TransformerConfigurationException e ) { throw new ConfigurationException ( e ) ; } catch ( javax . xml . transform . TransformerException e ) { throw new XMLUnitException ( e ) ; } } | Creates a SAX InputSource from a TraX Source . |
39,061 | public static NamespaceContext toNamespaceContext ( Map < String , String > prefix2URI ) { final Map < String , String > copy = new LinkedHashMap < String , String > ( prefix2URI ) ; return new NamespaceContext ( ) { public String getNamespaceURI ( String prefix ) { if ( prefix == null ) { throw new IllegalArgumentException ( "prefix must not be null" ) ; } if ( XMLConstants . XML_NS_PREFIX . equals ( prefix ) ) { return XMLConstants . XML_NS_URI ; } if ( XMLConstants . XMLNS_ATTRIBUTE . equals ( prefix ) ) { return XMLConstants . XMLNS_ATTRIBUTE_NS_URI ; } String uri = copy . get ( prefix ) ; return uri != null ? uri : XMLConstants . NULL_NS_URI ; } public String getPrefix ( String uri ) { Iterator i = getPrefixes ( uri ) ; return i . hasNext ( ) ? ( String ) i . next ( ) : null ; } public Iterator getPrefixes ( String uri ) { if ( uri == null ) { throw new IllegalArgumentException ( "uri must not be null" ) ; } Collection < String > c = new LinkedHashSet < String > ( ) ; boolean done = false ; if ( XMLConstants . XML_NS_URI . equals ( uri ) ) { c . add ( XMLConstants . XML_NS_PREFIX ) ; done = true ; } if ( XMLConstants . XMLNS_ATTRIBUTE_NS_URI . equals ( uri ) ) { c . add ( XMLConstants . XMLNS_ATTRIBUTE ) ; done = true ; } if ( ! done ) { for ( Map . Entry < String , String > entry : copy . entrySet ( ) ) { if ( uri . equals ( entry . getValue ( ) ) ) { c . add ( entry . getKey ( ) ) ; } } } return c . iterator ( ) ; } } ; } | Creates a JAXP NamespaceContext from a Map prefix = > ; Namespace URI . |
39,062 | protected void compareDocument ( Document control , Document test , DifferenceListener listener , ElementQualifier elementQualifier ) throws DifferenceFoundException { DocumentType controlDoctype = control . getDoctype ( ) ; DocumentType testDoctype = test . getDoctype ( ) ; compare ( getNullOrNotNull ( controlDoctype ) , getNullOrNotNull ( testDoctype ) , controlDoctype , testDoctype , listener , HAS_DOCTYPE_DECLARATION ) ; if ( controlDoctype != null && testDoctype != null ) { compareNode ( controlDoctype , testDoctype , listener , elementQualifier ) ; } } | Compare two Documents for doctype and then element differences |
39,063 | private Boolean hasChildNodes ( Node n ) { boolean flag = n . hasChildNodes ( ) ; if ( flag && XMLUnit . getIgnoreComments ( ) ) { List nl = nodeList2List ( n . getChildNodes ( ) ) ; flag = ! nl . isEmpty ( ) ; } return flag ? Boolean . TRUE : Boolean . FALSE ; } | Tests whether a Node has children taking ignoreComments setting into account . |
39,064 | static List < Node > nodeList2List ( NodeList nl ) { int len = nl . getLength ( ) ; List < Node > l = new ArrayList < Node > ( len ) ; for ( int i = 0 ; i < len ; i ++ ) { Node n = nl . item ( i ) ; if ( ! XMLUnit . getIgnoreComments ( ) || ! ( n instanceof Comment ) ) { l . add ( n ) ; } } return l ; } | Returns the NodeList s Nodes as List taking ignoreComments into account . |
39,065 | protected void compareElement ( Element control , Element test , DifferenceListener listener ) throws DifferenceFoundException { compare ( getUnNamespacedNodeName ( control ) , getUnNamespacedNodeName ( test ) , control , test , listener , ELEMENT_TAG_NAME ) ; NamedNodeMap controlAttr = control . getAttributes ( ) ; Integer controlNonXmlnsAttrLength = getNonSpecialAttrLength ( controlAttr ) ; NamedNodeMap testAttr = test . getAttributes ( ) ; Integer testNonXmlnsAttrLength = getNonSpecialAttrLength ( testAttr ) ; compare ( controlNonXmlnsAttrLength , testNonXmlnsAttrLength , control , test , listener , ELEMENT_NUM_ATTRIBUTES ) ; compareElementAttributes ( control , test , controlAttr , testAttr , listener ) ; } | Compare 2 elements and their attributes |
39,066 | protected void compareCDataSection ( CDATASection control , CDATASection test , DifferenceListener listener ) throws DifferenceFoundException { compareText ( control , test , listener ) ; } | Compare two CDATA sections - unused kept for backwards compatibility |
39,067 | protected void compareComment ( Comment control , Comment test , DifferenceListener listener ) throws DifferenceFoundException { if ( ! XMLUnit . getIgnoreComments ( ) ) { compareCharacterData ( control , test , listener , COMMENT_VALUE ) ; } } | Compare two comments |
39,068 | protected void compareDocumentType ( DocumentType control , DocumentType test , DifferenceListener listener ) throws DifferenceFoundException { compare ( control . getName ( ) , test . getName ( ) , control , test , listener , DOCTYPE_NAME ) ; compare ( control . getPublicId ( ) , test . getPublicId ( ) , control , test , listener , DOCTYPE_PUBLIC_ID ) ; compare ( control . getSystemId ( ) , test . getSystemId ( ) , control , test , listener , DOCTYPE_SYSTEM_ID ) ; } | Compare two DocumentType nodes |
39,069 | protected void compareProcessingInstruction ( ProcessingInstruction control , ProcessingInstruction test , DifferenceListener listener ) throws DifferenceFoundException { compare ( control . getTarget ( ) , test . getTarget ( ) , control , test , listener , PROCESSING_INSTRUCTION_TARGET ) ; compare ( control . getData ( ) , test . getData ( ) , control , test , listener , PROCESSING_INSTRUCTION_DATA ) ; } | Compare two processing instructions |
39,070 | protected void compareText ( Text control , Text test , DifferenceListener listener ) throws DifferenceFoundException { compareText ( ( CharacterData ) control , ( CharacterData ) test , listener ) ; } | Compare text - unused kept for backwards compatibility |
39,071 | private void compareCharacterData ( CharacterData control , CharacterData test , DifferenceListener listener , Difference difference ) throws DifferenceFoundException { compare ( control . getData ( ) , test . getData ( ) , control , test , listener , difference ) ; } | Character comparison method used by comments text and CDATA sections |
39,072 | private boolean unequal ( Object expected , Object actual ) { return expected == null ? actual != null : unequalNotNull ( expected , actual ) ; } | Test two possibly null values for inequality |
39,073 | private boolean unequalNotNull ( Object expected , Object actual ) { if ( ( XMLUnit . getIgnoreWhitespace ( ) || XMLUnit . getNormalizeWhitespace ( ) ) && expected instanceof String && actual instanceof String ) { String expectedString = ( ( String ) expected ) . trim ( ) ; String actualString = ( ( String ) actual ) . trim ( ) ; if ( XMLUnit . getNormalizeWhitespace ( ) ) { expectedString = normalizeWhitespace ( expectedString ) ; actualString = normalizeWhitespace ( actualString ) ; } return ! expectedString . equals ( actualString ) ; } return ! ( expected . equals ( actual ) ) ; } | Test two non - null values for inequality |
39,074 | final static String normalizeWhitespace ( String orig ) { StringBuilder sb = new StringBuilder ( ) ; boolean lastCharWasWhitespace = false ; boolean changed = false ; char [ ] characters = orig . toCharArray ( ) ; for ( int i = 0 ; i < characters . length ; i ++ ) { if ( Character . isWhitespace ( characters [ i ] ) ) { if ( lastCharWasWhitespace ) { changed = true ; } else { sb . append ( ' ' ) ; changed |= characters [ i ] != ' ' ; lastCharWasWhitespace = true ; } } else { sb . append ( characters [ i ] ) ; lastCharWasWhitespace = false ; } } return changed ? sb . toString ( ) : orig ; } | Replace all whitespace characters with SPACE and collapse consecutive whitespace chars to a single SPACE . |
39,075 | public static ElementSelector not ( final ElementSelector es ) { if ( es == null ) { throw new IllegalArgumentException ( "es must not be null" ) ; } return new ElementSelector ( ) { public boolean canBeCompared ( Element controlElement , Element testElement ) { return ! es . canBeCompared ( controlElement , testElement ) ; } } ; } | Negates another ElementSelector . |
39,076 | public static ElementSelector or ( final ElementSelector ... selectors ) { if ( selectors == null ) { throw new IllegalArgumentException ( SELECTORS_MUST_NOT_BE_NULL ) ; } final Collection < ElementSelector > s = Arrays . asList ( selectors ) ; if ( any ( s , new IsNullPredicate ( ) ) ) { throw new IllegalArgumentException ( "selectors must not contain null values" ) ; } return new ElementSelector ( ) { public boolean canBeCompared ( Element controlElement , Element testElement ) { return any ( s , new CanBeComparedPredicate ( controlElement , testElement ) ) ; } } ; } | Accepts two elements if at least one of the given ElementSelectors does . |
39,077 | public static ElementSelector xor ( final ElementSelector es1 , final ElementSelector es2 ) { if ( es1 == null || es2 == null ) { throw new IllegalArgumentException ( SELECTORS_MUST_NOT_BE_NULL ) ; } return new ElementSelector ( ) { public boolean canBeCompared ( Element controlElement , Element testElement ) { return es1 . canBeCompared ( controlElement , testElement ) ^ es2 . canBeCompared ( controlElement , testElement ) ; } } ; } | Accepts two elements if exactly on of the given ElementSelectors does . |
39,078 | public static ElementSelector conditionalSelector ( final Predicate < ? super Element > predicate , final ElementSelector es ) { if ( predicate == null ) { throw new IllegalArgumentException ( "predicate must not be null" ) ; } if ( es == null ) { throw new IllegalArgumentException ( "es must not be null" ) ; } return new ElementSelector ( ) { public boolean canBeCompared ( Element controlElement , Element testElement ) { return predicate . test ( controlElement ) && es . canBeCompared ( controlElement , testElement ) ; } } ; } | Applies the wrapped ElementSelector s logic if and only if the control element matches the given predicate . |
39,079 | public void setSchemaSources ( Source ... s ) { if ( s != null ) { sourceLocations = Arrays . copyOf ( s , s . length ) ; } else { sourceLocations = null ; } } | Where to find the schema . |
39,080 | public static Validator forLanguage ( String language ) { if ( ! Languages . XML_DTD_NS_URI . equals ( language ) ) { return new JAXPValidator ( language ) ; } return new ParsingValidator ( Languages . XML_DTD_NS_URI ) ; } | Factory that obtains a Validator instance based on the schema language . |
39,081 | public void saveTo ( File propertyFile ) throws IOException { Properties props = new Properties ( ) ; props . put ( "username" , username ) ; props . put ( "key" , accessKey ) ; FileOutputStream out = new FileOutputStream ( propertyFile ) ; try { props . store ( out , "Sauce OnDemand access credential" ) ; } finally { out . close ( ) ; } } | Persists this credential to the disk . |
39,082 | public static GsonBuilder registerAll ( GsonBuilder builder ) { if ( builder == null ) { throw new NullPointerException ( "builder cannot be null" ) ; } registerDateMidnight ( builder ) ; registerDateTime ( builder ) ; registerDuration ( builder ) ; registerLocalDate ( builder ) ; registerLocalDateTime ( builder ) ; registerLocalTime ( builder ) ; registerInterval ( builder ) ; registerPeriod ( builder ) ; registerInstant ( builder ) ; registerDateTimeZone ( builder ) ; return builder ; } | Registers all the Joda Time converters . |
39,083 | public void stop ( Future < Void > stopFuture ) throws Exception { if ( realVerticle != null ) { realVerticle . stop ( stopFuture ) ; realVerticle = null ; } } | Vert . x calls the stop method when the verticle is undeployed . Put any cleanup code for your verticle in here |
39,084 | public void start ( ) throws Exception { if ( dependency == null ) { throw new IllegalStateException ( "Dependency was not injected!" ) ; } vertx . eventBus ( ) . consumer ( EB_ADDRESS , this ) ; super . start ( ) ; } | If your verticle does a simple synchronous start - up then override this method and put your start - up code in there . |
39,085 | public void handle ( Message < Void > msg ) { msg . reply ( dependency . getClass ( ) . getName ( ) ) ; } | Something has happened so handle it . |
39,086 | public InputStream getAsStream ( final Archive < ? > archive ) { final Archive < ? > testable = findTestableArchive ( archive ) ; final Collection < Node > values = collectPersistenceXml ( testable ) ; if ( values . size ( ) == 1 ) { return values . iterator ( ) . next ( ) . getAsset ( ) . openStream ( ) ; } return null ; } | Returns open stream of persistence . xml found in the archive but only if single file have been found . |
39,087 | public Class < ? > box ( Class < ? > primitive ) { if ( ! primitive . isPrimitive ( ) ) { return primitive ; } if ( int . class . equals ( primitive ) ) { return Integer . class ; } else if ( long . class . equals ( primitive ) ) { return Long . class ; } else if ( float . class . equals ( primitive ) ) { return Float . class ; } else if ( double . class . equals ( primitive ) ) { return Double . class ; } else if ( short . class . equals ( primitive ) ) { return Short . class ; } else if ( boolean . class . equals ( primitive ) ) { return Boolean . class ; } else if ( char . class . equals ( primitive ) ) { return Character . class ; } else if ( byte . class . equals ( primitive ) ) { return Byte . class ; } throw new IllegalArgumentException ( "Unknown primitive type " + primitive ) ; } | A helper boxing method . Returns boxed class for a primitive class |
39,088 | private String [ ] requiredLibraries ( ) { List < String > libraries = new ArrayList < String > ( Arrays . asList ( "org.dbunit" , "org.apache.commons" , "org.apache.log4j" , "org.slf4j" , "org.yaml" , "org.codehaus.jackson" ) ) ; if ( ! dbunitConfigurationInstance . get ( ) . isExcludePoi ( ) ) { libraries . add ( "org.apache.poi" ) ; } return libraries . toArray ( new String [ libraries . size ( ) ] ) ; } | Private helper methods |
39,089 | public Collection < T > getDescriptors ( TestClass testClass ) { final List < T > descriptors = new ArrayList < T > ( ) ; for ( Method testMethod : testClass . getMethods ( resourceAnnotation ) ) { descriptors . addAll ( getDescriptorsDefinedFor ( testMethod ) ) ; } descriptors . addAll ( obtainClassLevelDescriptor ( testClass . getAnnotation ( resourceAnnotation ) ) ) ; return descriptors ; } | Returns all resources defined for this test class including those defined on the test method level . |
39,090 | protected String determineLocation ( String location ) { if ( existsInDefaultLocation ( location ) ) { return defaultFolder ( ) + location ; } if ( ! existsInGivenLocation ( location ) ) { throw new InvalidResourceLocation ( "Unable to locate " + location + ". " + "File does not exist also in default location " + defaultLocation ( ) ) ; } return location ; } | Checks if file exists in the default location . If that s not the case file is looked up starting from the root . |
39,091 | public static List < String > extractNonExistingColumns ( final Collection < String > expectedColumns , final Collection < String > actualColumns ) { final List < String > columnsNotSpecifiedInExpectedDataSet = new ArrayList < String > ( ) ; for ( String column : expectedColumns ) { if ( ! actualColumns . contains ( column . toLowerCase ( ) ) ) { columnsNotSpecifiedInExpectedDataSet . add ( column . toLowerCase ( ) ) ; } } return columnsNotSpecifiedInExpectedDataSet ; } | Provides list of columns defined in expectedColumns but not listed in actualColumns . |
39,092 | public T fetchUsingFirst ( Method testMethod ) { T usedAnnotation = getAnnotationOnClassLevel ( ) ; if ( isDefinedOn ( testMethod ) ) { usedAnnotation = fetchFrom ( testMethod ) ; } return usedAnnotation ; } | Fetches annotation for a given test class . If annotation is defined on method level it s returned as a result . Otherwise class level annotation is returned if present . |
39,093 | public Factory < ? > getValueFactory ( Parameter parameter ) { if ( type . equals ( parameter . getRawType ( ) ) && parameter . isAnnotationPresent ( Auth . class ) ) { return this ; } return null ; } | org . glassfish . jersey . server . spi . internal . ValueFactoryProvider |
39,094 | public void bind ( DynamicConfiguration config ) { Injections . addBinding ( Injections . newFactoryBinder ( this ) . to ( type ) . in ( Singleton . class ) , config ) ; Injections . addBinding ( Injections . newBinder ( this ) . to ( ValueFactoryProvider . class ) , config ) ; } | org . glassfish . hk2 . utilities . Binder |
39,095 | public void setVehicleManager ( VehicleManager vehicle ) { mVehicle = vehicle ; mPreferenceListener = watchPreferences ( getPreferences ( ) ) ; mPreferenceListener . readStoredPreferences ( ) ; } | Give the instance a reference to an active VehicleManager . |
39,096 | public static Class < ? extends VehicleInterface > findClass ( String interfaceName ) throws VehicleInterfaceException { Class < ? extends VehicleInterface > interfaceType ; try { interfaceType = Class . forName ( interfaceName ) . asSubclass ( VehicleInterface . class ) ; } catch ( ClassNotFoundException e ) { throw new VehicleInterfaceException ( "Couldn't find vehicle interface type " + interfaceName , e ) ; } return interfaceType ; } | Obtain the Class object for a given VehicleInterface class name . |
39,097 | public static boolean validatePath ( String path ) { if ( path == null ) { Log . w ( TAG , "Uploading path not set" ) ; return false ; } try { uriFromString ( path ) ; return true ; } catch ( DataSinkException e ) { return false ; } } | Returns true if the path is not null and if it is a valid URI . |
39,098 | public void waitUntilBound ( ) throws VehicleServiceException { mRemoteBoundLock . lock ( ) ; Log . i ( TAG , "Waiting for the VehicleService to bind to " + this ) ; while ( mRemoteService == null ) { try { if ( ! mRemoteBoundCondition . await ( 3 , TimeUnit . SECONDS ) ) { throw new VehicleServiceException ( "Not bound to remote service after 3 seconds" ) ; } } catch ( InterruptedException e ) { } } Log . i ( TAG , mRemoteService + " is now bound" ) ; mRemoteBoundLock . unlock ( ) ; } | Block until the VehicleManager is alive and can return measurements . |
39,099 | public Measurement get ( Class < ? extends Measurement > measurementType ) throws UnrecognizedMeasurementTypeException , NoValueException { return BaseMeasurement . getMeasurementFromMessage ( measurementType , get ( BaseMeasurement . getKeyForMeasurement ( measurementType ) ) . asSimpleMessage ( ) ) ; } | Retrieve the most current value of a measurement . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.