This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JaxbPartialObjectParser | |
{ | |
public static void main(String[] args) throws Exception | |
{ | |
String xmlStr = "<root><student><name>Raju</name></student></root>"; | |
// Assuming Student class is JAXB generated | |
Iterator<Student> it = extractPartialObjects(new StringReader(xmlStr), QName.valueOf("student"), Student.class); | |
while (it.hasNext()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (typeof $ARG === "undefined" || $ARG.length !== 2) | |
print("Usage: jjs -scripting --language=es6 test.js -- arg1 arg2"); | |
else | |
doSomething.apply(null, $ARG); | |
function doSomething(first, second) | |
{ | |
print("first: " + first + ", second: " + second); | |
for (let i = 0; i < 2; i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var comparisonFunctionByOperator = (function () | |
{ | |
var hash = { | |
"<" : (left, right) => left < right, | |
"<=" : (left, right) => left <= right, | |
">" : (left, right) => left > right, | |
">=" : (left, right) => left >= right, | |
"===": (left, right) => left === right, | |
"!==": (left, right) => left !== right, | |
"==" : (left, right) => left == right, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import java.io.IOException; | |
import java.util.function.Predicate; | |
public class AnyThrowableMatchesPredicateInThrowableChain | |
{ | |
public static void main(String[] args) throws IOException | |
{ | |
Throwable throwable = new Throwable("sdsdf"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Path path = Paths.get("D:\\Directory"); | |
WatchService watchService = path.getFileSystem().newWatchService(); | |
path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE); | |
System.out.println("Watching..."); | |
for (;;) | |
{ | |
WatchKey wk = watchService.take(); | |
wk.pollEvents().forEach(we -> System.out.println(we.context() + ", " + we.kind() + ", " + we.count())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class PeekingIterator<T> implements Iterator<T> | |
{ | |
private Iterator<T> iterator; | |
private boolean elementPeeked; | |
private T peekedElement; | |
public PeekingIterator(Iterator<T> iterator) | |
{ | |
this.iterator = iterator; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class AbstractIterator<T> implements Iterator<T> | |
{ | |
private boolean hasMoreData = true, nextComputed; | |
private T data; | |
@Override | |
public final boolean hasNext() | |
{ | |
if (hasMoreData && !nextComputed) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import static java.util.Arrays.asList; | |
import java.util.ArrayDeque; | |
import java.util.Collections; | |
import java.util.Deque; | |
import java.util.Iterator; | |
import java.util.NoSuchElementException; | |
import java.util.Objects; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function minNonNegative(num1, num2) | |
{ | |
if (num1 >= 0 && (num1 <= num2 || num2 < 0)) | |
return num1; | |
if (num2 >= 0) | |
return num2; | |
throw new Error(`Both num1[${num1}] and num2[${num2}] are negative`); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var debug = false; | |
start(); | |
function start() | |
{ | |
if (typeof $ARG === "undefined" || $ARG.length !== 2) | |
{ | |
log("Usage: jjs -scripting proxy_from_pac.js -- <pacfile> <url>"); |