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 ... | 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 . 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 . |
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 ; c... | 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 ; i... | 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 = ge... | 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 ) { Documen... | 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 ( ) ; transforme... | 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... | 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... | 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 = currentDocu... | 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 < attribute... | 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 . Defa... | 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 = Linq... | 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 compareChara... | 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 ... | 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 ( ne... | 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 , get... | 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 , getXPat... | 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 ( ) , ge... | 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 .... | 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 (... | 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... | 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 ( controlConte... | 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_SPECIFIE... | 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 = ( Att... | 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... | 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 . setReco... | 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 . getLengt... | 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 = TransformerFactoryConfigur... | 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 IllegalArgumentExce... | 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 ... | 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 ( ) ; In... | 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 , tes... | 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 ... | 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 ) .... | 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 ] ) ) ... | 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 , testElemen... | 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 IllegalArgumentExcep... | 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 ... | 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 ... | 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 { ... | 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 ) ; re... | 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 nul... | 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 ... | 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 ( "or... | 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 ( t... | 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 " + defau... | 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 ( co... | 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 n... | 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 boun... | 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.