repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/servicefactory/ServiceFactory.java
ServiceFactory.getInstance
public synchronized static ServiceFactory getInstance(Class<?> aClass, String configurationPath) { if(configurationPath == null) { configurationPath = ""; } if (instances.get(configurationPath) == null) { instances.put(configurationPath, createServiceFactory(aClass,configurationPath)); } return (ServiceFactory)instances.get(configurationPath); }
java
public synchronized static ServiceFactory getInstance(Class<?> aClass, String configurationPath) { if(configurationPath == null) { configurationPath = ""; } if (instances.get(configurationPath) == null) { instances.put(configurationPath, createServiceFactory(aClass,configurationPath)); } return (ServiceFactory)instances.get(configurationPath); }
[ "public", "synchronized", "static", "ServiceFactory", "getInstance", "(", "Class", "<", "?", ">", "aClass", ",", "String", "configurationPath", ")", "{", "if", "(", "configurationPath", "==", "null", ")", "{", "configurationPath", "=", "\"\"", ";", "}", "if", ...
Singleton factory method @param aClass the class implements @param configurationPath the path to the configuration details @return a single instance of the ServiceFactory object for the JVM
[ "Singleton", "factory", "method" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/servicefactory/ServiceFactory.java#L107-L120
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/decorator/MappedTextFormatDecorator.java
MappedTextFormatDecorator.getText
public String getText() { //convert textable to map of text Object key = null; try { //read bindTemplate String bindTemplate = getTemplate(); Map<Object,String> textMap = new Hashtable<Object,String>(); for(Map.Entry<String, Textable> entry: map.entrySet()) { key = entry.getKey(); try { //convert to text textMap.put(key,(entry.getValue()).getText()); } catch (Exception e) { throw new SystemException("Unable to build text for key:"+key+" error:"+e.getMessage(),e); } } Debugger.println(this, "bindTemplate="+bindTemplate); String formattedOutput = Text.format(bindTemplate, textMap); Debugger.println(this, "formattedOutput="+formattedOutput); return formattedOutput; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new SetupException(e.getMessage(),e); } }
java
public String getText() { //convert textable to map of text Object key = null; try { //read bindTemplate String bindTemplate = getTemplate(); Map<Object,String> textMap = new Hashtable<Object,String>(); for(Map.Entry<String, Textable> entry: map.entrySet()) { key = entry.getKey(); try { //convert to text textMap.put(key,(entry.getValue()).getText()); } catch (Exception e) { throw new SystemException("Unable to build text for key:"+key+" error:"+e.getMessage(),e); } } Debugger.println(this, "bindTemplate="+bindTemplate); String formattedOutput = Text.format(bindTemplate, textMap); Debugger.println(this, "formattedOutput="+formattedOutput); return formattedOutput; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new SetupException(e.getMessage(),e); } }
[ "public", "String", "getText", "(", ")", "{", "//convert textable to map of text\r", "Object", "key", "=", "null", ";", "try", "{", "//read bindTemplate\r", "String", "bindTemplate", "=", "getTemplate", "(", ")", ";", "Map", "<", "Object", ",", "String", ">", ...
Convert get text output from each Textable in map. Return the format output using Text.format. Note the bind template is retrieved from the URL provided in templateUrl. @see nyla.solutions.core.data.Textable#getText()
[ "Convert", "get", "text", "output", "from", "each", "Textable", "in", "map", ".", "Return", "the", "format", "output", "using", "Text", ".", "format", "." ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/decorator/MappedTextFormatDecorator.java#L79-L118
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/workthread/ExecutorBoss.java
ExecutorBoss.startWorking
public <T> Collection<T> startWorking(Callable<T>[] callables) { List<Future<T>> list = new ArrayList<Future<T>>(); for (int i = 0; i < callables.length; i++) { list.add(executor.submit(callables[i])); } ArrayList<T> resultList = new ArrayList<T>(callables.length); // Now retrieve the result T output; for (Future<T> future : list) { try { output = future.get(); if(output != null) resultList.add(output); } catch (InterruptedException e) { throw new SystemException(e); } catch (ExecutionException e) { throw new SystemException(e); } } return resultList; }
java
public <T> Collection<T> startWorking(Callable<T>[] callables) { List<Future<T>> list = new ArrayList<Future<T>>(); for (int i = 0; i < callables.length; i++) { list.add(executor.submit(callables[i])); } ArrayList<T> resultList = new ArrayList<T>(callables.length); // Now retrieve the result T output; for (Future<T> future : list) { try { output = future.get(); if(output != null) resultList.add(output); } catch (InterruptedException e) { throw new SystemException(e); } catch (ExecutionException e) { throw new SystemException(e); } } return resultList; }
[ "public", "<", "T", ">", "Collection", "<", "T", ">", "startWorking", "(", "Callable", "<", "T", ">", "[", "]", "callables", ")", "{", "List", "<", "Future", "<", "T", ">>", "list", "=", "new", "ArrayList", "<", "Future", "<", "T", ">", ">", "(",...
Start the array of the callables @param <T> the type class @param callables of callables @return the collection of returned object from the callables
[ "Start", "the", "array", "of", "the", "callables" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/workthread/ExecutorBoss.java#L110-L144
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/workthread/ExecutorBoss.java
ExecutorBoss.startWorking
public Collection<Future<?>> startWorking(WorkQueue queue, boolean background) { ArrayList<Future<?>> futures = new ArrayList<Future<?>>(queue.size()); while(queue.hasMoreTasks()) { futures.add(executor.submit(queue.nextTask())); } if(background) return futures; try { for (Future<?> future : futures) { future.get(); //join submitted thread } return futures; } catch (InterruptedException e) { throw new SystemException(e); } catch (ExecutionException e) { throw new SystemException(e); } }
java
public Collection<Future<?>> startWorking(WorkQueue queue, boolean background) { ArrayList<Future<?>> futures = new ArrayList<Future<?>>(queue.size()); while(queue.hasMoreTasks()) { futures.add(executor.submit(queue.nextTask())); } if(background) return futures; try { for (Future<?> future : futures) { future.get(); //join submitted thread } return futures; } catch (InterruptedException e) { throw new SystemException(e); } catch (ExecutionException e) { throw new SystemException(e); } }
[ "public", "Collection", "<", "Future", "<", "?", ">", ">", "startWorking", "(", "WorkQueue", "queue", ",", "boolean", "background", ")", "{", "ArrayList", "<", "Future", "<", "?", ">", ">", "futures", "=", "new", "ArrayList", "<", "Future", "<", "?", "...
The start the work threads @param queue the queue @param background determine to while for futures to complete @return the collection of futures
[ "The", "start", "the", "work", "threads" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/workthread/ExecutorBoss.java#L205-L236
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/reflection/Mirror.java
Mirror.newInstanceForClassName
public static Mirror newInstanceForClassName(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException { className = className.trim(); Class<?> objClass = Class.forName(className); return new Mirror(ClassPath.newInstance(objClass)); }
java
public static Mirror newInstanceForClassName(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException { className = className.trim(); Class<?> objClass = Class.forName(className); return new Mirror(ClassPath.newInstance(objClass)); }
[ "public", "static", "Mirror", "newInstanceForClassName", "(", "String", "className", ")", "throws", "ClassNotFoundException", ",", "InstantiationException", ",", "IllegalAccessException", "{", "className", "=", "className", ".", "trim", "(", ")", ";", "Class", "<", ...
Create an instance of the given object @param className the class name @return the object reflector instance @throws ClassNotFoundException @throws InstantiationException @throws IllegalAccessException
[ "Create", "an", "instance", "of", "the", "given", "object" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/reflection/Mirror.java#L84-L92
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/io/FileMonitor.java
FileMonitor.waitFor
public static void waitFor(File aFile) { if(aFile == null) return; String path =aFile.getAbsolutePath(); long previousSize = IO.getFileSize(path); long currentSize = previousSize; long sleepTime = Config.getPropertyLong("file.monitor.file.wait.time",100).longValue(); while(true) { try { Thread.sleep(sleepTime); } catch(InterruptedException e){} currentSize = IO.getFileSize(path); if(currentSize == previousSize ) return; previousSize = currentSize; } }
java
public static void waitFor(File aFile) { if(aFile == null) return; String path =aFile.getAbsolutePath(); long previousSize = IO.getFileSize(path); long currentSize = previousSize; long sleepTime = Config.getPropertyLong("file.monitor.file.wait.time",100).longValue(); while(true) { try { Thread.sleep(sleepTime); } catch(InterruptedException e){} currentSize = IO.getFileSize(path); if(currentSize == previousSize ) return; previousSize = currentSize; } }
[ "public", "static", "void", "waitFor", "(", "File", "aFile", ")", "{", "if", "(", "aFile", "==", "null", ")", "return", ";", "String", "path", "=", "aFile", ".", "getAbsolutePath", "(", ")", ";", "long", "previousSize", "=", "IO", ".", "getFileSize", "...
Used to wait for transferred file's content length to stop changes for 5 seconds @param aFile the file
[ "Used", "to", "wait", "for", "transferred", "file", "s", "content", "length", "to", "stop", "changes", "for", "5", "seconds" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/io/FileMonitor.java#L57-L85
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/io/FileMonitor.java
FileMonitor.notifyChange
protected synchronized void notifyChange(File file) { System.out.println("Notify change file="+file.getAbsolutePath()); this.notify(FileEvent.createChangedEvent(file)); }
java
protected synchronized void notifyChange(File file) { System.out.println("Notify change file="+file.getAbsolutePath()); this.notify(FileEvent.createChangedEvent(file)); }
[ "protected", "synchronized", "void", "notifyChange", "(", "File", "file", ")", "{", "System", ".", "out", ".", "println", "(", "\"Notify change file=\"", "+", "file", ".", "getAbsolutePath", "(", ")", ")", ";", "this", ".", "notify", "(", "FileEvent", ".", ...
Notify observers that the file has changed @param file the file that changes
[ "Notify", "observers", "that", "the", "file", "has", "changed" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/io/FileMonitor.java#L113-L121
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/security/user/conversion/VcfFileToUserProfileConverter.java
VcfFileToUserProfileConverter.convert
@Override public UserProfile convert(File file) { if(file == null) return null; try { String text = IO.readFile(file); if(text == null || text.length() == 0) return null; return converter.convert(text); } catch (IOException e) { throw new SystemException("Unable to convert file:"+ file.getAbsolutePath()+" to user profile ERROR:"+e.getMessage(),e); } }
java
@Override public UserProfile convert(File file) { if(file == null) return null; try { String text = IO.readFile(file); if(text == null || text.length() == 0) return null; return converter.convert(text); } catch (IOException e) { throw new SystemException("Unable to convert file:"+ file.getAbsolutePath()+" to user profile ERROR:"+e.getMessage(),e); } }
[ "@", "Override", "public", "UserProfile", "convert", "(", "File", "file", ")", "{", "if", "(", "file", "==", "null", ")", "return", "null", ";", "try", "{", "String", "text", "=", "IO", ".", "readFile", "(", "file", ")", ";", "if", "(", "text", "==...
Convert the user profile
[ "Convert", "the", "user", "profile" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/security/user/conversion/VcfFileToUserProfileConverter.java#L31-L51
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/observer/SubjectRegistry.java
SubjectRegistry.register
public <T> void register(String subjectName, SubjectObserver<T> subjectObserver, Subject<T> subject) { subject.add(subjectObserver); this.registry.put(subjectName, subject); }
java
public <T> void register(String subjectName, SubjectObserver<T> subjectObserver, Subject<T> subject) { subject.add(subjectObserver); this.registry.put(subjectName, subject); }
[ "public", "<", "T", ">", "void", "register", "(", "String", "subjectName", ",", "SubjectObserver", "<", "T", ">", "subjectObserver", ",", "Subject", "<", "T", ">", "subject", ")", "{", "subject", ".", "add", "(", "subjectObserver", ")", ";", "this", ".",...
Add subject observer to a subject @param <T> the class type @param subjectName the subject name @param subjectObserver the subject observer @param subject the subject to add the observer
[ "Add", "subject", "observer", "to", "a", "subject" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/observer/SubjectRegistry.java#L67-L74
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/observer/SubjectRegistry.java
SubjectRegistry.removeRegistraion
@SuppressWarnings({ "unchecked", "rawtypes" }) public <T> void removeRegistraion(String subjectName, SubjectObserver<T> subjectObserver) { Subject subject = (Subject)this.registry.get(subjectName); if(subject == null) return; subject.remove(subjectObserver); }
java
@SuppressWarnings({ "unchecked", "rawtypes" }) public <T> void removeRegistraion(String subjectName, SubjectObserver<T> subjectObserver) { Subject subject = (Subject)this.registry.get(subjectName); if(subject == null) return; subject.remove(subjectObserver); }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "public", "<", "T", ">", "void", "removeRegistraion", "(", "String", "subjectName", ",", "SubjectObserver", "<", "T", ">", "subjectObserver", ")", "{", "Subject", "subject", "="...
Remove an observer for a registered observer @param <T> the class type @param subjectName the subject name to remove @param subjectObserver the subject observer
[ "Remove", "an", "observer", "for", "a", "registered", "observer" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/observer/SubjectRegistry.java#L81-L91
train
jinahya/bit-io
src/main/java/com/github/jinahya/bit/io/BufferByteOutput.java
BufferByteOutput.of
@SuppressWarnings({"Duplicates"}) public static BufferByteOutput<ByteBuffer> of(final int capacity, final WritableByteChannel channel) { if (capacity <= 0) { throw new IllegalArgumentException("capacity(" + capacity + ") <= 0"); } if (channel == null) { throw new NullPointerException("channel is null"); } return new BufferByteOutput<ByteBuffer>(null) { @Override public void write(final int value) throws IOException { if (target == null) { target = ByteBuffer.allocate(capacity); // position: zero, limit: capacity } if (!target.hasRemaining()) { // no space to put target.flip(); // limit -> position, position -> zero do { channel.write(target); } while (target.position() == 0); target.compact(); } super.write(value); } @Override public void setTarget(final ByteBuffer target) { throw new UnsupportedOperationException(); } }; }
java
@SuppressWarnings({"Duplicates"}) public static BufferByteOutput<ByteBuffer> of(final int capacity, final WritableByteChannel channel) { if (capacity <= 0) { throw new IllegalArgumentException("capacity(" + capacity + ") <= 0"); } if (channel == null) { throw new NullPointerException("channel is null"); } return new BufferByteOutput<ByteBuffer>(null) { @Override public void write(final int value) throws IOException { if (target == null) { target = ByteBuffer.allocate(capacity); // position: zero, limit: capacity } if (!target.hasRemaining()) { // no space to put target.flip(); // limit -> position, position -> zero do { channel.write(target); } while (target.position() == 0); target.compact(); } super.write(value); } @Override public void setTarget(final ByteBuffer target) { throw new UnsupportedOperationException(); } }; }
[ "@", "SuppressWarnings", "(", "{", "\"Duplicates\"", "}", ")", "public", "static", "BufferByteOutput", "<", "ByteBuffer", ">", "of", "(", "final", "int", "capacity", ",", "final", "WritableByteChannel", "channel", ")", "{", "if", "(", "capacity", "<=", "0", ...
Creates a new instance which writes bytes to specified channel using a byte buffer of given capacity. @param capacity the capacity for the byte buffer. @param channel the channel to which bytes are written. @return a new instance of byte buffer. @see #flush(BufferByteOutput, WritableByteChannel)
[ "Creates", "a", "new", "instance", "which", "writes", "bytes", "to", "specified", "channel", "using", "a", "byte", "buffer", "of", "given", "capacity", "." ]
f3b49bbec80047c0cc3ea2424def98eb2d08352a
https://github.com/jinahya/bit-io/blob/f3b49bbec80047c0cc3ea2424def98eb2d08352a/src/main/java/com/github/jinahya/bit/io/BufferByteOutput.java#L46-L76
train
jinahya/bit-io
src/main/java/com/github/jinahya/bit/io/BufferByteOutput.java
BufferByteOutput.flush
public static int flush(final BufferByteOutput<?> output, final WritableByteChannel channel) throws IOException { final ByteBuffer buffer = output.getTarget(); if (buffer == null) { return 0; } int written = 0; for (buffer.flip(); buffer.hasRemaining(); ) { written += channel.write(buffer); } buffer.clear(); // position -> zero; limit -> capacity return written; }
java
public static int flush(final BufferByteOutput<?> output, final WritableByteChannel channel) throws IOException { final ByteBuffer buffer = output.getTarget(); if (buffer == null) { return 0; } int written = 0; for (buffer.flip(); buffer.hasRemaining(); ) { written += channel.write(buffer); } buffer.clear(); // position -> zero; limit -> capacity return written; }
[ "public", "static", "int", "flush", "(", "final", "BufferByteOutput", "<", "?", ">", "output", ",", "final", "WritableByteChannel", "channel", ")", "throws", "IOException", "{", "final", "ByteBuffer", "buffer", "=", "output", ".", "getTarget", "(", ")", ";", ...
Flushes the internal byte buffer of given byte output to specified channel and returns the number of bytes written. @param output the output whose buffer is flushed. @param channel the channel to which the buffer is flushed. @return the number of bytes written while flushing; {@code 0} if there is no inter buffer. @throws IOException if an I/O error occurs.
[ "Flushes", "the", "internal", "byte", "buffer", "of", "given", "byte", "output", "to", "specified", "channel", "and", "returns", "the", "number", "of", "bytes", "written", "." ]
f3b49bbec80047c0cc3ea2424def98eb2d08352a
https://github.com/jinahya/bit-io/blob/f3b49bbec80047c0cc3ea2424def98eb2d08352a/src/main/java/com/github/jinahya/bit/io/BufferByteOutput.java#L89-L100
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/Scheduler.java
Scheduler.durationMS
public static long durationMS(LocalDateTime start,LocalDateTime end) { if(start == null || end == null) { return 0; } return Duration.between(start, end).toMillis(); }
java
public static long durationMS(LocalDateTime start,LocalDateTime end) { if(start == null || end == null) { return 0; } return Duration.between(start, end).toMillis(); }
[ "public", "static", "long", "durationMS", "(", "LocalDateTime", "start", ",", "LocalDateTime", "end", ")", "{", "if", "(", "start", "==", "null", "||", "end", "==", "null", ")", "{", "return", "0", ";", "}", "return", "Duration", ".", "between", "(", "...
The time between two dates @param start the begin time @param end the finish time @return duration in milliseconds
[ "The", "time", "between", "two", "dates" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Scheduler.java#L85-L93
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/Scheduler.java
Scheduler.durationSeconds
public static double durationSeconds(LocalDateTime start, LocalDateTime end) { return Duration.between(start, end).getSeconds(); }
java
public static double durationSeconds(LocalDateTime start, LocalDateTime end) { return Duration.between(start, end).getSeconds(); }
[ "public", "static", "double", "durationSeconds", "(", "LocalDateTime", "start", ",", "LocalDateTime", "end", ")", "{", "return", "Duration", ".", "between", "(", "start", ",", "end", ")", ".", "getSeconds", "(", ")", ";", "}" ]
1 millisecond = 0.001 seconds @param start between time @param end finish time @return duration in seconds
[ "1", "millisecond", "=", "0", ".", "001", "seconds" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Scheduler.java#L100-L103
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/Scheduler.java
Scheduler.durationHours
public static long durationHours(LocalDateTime start,LocalDateTime end) { if(start == null || end == null) return ZERO; return Duration.between(start, end).toHours(); }
java
public static long durationHours(LocalDateTime start,LocalDateTime end) { if(start == null || end == null) return ZERO; return Duration.between(start, end).toHours(); }
[ "public", "static", "long", "durationHours", "(", "LocalDateTime", "start", ",", "LocalDateTime", "end", ")", "{", "if", "(", "start", "==", "null", "||", "end", "==", "null", ")", "return", "ZERO", ";", "return", "Duration", ".", "between", "(", "start", ...
1 Hours = 60 minutes @param start between time @param end finish time @return duration in hours
[ "1", "Hours", "=", "60", "minutes" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Scheduler.java#L121-L127
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/Scheduler.java
Scheduler.scheduleRecurring
public void scheduleRecurring(Runnable runnable, Date firstTime, long period) { timer.scheduleAtFixedRate(toTimerTask(runnable), firstTime, period); }
java
public void scheduleRecurring(Runnable runnable, Date firstTime, long period) { timer.scheduleAtFixedRate(toTimerTask(runnable), firstTime, period); }
[ "public", "void", "scheduleRecurring", "(", "Runnable", "runnable", ",", "Date", "firstTime", ",", "long", "period", ")", "{", "timer", ".", "scheduleAtFixedRate", "(", "toTimerTask", "(", "runnable", ")", ",", "firstTime", ",", "period", ")", ";", "}" ]
Schedule runnable to run a given interval @param runnable the runnable to @param firstTime @param period
[ "Schedule", "runnable", "to", "run", "a", "given", "interval" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Scheduler.java#L188-L192
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/Scheduler.java
Scheduler.toTimerTask
public static TimerTask toTimerTask(Runnable runnable) { if(runnable instanceof TimerTask) return (TimerTask) runnable; return new TimerTaskRunnerAdapter(runnable); }
java
public static TimerTask toTimerTask(Runnable runnable) { if(runnable instanceof TimerTask) return (TimerTask) runnable; return new TimerTaskRunnerAdapter(runnable); }
[ "public", "static", "TimerTask", "toTimerTask", "(", "Runnable", "runnable", ")", "{", "if", "(", "runnable", "instanceof", "TimerTask", ")", "return", "(", "TimerTask", ")", "runnable", ";", "return", "new", "TimerTaskRunnerAdapter", "(", "runnable", ")", ";", ...
Convert timer task to a runnable @param runnable @return timer task for the runnable
[ "Convert", "timer", "task", "to", "a", "runnable" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Scheduler.java#L207-L213
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/decorator/ReplaceRegExpTextDecorator.java
ReplaceRegExpTextDecorator.getText
public String getText() { if(this.target == null) throw new RequiredException("this.target in ReplaceTextDecorator"); return Text.replaceForRegExprWith(this.target.getText(), regExp, replacement); }
java
public String getText() { if(this.target == null) throw new RequiredException("this.target in ReplaceTextDecorator"); return Text.replaceForRegExprWith(this.target.getText(), regExp, replacement); }
[ "public", "String", "getText", "(", ")", "{", "if", "(", "this", ".", "target", "==", "null", ")", "throw", "new", "RequiredException", "(", "\"this.target in ReplaceTextDecorator\"", ")", ";", "return", "Text", ".", "replaceForRegExprWith", "(", "this", ".", ...
replace the text based on a RegExpr @return Text.replaceForRegExprWith(this.target.getText(), regExp, replacement)
[ "replace", "the", "text", "based", "on", "a", "RegExpr" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/decorator/ReplaceRegExpTextDecorator.java#L21-L27
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/SettingsInMemory.java
SettingsInMemory.getInteger
public Integer getInteger(Class<?> aClass, String key, int defaultValue) { return getInteger(aClass.getName()+".key",defaultValue); }
java
public Integer getInteger(Class<?> aClass, String key, int defaultValue) { return getInteger(aClass.getName()+".key",defaultValue); }
[ "public", "Integer", "getInteger", "(", "Class", "<", "?", ">", "aClass", ",", "String", "key", ",", "int", "defaultValue", ")", "{", "return", "getInteger", "(", "aClass", ".", "getName", "(", ")", "+", "\".key\"", ",", "defaultValue", ")", ";", "}" ]
Get a Setting property as an Integer object. @param aClass calling class @param key the key name of the numeric property to be returned. @param defaultValue the default value @return Value of the property as an Integer or null if no property found.
[ "Get", "a", "Setting", "property", "as", "an", "Integer", "object", "." ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/SettingsInMemory.java#L171-L174
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/SettingsInMemory.java
SettingsInMemory.getCharacter
public Character getCharacter(Class<?> aClass,String key,char defaultValue) { String results = getText(aClass,key, ""); if(results.length() == 0) return Character.valueOf(defaultValue); else return Character.valueOf(results.charAt(0));//return first character }
java
public Character getCharacter(Class<?> aClass,String key,char defaultValue) { String results = getText(aClass,key, ""); if(results.length() == 0) return Character.valueOf(defaultValue); else return Character.valueOf(results.charAt(0));//return first character }
[ "public", "Character", "getCharacter", "(", "Class", "<", "?", ">", "aClass", ",", "String", "key", ",", "char", "defaultValue", ")", "{", "String", "results", "=", "getText", "(", "aClass", ",", "key", ",", "\"\"", ")", ";", "if", "(", "results", ".",...
Get a Settings property as an c object. @param aClass the class the property is related to @param key the Settings name @param defaultValue the default value to return if the property does not exist @return the Settings character
[ "Get", "a", "Settings", "property", "as", "an", "c", "object", "." ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/SettingsInMemory.java#L182-L190
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/SettingsInMemory.java
SettingsInMemory.getInteger
public Integer getInteger(String key) { Integer iVal = null; String sVal = getText(key); if ((sVal != null) && (sVal.length() > 0)) { iVal = Integer.valueOf(sVal); } return iVal; }
java
public Integer getInteger(String key) { Integer iVal = null; String sVal = getText(key); if ((sVal != null) && (sVal.length() > 0)) { iVal = Integer.valueOf(sVal); } return iVal; }
[ "public", "Integer", "getInteger", "(", "String", "key", ")", "{", "Integer", "iVal", "=", "null", ";", "String", "sVal", "=", "getText", "(", "key", ")", ";", "if", "(", "(", "sVal", "!=", "null", ")", "&&", "(", "sVal", ".", "length", "(", ")", ...
Get a Settings property as an Integer object. @param key the Key Name of the numeric property to be returned. @return Value of the property as an Integer or null if no property found.
[ "Get", "a", "Settings", "property", "as", "an", "Integer", "object", "." ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/SettingsInMemory.java#L198-L211
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/SettingsInMemory.java
SettingsInMemory.getBoolean
public Boolean getBoolean(String key) { Boolean bVal = null; String sVal = getText(key); if ((sVal != null) && (sVal.length() > 0)) { bVal = Boolean.valueOf(sVal); } return bVal; }
java
public Boolean getBoolean(String key) { Boolean bVal = null; String sVal = getText(key); if ((sVal != null) && (sVal.length() > 0)) { bVal = Boolean.valueOf(sVal); } return bVal; }
[ "public", "Boolean", "getBoolean", "(", "String", "key", ")", "{", "Boolean", "bVal", "=", "null", ";", "String", "sVal", "=", "getText", "(", "key", ")", ";", "if", "(", "(", "sVal", "!=", "null", ")", "&&", "(", "sVal", ".", "length", "(", ")", ...
Get a Setting property as a Boolean object. @param key the key name of the numeric property to be returned. @return Value of the property as an Boolean or null if no property found. Note that the value of the returned Boolean will be false if the <p/>property sought after exists but is not equal to "true" (ignoring case).
[ "Get", "a", "Setting", "property", "as", "a", "Boolean", "object", "." ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/SettingsInMemory.java#L263-L272
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/memento/MethodCallSavePointPlayer.java
MethodCallSavePointPlayer.playMethodCalls
public synchronized void playMethodCalls(Memento memento, String [] savePoints) { String savePoint = null; MethodCallFact methodCallFact = null; SummaryException exceptions = new SummaryException(); //loop thru savepoints for (int i = 0; i < savePoints.length; i++) { savePoint = savePoints[i]; if(savePoint == null || savePoint.length() == 0 || savePoint.trim().length() == 0) continue; Debugger.println(this,"processing savepoint="+savePoint); //get method call fact methodCallFact = (MethodCallFact)memento.restore(savePoint, MethodCallFact.class); try { ObjectProxy.executeMethod(prepareObject(methodCallFact,savePoint), methodCallFact); } catch(Exception e) { exceptions.addException(new SystemException("savePoint="+savePoint+" methodCallFact="+methodCallFact+" exception="+Debugger.stackTrace(e))); throw new SystemException(e); // TODO: } } if(!exceptions.isEmpty()) throw exceptions; }
java
public synchronized void playMethodCalls(Memento memento, String [] savePoints) { String savePoint = null; MethodCallFact methodCallFact = null; SummaryException exceptions = new SummaryException(); //loop thru savepoints for (int i = 0; i < savePoints.length; i++) { savePoint = savePoints[i]; if(savePoint == null || savePoint.length() == 0 || savePoint.trim().length() == 0) continue; Debugger.println(this,"processing savepoint="+savePoint); //get method call fact methodCallFact = (MethodCallFact)memento.restore(savePoint, MethodCallFact.class); try { ObjectProxy.executeMethod(prepareObject(methodCallFact,savePoint), methodCallFact); } catch(Exception e) { exceptions.addException(new SystemException("savePoint="+savePoint+" methodCallFact="+methodCallFact+" exception="+Debugger.stackTrace(e))); throw new SystemException(e); // TODO: } } if(!exceptions.isEmpty()) throw exceptions; }
[ "public", "synchronized", "void", "playMethodCalls", "(", "Memento", "memento", ",", "String", "[", "]", "savePoints", ")", "{", "String", "savePoint", "=", "null", ";", "MethodCallFact", "methodCallFact", "=", "null", ";", "SummaryException", "exceptions", "=", ...
Redo the method calls of a target object @param memento the memento to restore MethodCallFact @param savePoints the list of the MethodCallFact save points @throws SummaryException
[ "Redo", "the", "method", "calls", "of", "a", "target", "object" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/memento/MethodCallSavePointPlayer.java#L38-L70
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java
Debugger.printError
public static void printError(Object caller, Object message) { StringBuilder text = new StringBuilder(); Class<?> c = callerBuilder(caller, text); if(message instanceof Throwable) getLog(c).error(text.append(stackTrace((Throwable)message))); else getLog(c).error(text.append(message)); }
java
public static void printError(Object caller, Object message) { StringBuilder text = new StringBuilder(); Class<?> c = callerBuilder(caller, text); if(message instanceof Throwable) getLog(c).error(text.append(stackTrace((Throwable)message))); else getLog(c).error(text.append(message)); }
[ "public", "static", "void", "printError", "(", "Object", "caller", ",", "Object", "message", ")", "{", "StringBuilder", "text", "=", "new", "StringBuilder", "(", ")", ";", "Class", "<", "?", ">", "c", "=", "callerBuilder", "(", "caller", ",", "text", ")"...
Print a error message. The stack trace will be printed if the given message is an exception. @param caller the calling object @param message the message/object to print
[ "Print", "a", "error", "message", ".", "The", "stack", "trace", "will", "be", "printed", "if", "the", "given", "message", "is", "an", "exception", "." ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java#L411-L423
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java
Debugger.printError
public static void printError(Object errorMessage) { if (errorMessage instanceof Throwable) { Throwable e = (Throwable) errorMessage; getLog(Debugger.class).error(stackTrace(e)); } else getLog(Debugger.class).error(errorMessage); }
java
public static void printError(Object errorMessage) { if (errorMessage instanceof Throwable) { Throwable e = (Throwable) errorMessage; getLog(Debugger.class).error(stackTrace(e)); } else getLog(Debugger.class).error(errorMessage); }
[ "public", "static", "void", "printError", "(", "Object", "errorMessage", ")", "{", "if", "(", "errorMessage", "instanceof", "Throwable", ")", "{", "Throwable", "e", "=", "(", "Throwable", ")", "errorMessage", ";", "getLog", "(", "Debugger", ".", "class", ")"...
Print error message using the configured log. The stack trace will be printed if the given message is an exception. @param errorMessage the error/object message
[ "Print", "error", "message", "using", "the", "configured", "log", ".", "The", "stack", "trace", "will", "be", "printed", "if", "the", "given", "message", "is", "an", "exception", "." ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java#L430-L444
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java
Debugger.printFatal
public static void printFatal(Object message) { if (message instanceof Throwable) { Throwable e = (Throwable) message; e.printStackTrace(); } Log log = getLog(Debugger.class); if(log != null) log.fatal(message); else System.err.println(message); }
java
public static void printFatal(Object message) { if (message instanceof Throwable) { Throwable e = (Throwable) message; e.printStackTrace(); } Log log = getLog(Debugger.class); if(log != null) log.fatal(message); else System.err.println(message); }
[ "public", "static", "void", "printFatal", "(", "Object", "message", ")", "{", "if", "(", "message", "instanceof", "Throwable", ")", "{", "Throwable", "e", "=", "(", "Throwable", ")", "message", ";", "e", ".", "printStackTrace", "(", ")", ";", "}", "Log",...
Print a fatal level message. The stack trace will be printed if the given message is an exception. @param message the fatal message
[ "Print", "a", "fatal", "level", "message", ".", "The", "stack", "trace", "will", "be", "printed", "if", "the", "given", "message", "is", "an", "exception", "." ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java#L451-L466
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java
Debugger.printFatal
public static void printFatal(Object caller, Object message) { StringBuilder text = new StringBuilder(); Class<?> c = callerBuilder(caller, text); if(message instanceof Throwable) getLog(c).fatal(text.append(stackTrace((Throwable)message))); else getLog(c).fatal(text.append(message)); }
java
public static void printFatal(Object caller, Object message) { StringBuilder text = new StringBuilder(); Class<?> c = callerBuilder(caller, text); if(message instanceof Throwable) getLog(c).fatal(text.append(stackTrace((Throwable)message))); else getLog(c).fatal(text.append(message)); }
[ "public", "static", "void", "printFatal", "(", "Object", "caller", ",", "Object", "message", ")", "{", "StringBuilder", "text", "=", "new", "StringBuilder", "(", ")", ";", "Class", "<", "?", ">", "c", "=", "callerBuilder", "(", "caller", ",", "text", ")"...
Print a fatal message. The stack trace will be printed if the given message is an exception. @param caller the calling object @param message the fatal message
[ "Print", "a", "fatal", "message", ".", "The", "stack", "trace", "will", "be", "printed", "if", "the", "given", "message", "is", "an", "exception", "." ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java#L474-L486
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java
Debugger.printInfo
public static void printInfo(Object caller, Object message) { StringBuilder text = new StringBuilder(); Class<?> c = callerBuilder(caller, text); if(message instanceof Throwable) getLog(c).info(text.append(stackTrace((Throwable)message))); else getLog(c).info(text.append(message)); }
java
public static void printInfo(Object caller, Object message) { StringBuilder text = new StringBuilder(); Class<?> c = callerBuilder(caller, text); if(message instanceof Throwable) getLog(c).info(text.append(stackTrace((Throwable)message))); else getLog(c).info(text.append(message)); }
[ "public", "static", "void", "printInfo", "(", "Object", "caller", ",", "Object", "message", ")", "{", "StringBuilder", "text", "=", "new", "StringBuilder", "(", ")", ";", "Class", "<", "?", ">", "c", "=", "callerBuilder", "(", "caller", ",", "text", ")",...
Print an INFO message @param caller the calling object @param message the INFO message
[ "Print", "an", "INFO", "message" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java#L492-L504
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java
Debugger.printInfo
public static void printInfo(Object message) { if (message instanceof Throwable) { Throwable e = (Throwable) message; getLog(Debugger.class).info(stackTrace(e)); } else getLog(Debugger.class).info(message); }
java
public static void printInfo(Object message) { if (message instanceof Throwable) { Throwable e = (Throwable) message; getLog(Debugger.class).info(stackTrace(e)); } else getLog(Debugger.class).info(message); }
[ "public", "static", "void", "printInfo", "(", "Object", "message", ")", "{", "if", "(", "message", "instanceof", "Throwable", ")", "{", "Throwable", "e", "=", "(", "Throwable", ")", "message", ";", "getLog", "(", "Debugger", ".", "class", ")", ".", "info...
Print a INFO level message @param message
[ "Print", "a", "INFO", "level", "message" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java#L509-L523
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java
Debugger.printWarn
public static void printWarn(Object caller, Object message) { StringBuilder text = new StringBuilder(); Class<?> c = callerBuilder(caller, text); if(message instanceof Throwable) getLog(c).warn(text.append(stackTrace((Throwable)message))); else getLog(c).warn(text.append(message)); }
java
public static void printWarn(Object caller, Object message) { StringBuilder text = new StringBuilder(); Class<?> c = callerBuilder(caller, text); if(message instanceof Throwable) getLog(c).warn(text.append(stackTrace((Throwable)message))); else getLog(c).warn(text.append(message)); }
[ "public", "static", "void", "printWarn", "(", "Object", "caller", ",", "Object", "message", ")", "{", "StringBuilder", "text", "=", "new", "StringBuilder", "(", ")", ";", "Class", "<", "?", ">", "c", "=", "callerBuilder", "(", "caller", ",", "text", ")",...
Print a warning level message. The stack trace will be printed if the given message is an exception. @param caller the calling object @param message the message to print
[ "Print", "a", "warning", "level", "message", ".", "The", "stack", "trace", "will", "be", "printed", "if", "the", "given", "message", "is", "an", "exception", "." ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java#L531-L543
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java
Debugger.printWarn
public static void printWarn(Object message) { if (message instanceof Throwable) { Throwable e = (Throwable) message; getLog(Debugger.class).warn(stackTrace(e)); } else getLog(Debugger.class).warn(message); }
java
public static void printWarn(Object message) { if (message instanceof Throwable) { Throwable e = (Throwable) message; getLog(Debugger.class).warn(stackTrace(e)); } else getLog(Debugger.class).warn(message); }
[ "public", "static", "void", "printWarn", "(", "Object", "message", ")", "{", "if", "(", "message", "instanceof", "Throwable", ")", "{", "Throwable", "e", "=", "(", "Throwable", ")", "message", ";", "getLog", "(", "Debugger", ".", "class", ")", ".", "warn...
Print A WARN message. The stack trace will be printed if the given message is an exception. @param message the message to stack
[ "Print", "A", "WARN", "message", ".", "The", "stack", "trace", "will", "be", "printed", "if", "the", "given", "message", "is", "an", "exception", "." ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java#L575-L591
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/jmx/JMX.java
JMX.registerMemoryNotifications
public void registerMemoryNotifications(NotificationListener notificationListener, Object handback) { NotificationEmitter emitter = (NotificationEmitter) this.getMemory(); emitter.addNotificationListener(notificationListener, null, handback); }
java
public void registerMemoryNotifications(NotificationListener notificationListener, Object handback) { NotificationEmitter emitter = (NotificationEmitter) this.getMemory(); emitter.addNotificationListener(notificationListener, null, handback); }
[ "public", "void", "registerMemoryNotifications", "(", "NotificationListener", "notificationListener", ",", "Object", "handback", ")", "{", "NotificationEmitter", "emitter", "=", "(", "NotificationEmitter", ")", "this", ".", "getMemory", "(", ")", ";", "emitter", ".", ...
Allows a listener to be registered within the MemoryMXBean as a notification listener usage threshold exceeded notification - for notifying that the memory usage of a memory pool is increased and has reached or exceeded its usage threshold value. collection usage threshold exceeded notification - for notifying that the memory usage of a memory pool is greater than or equal to its collection usage threshold after the Java virtual machine has expended effort in recycling unused objects in that memory pool. The notification emitted is a Notification instance whose user data is set to a CompositeData that represents a MemoryNotificationInfo object containing information about the memory pool when the notification was constructed. The CompositeData contains the attributes as described in MemoryNotificationInfo. @param notificationListener listener to be alerted @param handback object to be passed back to notification listener when notification occurs
[ "Allows", "a", "listener", "to", "be", "registered", "within", "the", "MemoryMXBean", "as", "a", "notification", "listener", "usage", "threshold", "exceeded", "notification", "-", "for", "notifying", "that", "the", "memory", "usage", "of", "a", "memory", "pool",...
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/jmx/JMX.java#L530-L535
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/operations/Shell.java
Shell.execute
public ProcessInfo execute(boolean background,String... command) { ProcessBuilder pb = new ProcessBuilder(command); return executeProcess(background,pb); }
java
public ProcessInfo execute(boolean background,String... command) { ProcessBuilder pb = new ProcessBuilder(command); return executeProcess(background,pb); }
[ "public", "ProcessInfo", "execute", "(", "boolean", "background", ",", "String", "...", "command", ")", "{", "ProcessBuilder", "pb", "=", "new", "ProcessBuilder", "(", "command", ")", ";", "return", "executeProcess", "(", "background", ",", "pb", ")", ";", "...
Executes a giving shell command @param command the commands to execute @param background execute in background @return process information handle
[ "Executes", "a", "giving", "shell", "command" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/operations/Shell.java#L100-L107
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/operations/Shell.java
Shell.executeProcess
private ProcessInfo executeProcess(boolean background,ProcessBuilder pb) { try { pb.directory(workingDirectory); pb.redirectErrorStream(false); if(log != null) pb.redirectOutput(Redirect.appendTo(log)); pb.environment().putAll(envMap); Process p = pb.start(); String out = null; String error = null; if(background) { out = IO.readText(p.getInputStream(),true,defaultBackgroundReadSize); error = IO.readText(p.getErrorStream(),true,20); } else { out = IO.readText(p.getInputStream(),true); error = IO.readText(p.getErrorStream(),true); } if(background) return new ProcessInfo(0, out, error); return new ProcessInfo(p.waitFor(),out,error); } catch (Exception e) { return new ProcessInfo(-1, null, Debugger.stackTrace(e)); } }
java
private ProcessInfo executeProcess(boolean background,ProcessBuilder pb) { try { pb.directory(workingDirectory); pb.redirectErrorStream(false); if(log != null) pb.redirectOutput(Redirect.appendTo(log)); pb.environment().putAll(envMap); Process p = pb.start(); String out = null; String error = null; if(background) { out = IO.readText(p.getInputStream(),true,defaultBackgroundReadSize); error = IO.readText(p.getErrorStream(),true,20); } else { out = IO.readText(p.getInputStream(),true); error = IO.readText(p.getErrorStream(),true); } if(background) return new ProcessInfo(0, out, error); return new ProcessInfo(p.waitFor(),out,error); } catch (Exception e) { return new ProcessInfo(-1, null, Debugger.stackTrace(e)); } }
[ "private", "ProcessInfo", "executeProcess", "(", "boolean", "background", ",", "ProcessBuilder", "pb", ")", "{", "try", "{", "pb", ".", "directory", "(", "workingDirectory", ")", ";", "pb", ".", "redirectErrorStream", "(", "false", ")", ";", "if", "(", "log"...
Executes a process @param background if starting as background process @param pb the process builder @return the process information @throws IOException
[ "Executes", "a", "process" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/operations/Shell.java#L116-L157
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/io/csv/formulas/SumStatsByMillisecondsFormular.java
SumStatsByMillisecondsFormular.main
public static void main(String[] args) { if(args.length != 4) { System.err.println("Usage java "+SumStatsByMillisecondsFormular.class.getName()+" file msSecColumn calculateCol sumByMillisec"); System.exit(-1); } File file = Paths.get(args[0]).toFile(); try { if(!file.exists()) { throw new FileNotFoundException(file.getAbsolutePath()); } int timeMsIndex = Integer.parseInt(args[1]); int calculateColumn = Integer.parseInt(args[2]); long milliseconds = Long.parseLong(args[3]); SumStatsByMillisecondsFormular formular = new SumStatsByMillisecondsFormular(timeMsIndex, calculateColumn, milliseconds); new CsvReader(file).calc(formular); System.out.println(formular); } catch (NumberFormatException e) { System.err.println("Checks timeMsIndex:"+args[1]+",calculateColumn:"+args[2]+" and milliseconds:"+args[3]+" are valids numbers error:"+e); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
java
public static void main(String[] args) { if(args.length != 4) { System.err.println("Usage java "+SumStatsByMillisecondsFormular.class.getName()+" file msSecColumn calculateCol sumByMillisec"); System.exit(-1); } File file = Paths.get(args[0]).toFile(); try { if(!file.exists()) { throw new FileNotFoundException(file.getAbsolutePath()); } int timeMsIndex = Integer.parseInt(args[1]); int calculateColumn = Integer.parseInt(args[2]); long milliseconds = Long.parseLong(args[3]); SumStatsByMillisecondsFormular formular = new SumStatsByMillisecondsFormular(timeMsIndex, calculateColumn, milliseconds); new CsvReader(file).calc(formular); System.out.println(formular); } catch (NumberFormatException e) { System.err.println("Checks timeMsIndex:"+args[1]+",calculateColumn:"+args[2]+" and milliseconds:"+args[3]+" are valids numbers error:"+e); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "if", "(", "args", ".", "length", "!=", "4", ")", "{", "System", ".", "err", ".", "println", "(", "\"Usage java \"", "+", "SumStatsByMillisecondsFormular", ".", "class", ".", ...
Usages file msSecColumn calculateCol sumByMillisec @param args
[ "Usages", "file", "msSecColumn", "calculateCol", "sumByMillisec" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/io/csv/formulas/SumStatsByMillisecondsFormular.java#L158-L199
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/jmx/JmxSecurity.java
JmxSecurity.decorateEncryption
public static String decorateEncryption(char[] password) { if(password == null || password.length == 0) return null; return new StringBuilder(ENCRYPTED_PASSWORD_PREFIX) .append(encrypt(password)).append(ENCRYPTED_PASSWORD_SUFFIX) .toString(); }
java
public static String decorateEncryption(char[] password) { if(password == null || password.length == 0) return null; return new StringBuilder(ENCRYPTED_PASSWORD_PREFIX) .append(encrypt(password)).append(ENCRYPTED_PASSWORD_SUFFIX) .toString(); }
[ "public", "static", "String", "decorateEncryption", "(", "char", "[", "]", "password", ")", "{", "if", "(", "password", "==", "null", "||", "password", ".", "length", "==", "0", ")", "return", "null", ";", "return", "new", "StringBuilder", "(", "ENCRYPTED_...
Surround encrypted password with a prefix and suffix to indicate it has been encrypted @param password the password string @return encrypted password surrounded by the prefix and suffix
[ "Surround", "encrypted", "password", "with", "a", "prefix", "and", "suffix", "to", "indicate", "it", "has", "been", "encrypted" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/jmx/JmxSecurity.java#L89-L98
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/jmx/JmxSecurity.java
JmxSecurity.decrypt
public static char[] decrypt(char[] password) { if(password == null || password.length == 0) return null; String passwordString = String.valueOf(password); try { byte[] decrypted = null; if (passwordString.startsWith("encrypted(") && passwordString.endsWith(")")) { passwordString = passwordString.substring(10, passwordString.length() - 1); } SecretKeySpec key = new SecretKeySpec(init, "Blowfish"); Cipher cipher = Cipher.getInstance(CIPHER_INSTANCE); cipher.init(Cipher.DECRYPT_MODE, key); decrypted = cipher.doFinal(hexStringToByteArray(passwordString)); return new String(decrypted, Charset.forName("UTF8")).toCharArray(); } catch (Exception e) { throw new SecurityException( "Unable to decrypt password. Check that the password has been encrypted.", e); } }
java
public static char[] decrypt(char[] password) { if(password == null || password.length == 0) return null; String passwordString = String.valueOf(password); try { byte[] decrypted = null; if (passwordString.startsWith("encrypted(") && passwordString.endsWith(")")) { passwordString = passwordString.substring(10, passwordString.length() - 1); } SecretKeySpec key = new SecretKeySpec(init, "Blowfish"); Cipher cipher = Cipher.getInstance(CIPHER_INSTANCE); cipher.init(Cipher.DECRYPT_MODE, key); decrypted = cipher.doFinal(hexStringToByteArray(passwordString)); return new String(decrypted, Charset.forName("UTF8")).toCharArray(); } catch (Exception e) { throw new SecurityException( "Unable to decrypt password. Check that the password has been encrypted.", e); } }
[ "public", "static", "char", "[", "]", "decrypt", "(", "char", "[", "]", "password", ")", "{", "if", "(", "password", "==", "null", "||", "password", ".", "length", "==", "0", ")", "return", "null", ";", "String", "passwordString", "=", "String", ".", ...
decrypt an encrypted password string. @param password String to be decrypted @return String decrypted String
[ "decrypt", "an", "encrypted", "password", "string", "." ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/jmx/JmxSecurity.java#L133-L164
train
nyla-solutions/nyla
nyla.solutions.core/src/main/java/nyla/solutions/core/media/Graphics.java
Graphics.rotateImage
public static void rotateImage(File input, File output, String format, int degrees) throws IOException { BufferedImage inputImage = ImageIO.read(input); Graphics2D g = (Graphics2D) inputImage.getGraphics(); g.drawImage(inputImage, 0, 0, null); AffineTransform at = new AffineTransform(); // scale image //at.scale(2.0, 2.0); // rotate 45 degrees around image center at.rotate(degrees * Math.PI / 180.0, inputImage.getWidth() / 2.0, inputImage.getHeight() / 2.0); //at.rotate(Math.toRadians(degrees), inputImage.getWidth() / 2.0, inputImage.getHeight() / 2.0); /* * translate to make sure the rotation doesn't cut off any image data */ AffineTransform translationTransform; translationTransform = findTranslation(at, inputImage); at.preConcatenate(translationTransform); // instantiate and apply transformation filter BufferedImageOp bio = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); BufferedImage destinationBI = bio.filter(inputImage, null); ImageIO.write(destinationBI, format, output); }
java
public static void rotateImage(File input, File output, String format, int degrees) throws IOException { BufferedImage inputImage = ImageIO.read(input); Graphics2D g = (Graphics2D) inputImage.getGraphics(); g.drawImage(inputImage, 0, 0, null); AffineTransform at = new AffineTransform(); // scale image //at.scale(2.0, 2.0); // rotate 45 degrees around image center at.rotate(degrees * Math.PI / 180.0, inputImage.getWidth() / 2.0, inputImage.getHeight() / 2.0); //at.rotate(Math.toRadians(degrees), inputImage.getWidth() / 2.0, inputImage.getHeight() / 2.0); /* * translate to make sure the rotation doesn't cut off any image data */ AffineTransform translationTransform; translationTransform = findTranslation(at, inputImage); at.preConcatenate(translationTransform); // instantiate and apply transformation filter BufferedImageOp bio = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); BufferedImage destinationBI = bio.filter(inputImage, null); ImageIO.write(destinationBI, format, output); }
[ "public", "static", "void", "rotateImage", "(", "File", "input", ",", "File", "output", ",", "String", "format", ",", "int", "degrees", ")", "throws", "IOException", "{", "BufferedImage", "inputImage", "=", "ImageIO", ".", "read", "(", "input", ")", ";", "...
Rotate a file a given number of degrees @param input input image file @param output the output image fiel @param format the format (png, jpg, gif, etc.) @param degrees angle to rotote @throws IOException
[ "Rotate", "a", "file", "a", "given", "number", "of", "degrees" ]
38d5b843c76eae9762bbca20453ed0f0ad8412a9
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/media/Graphics.java#L36-L70
train
wnameless/workbook-accessor
src/main/java/com/github/wnameless/workbookaccessor/WorkbookReader.java
WorkbookReader.close
public void close() { try { if (is != null) is.close(); } catch (IOException e) { log.error(null, e); throw new RuntimeException(e); } isClosed = true; }
java
public void close() { try { if (is != null) is.close(); } catch (IOException e) { log.error(null, e); throw new RuntimeException(e); } isClosed = true; }
[ "public", "void", "close", "(", ")", "{", "try", "{", "if", "(", "is", "!=", "null", ")", "is", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "log", ".", "error", "(", "null", ",", "e", ")", ";", "throw", "new"...
Closes the Workbook manually.
[ "Closes", "the", "Workbook", "manually", "." ]
b6bfda4a1d1e99b1ab736a8a8c0aeae608f5e983
https://github.com/wnameless/workbook-accessor/blob/b6bfda4a1d1e99b1ab736a8a8c0aeae608f5e983/src/main/java/com/github/wnameless/workbookaccessor/WorkbookReader.java#L231-L239
train
wnameless/workbook-accessor
src/main/java/com/github/wnameless/workbookaccessor/WorkbookReader.java
WorkbookReader.toCSV
public Iterable<String> toCSV() { checkState(!isClosed, WORKBOOK_CLOSED); Joiner joiner = Joiner.on(",").useForNull(""); Iterable<String> CSVIterable = Iterables.transform(sheet, item -> joiner.join(rowToList(item, true))); return hasHeader ? Iterables.skip(CSVIterable, 1) : CSVIterable; }
java
public Iterable<String> toCSV() { checkState(!isClosed, WORKBOOK_CLOSED); Joiner joiner = Joiner.on(",").useForNull(""); Iterable<String> CSVIterable = Iterables.transform(sheet, item -> joiner.join(rowToList(item, true))); return hasHeader ? Iterables.skip(CSVIterable, 1) : CSVIterable; }
[ "public", "Iterable", "<", "String", ">", "toCSV", "(", ")", "{", "checkState", "(", "!", "isClosed", ",", "WORKBOOK_CLOSED", ")", ";", "Joiner", "joiner", "=", "Joiner", ".", "on", "(", "\",\"", ")", ".", "useForNull", "(", "\"\"", ")", ";", "Iterable...
Converts the spreadsheet to CSV by a String Iterable. @return String Iterable
[ "Converts", "the", "spreadsheet", "to", "CSV", "by", "a", "String", "Iterable", "." ]
b6bfda4a1d1e99b1ab736a8a8c0aeae608f5e983
https://github.com/wnameless/workbook-accessor/blob/b6bfda4a1d1e99b1ab736a8a8c0aeae608f5e983/src/main/java/com/github/wnameless/workbookaccessor/WorkbookReader.java#L340-L346
train
wnameless/workbook-accessor
src/main/java/com/github/wnameless/workbookaccessor/WorkbookReader.java
WorkbookReader.toLists
public Iterable<List<String>> toLists() { checkState(!isClosed, WORKBOOK_CLOSED); Iterable<List<String>> listsIterable = Iterables.transform(sheet, item -> { return rowToList(item); }); return hasHeader ? Iterables.skip(listsIterable, 1) : listsIterable; }
java
public Iterable<List<String>> toLists() { checkState(!isClosed, WORKBOOK_CLOSED); Iterable<List<String>> listsIterable = Iterables.transform(sheet, item -> { return rowToList(item); }); return hasHeader ? Iterables.skip(listsIterable, 1) : listsIterable; }
[ "public", "Iterable", "<", "List", "<", "String", ">", ">", "toLists", "(", ")", "{", "checkState", "(", "!", "isClosed", ",", "WORKBOOK_CLOSED", ")", ";", "Iterable", "<", "List", "<", "String", ">", ">", "listsIterable", "=", "Iterables", ".", "transfo...
Converts the spreadsheet to String Lists by a List Iterable. @return List of String Iterable
[ "Converts", "the", "spreadsheet", "to", "String", "Lists", "by", "a", "List", "Iterable", "." ]
b6bfda4a1d1e99b1ab736a8a8c0aeae608f5e983
https://github.com/wnameless/workbook-accessor/blob/b6bfda4a1d1e99b1ab736a8a8c0aeae608f5e983/src/main/java/com/github/wnameless/workbookaccessor/WorkbookReader.java#L353-L359
train
wnameless/workbook-accessor
src/main/java/com/github/wnameless/workbookaccessor/WorkbookReader.java
WorkbookReader.toArrays
public Iterable<String[]> toArrays() { checkState(!isClosed, WORKBOOK_CLOSED); Iterable<String[]> arraysIterable = Iterables.transform(sheet, item -> { List<String> list = rowToList(item); return list.toArray(new String[list.size()]); }); return hasHeader ? Iterables.skip(arraysIterable, 1) : arraysIterable; }
java
public Iterable<String[]> toArrays() { checkState(!isClosed, WORKBOOK_CLOSED); Iterable<String[]> arraysIterable = Iterables.transform(sheet, item -> { List<String> list = rowToList(item); return list.toArray(new String[list.size()]); }); return hasHeader ? Iterables.skip(arraysIterable, 1) : arraysIterable; }
[ "public", "Iterable", "<", "String", "[", "]", ">", "toArrays", "(", ")", "{", "checkState", "(", "!", "isClosed", ",", "WORKBOOK_CLOSED", ")", ";", "Iterable", "<", "String", "[", "]", ">", "arraysIterable", "=", "Iterables", ".", "transform", "(", "she...
Converts the spreadsheet to String Arrays by an Array Iterable. @return String array Iterable
[ "Converts", "the", "spreadsheet", "to", "String", "Arrays", "by", "an", "Array", "Iterable", "." ]
b6bfda4a1d1e99b1ab736a8a8c0aeae608f5e983
https://github.com/wnameless/workbook-accessor/blob/b6bfda4a1d1e99b1ab736a8a8c0aeae608f5e983/src/main/java/com/github/wnameless/workbookaccessor/WorkbookReader.java#L366-L373
train
wnameless/workbook-accessor
src/main/java/com/github/wnameless/workbookaccessor/WorkbookReader.java
WorkbookReader.toMaps
public Iterable<Map<String, String>> toMaps() { checkState(!isClosed, WORKBOOK_CLOSED); checkState(hasHeader, NO_HEADER); return Iterables.skip(Iterables.transform(sheet, item -> { Map<String, String> map = newLinkedHashMap(); List<String> row = rowToList(item); for (int i = 0; i < getHeader().size(); i++) { map.put(getHeader().get(i), row.get(i)); } return map; }), 1); }
java
public Iterable<Map<String, String>> toMaps() { checkState(!isClosed, WORKBOOK_CLOSED); checkState(hasHeader, NO_HEADER); return Iterables.skip(Iterables.transform(sheet, item -> { Map<String, String> map = newLinkedHashMap(); List<String> row = rowToList(item); for (int i = 0; i < getHeader().size(); i++) { map.put(getHeader().get(i), row.get(i)); } return map; }), 1); }
[ "public", "Iterable", "<", "Map", "<", "String", ",", "String", ">", ">", "toMaps", "(", ")", "{", "checkState", "(", "!", "isClosed", ",", "WORKBOOK_CLOSED", ")", ";", "checkState", "(", "hasHeader", ",", "NO_HEADER", ")", ";", "return", "Iterables", "....
Converts the spreadsheet to Maps by a Map Iterable. All Maps are implemented by LinkedHashMap which implies the order of all fields is kept. @return Map{@literal <String, String>} Iterable
[ "Converts", "the", "spreadsheet", "to", "Maps", "by", "a", "Map", "Iterable", ".", "All", "Maps", "are", "implemented", "by", "LinkedHashMap", "which", "implies", "the", "order", "of", "all", "fields", "is", "kept", "." ]
b6bfda4a1d1e99b1ab736a8a8c0aeae608f5e983
https://github.com/wnameless/workbook-accessor/blob/b6bfda4a1d1e99b1ab736a8a8c0aeae608f5e983/src/main/java/com/github/wnameless/workbookaccessor/WorkbookReader.java#L381-L392
train
Dempsy/dempsy
dempsy-framework.impl/src/main/java/net/dempsy/transport/passthrough/PassthroughReceiver.java
PassthroughReceiver.start
@SuppressWarnings("unchecked") @Override public void start(final Listener<?> listener, final Infrastructure infra) throws MessageTransportException { this.listener = (Listener<Object>) listener; }
java
@SuppressWarnings("unchecked") @Override public void start(final Listener<?> listener, final Infrastructure infra) throws MessageTransportException { this.listener = (Listener<Object>) listener; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Override", "public", "void", "start", "(", "final", "Listener", "<", "?", ">", "listener", ",", "final", "Infrastructure", "infra", ")", "throws", "MessageTransportException", "{", "this", ".", "listener"...
A receiver is started with a Listener and a threading model.
[ "A", "receiver", "is", "started", "with", "a", "Listener", "and", "a", "threading", "model", "." ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.impl/src/main/java/net/dempsy/transport/passthrough/PassthroughReceiver.java#L34-L38
train
Dempsy/dempsy
dempsy-framework.impl/src/main/java/net/dempsy/transport/blockingqueue/BlockingQueueReceiver.java
BlockingQueueReceiver.start
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public synchronized void start(final Listener listener, final Infrastructure infra) { if (listener == null) throw new IllegalArgumentException("Cannot pass null to " + BlockingQueueReceiver.class.getSimpleName() + ".setListener"); if (this.listener != null) throw new IllegalStateException( "Cannot set a new Listener (" + SafeString.objectDescription(listener) + ") on a " + BlockingQueueReceiver.class.getSimpleName() + " when there's one already set (" + SafeString.objectDescription(this.listener) + ")"); this.listener = listener; infra.getThreadingModel().runDaemon(this, "BQReceiver-" + address.toString()); }
java
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public synchronized void start(final Listener listener, final Infrastructure infra) { if (listener == null) throw new IllegalArgumentException("Cannot pass null to " + BlockingQueueReceiver.class.getSimpleName() + ".setListener"); if (this.listener != null) throw new IllegalStateException( "Cannot set a new Listener (" + SafeString.objectDescription(listener) + ") on a " + BlockingQueueReceiver.class.getSimpleName() + " when there's one already set (" + SafeString.objectDescription(this.listener) + ")"); this.listener = listener; infra.getThreadingModel().runDaemon(this, "BQReceiver-" + address.toString()); }
[ "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "@", "Override", "public", "synchronized", "void", "start", "(", "final", "Listener", "listener", ",", "final", "Infrastructure", "infra", ")", "{", "if", "(", "listener", "==",...
A BlockingQueueAdaptor requires a MessageTransportListener to be set in order to adapt a client side. @param listener is the MessageTransportListener to push messages to when they come in.
[ "A", "BlockingQueueAdaptor", "requires", "a", "MessageTransportListener", "to", "be", "set", "in", "order", "to", "adapt", "a", "client", "side", "." ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.impl/src/main/java/net/dempsy/transport/blockingqueue/BlockingQueueReceiver.java#L120-L131
train
Dempsy/dempsy
dempsy-framework.api/src/main/java/net/dempsy/lifecycle/annotation/internal/MessageUtils.java
MessageUtils.unwindMessages
public static void unwindMessages(final Object message, final List<Object> messages) { if (message instanceof Iterable) { @SuppressWarnings("rawtypes") final Iterator it = ((Iterable) message).iterator(); while (it.hasNext()) unwindMessages(it.next(), messages); } else messages.add(message); }
java
public static void unwindMessages(final Object message, final List<Object> messages) { if (message instanceof Iterable) { @SuppressWarnings("rawtypes") final Iterator it = ((Iterable) message).iterator(); while (it.hasNext()) unwindMessages(it.next(), messages); } else messages.add(message); }
[ "public", "static", "void", "unwindMessages", "(", "final", "Object", "message", ",", "final", "List", "<", "Object", ">", "messages", ")", "{", "if", "(", "message", "instanceof", "Iterable", ")", "{", "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "fin...
Return values from invoke's may be Iterables in which case there are many messages to be sent out.
[ "Return", "values", "from", "invoke", "s", "may", "be", "Iterables", "in", "which", "case", "there", "are", "many", "messages", "to", "be", "sent", "out", "." ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.api/src/main/java/net/dempsy/lifecycle/annotation/internal/MessageUtils.java#L25-L33
train
Dempsy/dempsy
dempsy-framework.impl/src/main/java/net/dempsy/router/shardutils/Leader.java
Leader.perNodeRelease
private Set<Integer> perNodeRelease(final C thisNodeAddress, final C[] currentState, final int nodeCount, final int nodeRank) { final int numberIShouldHave = howManyShouldIHave(totalNumShards, nodeCount, minNodes, nodeRank); // destinationsAcquired reflects what we already have according to the currentState final List<Integer> destinationsAcquired = buildDestinationsAcquired(thisNodeAddress, currentState); final int numHad = destinationsAcquired.size(); final Set<Integer> ret = new HashSet<>(); if (destinationsAcquired.size() > numberIShouldHave) { // there's some to remove. final Random random = new Random(); while (destinationsAcquired.size() > numberIShouldHave) { final int index = random.nextInt(destinationsAcquired.size()); ret.add(destinationsAcquired.remove(index)); } } if (LOGGER.isTraceEnabled() && ret.size() > 0) LOGGER.trace(thisNodeAddress.toString() + " removing shards " + ret + " because I have " + numHad + " but shouldn't have more than " + numberIShouldHave + "."); return ret; }
java
private Set<Integer> perNodeRelease(final C thisNodeAddress, final C[] currentState, final int nodeCount, final int nodeRank) { final int numberIShouldHave = howManyShouldIHave(totalNumShards, nodeCount, minNodes, nodeRank); // destinationsAcquired reflects what we already have according to the currentState final List<Integer> destinationsAcquired = buildDestinationsAcquired(thisNodeAddress, currentState); final int numHad = destinationsAcquired.size(); final Set<Integer> ret = new HashSet<>(); if (destinationsAcquired.size() > numberIShouldHave) { // there's some to remove. final Random random = new Random(); while (destinationsAcquired.size() > numberIShouldHave) { final int index = random.nextInt(destinationsAcquired.size()); ret.add(destinationsAcquired.remove(index)); } } if (LOGGER.isTraceEnabled() && ret.size() > 0) LOGGER.trace(thisNodeAddress.toString() + " removing shards " + ret + " because I have " + numHad + " but shouldn't have more than " + numberIShouldHave + "."); return ret; }
[ "private", "Set", "<", "Integer", ">", "perNodeRelease", "(", "final", "C", "thisNodeAddress", ",", "final", "C", "[", "]", "currentState", ",", "final", "int", "nodeCount", ",", "final", "int", "nodeRank", ")", "{", "final", "int", "numberIShouldHave", "=",...
go through and determine which nodes to give up ... if any
[ "go", "through", "and", "determine", "which", "nodes", "to", "give", "up", "...", "if", "any" ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.impl/src/main/java/net/dempsy/router/shardutils/Leader.java#L206-L228
train
Dempsy/dempsy
dempsy-framework.impl/src/main/java/net/dempsy/router/shardutils/Leader.java
Leader.registerAndConfirmIfImIt
private boolean registerAndConfirmIfImIt() throws ClusterInfoException { // reset the subdir watcher final Collection<String> imItSubdirs = utils.persistentGetSubdir(utils.leaderDir, this); // "there can be only one" if (imItSubdirs.size() > 1) throw new ClusterInfoException( "This is IMPOSSIBLE. There's more than one subdir of " + utils.leaderDir + ". They include " + imItSubdirs); // make sure it's still mine. @SuppressWarnings("unchecked") final C registered = (C) session.getData(utils.masterDetermineDir, null); return utils.thisNodeAddress.equals(registered); // am I it, or not? }
java
private boolean registerAndConfirmIfImIt() throws ClusterInfoException { // reset the subdir watcher final Collection<String> imItSubdirs = utils.persistentGetSubdir(utils.leaderDir, this); // "there can be only one" if (imItSubdirs.size() > 1) throw new ClusterInfoException( "This is IMPOSSIBLE. There's more than one subdir of " + utils.leaderDir + ". They include " + imItSubdirs); // make sure it's still mine. @SuppressWarnings("unchecked") final C registered = (C) session.getData(utils.masterDetermineDir, null); return utils.thisNodeAddress.equals(registered); // am I it, or not? }
[ "private", "boolean", "registerAndConfirmIfImIt", "(", ")", "throws", "ClusterInfoException", "{", "// reset the subdir watcher", "final", "Collection", "<", "String", ">", "imItSubdirs", "=", "utils", ".", "persistentGetSubdir", "(", "utils", ".", "leaderDir", ",", "...
whether or not imIt and return that.
[ "whether", "or", "not", "imIt", "and", "return", "that", "." ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.impl/src/main/java/net/dempsy/router/shardutils/Leader.java#L271-L285
train
Dempsy/dempsy
dempsy-framework.impl/src/main/java/net/dempsy/transport/blockingqueue/BlockingQueueSender.java
BlockingQueueSender.send
@Override public void send(final Object message) throws MessageTransportException { if (shutdown.get()) throw new MessageTransportException("send called on shutdown queue."); if (blocking) { while (true) { try { queue.put(message); if (statsCollector != null) statsCollector.messageSent(message); break; } catch (final InterruptedException ie) { if (shutdown.get()) throw new MessageTransportException("Shutting down durring send."); } } } else { if (!queue.offer(message)) { if (statsCollector != null) statsCollector.messageNotSent(); throw new MessageTransportException("Failed to queue message due to capacity."); } else if (statsCollector != null) statsCollector.messageSent(message); } }
java
@Override public void send(final Object message) throws MessageTransportException { if (shutdown.get()) throw new MessageTransportException("send called on shutdown queue."); if (blocking) { while (true) { try { queue.put(message); if (statsCollector != null) statsCollector.messageSent(message); break; } catch (final InterruptedException ie) { if (shutdown.get()) throw new MessageTransportException("Shutting down durring send."); } } } else { if (!queue.offer(message)) { if (statsCollector != null) statsCollector.messageNotSent(); throw new MessageTransportException("Failed to queue message due to capacity."); } else if (statsCollector != null) statsCollector.messageSent(message); } }
[ "@", "Override", "public", "void", "send", "(", "final", "Object", "message", ")", "throws", "MessageTransportException", "{", "if", "(", "shutdown", ".", "get", "(", ")", ")", "throw", "new", "MessageTransportException", "(", "\"send called on shutdown queue.\"", ...
Send a message into the BlockingQueueAdaptor.
[ "Send", "a", "message", "into", "the", "BlockingQueueAdaptor", "." ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.impl/src/main/java/net/dempsy/transport/blockingqueue/BlockingQueueSender.java#L71-L96
train
Dempsy/dempsy
dempsy-framework.api/src/main/java/net/dempsy/lifecycle/annotation/internal/AnnotatedMethodInvoker.java
AnnotatedMethodInvoker.allTypeAnnotations
public static <A extends Annotation> List<AnnotatedClass<A>> allTypeAnnotations(final Class<?> clazz, final Class<A> annotation, final boolean recurse) { final List<AnnotatedClass<A>> ret = new ArrayList<>(); final A curClassAnnotation = clazz.getAnnotation(annotation); if (curClassAnnotation != null) ret.add(new AnnotatedClass<A>(clazz, curClassAnnotation)); if (!recurse) return ret; final Class<?> superClazz = clazz.getSuperclass(); if (superClazz != null) ret.addAll(allTypeAnnotations(superClazz, annotation, recurse)); // Now do the interfaces. final Class<?>[] ifaces = clazz.getInterfaces(); if (ifaces != null && ifaces.length > 0) Arrays.stream(ifaces).forEach(iface -> ret.addAll(allTypeAnnotations(iface, annotation, recurse))); return ret; }
java
public static <A extends Annotation> List<AnnotatedClass<A>> allTypeAnnotations(final Class<?> clazz, final Class<A> annotation, final boolean recurse) { final List<AnnotatedClass<A>> ret = new ArrayList<>(); final A curClassAnnotation = clazz.getAnnotation(annotation); if (curClassAnnotation != null) ret.add(new AnnotatedClass<A>(clazz, curClassAnnotation)); if (!recurse) return ret; final Class<?> superClazz = clazz.getSuperclass(); if (superClazz != null) ret.addAll(allTypeAnnotations(superClazz, annotation, recurse)); // Now do the interfaces. final Class<?>[] ifaces = clazz.getInterfaces(); if (ifaces != null && ifaces.length > 0) Arrays.stream(ifaces).forEach(iface -> ret.addAll(allTypeAnnotations(iface, annotation, recurse))); return ret; }
[ "public", "static", "<", "A", "extends", "Annotation", ">", "List", "<", "AnnotatedClass", "<", "A", ">", ">", "allTypeAnnotations", "(", "final", "Class", "<", "?", ">", "clazz", ",", "final", "Class", "<", "A", ">", "annotation", ",", "final", "boolean...
Get all annotation on the given class, plus all annotations on the parent classes @param clazz @param annotation @return
[ "Get", "all", "annotation", "on", "the", "given", "class", "plus", "all", "annotations", "on", "the", "parent", "classes" ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.api/src/main/java/net/dempsy/lifecycle/annotation/internal/AnnotatedMethodInvoker.java#L240-L259
train
Dempsy/dempsy
dempsy-framework.impl/src/main/java/net/dempsy/router/shardutils/Subscriber.java
Subscriber.cleanupAfterExceptionDuringNodeDirCheck
private final void cleanupAfterExceptionDuringNodeDirCheck() { if (nodeDirectory != null) { // attempt to remove the node directory try { if (session.exists(nodeDirectory, this)) { session.rmdir(nodeDirectory); } nodeDirectory = null; } catch (final ClusterInfoException cie2) {} } }
java
private final void cleanupAfterExceptionDuringNodeDirCheck() { if (nodeDirectory != null) { // attempt to remove the node directory try { if (session.exists(nodeDirectory, this)) { session.rmdir(nodeDirectory); } nodeDirectory = null; } catch (final ClusterInfoException cie2) {} } }
[ "private", "final", "void", "cleanupAfterExceptionDuringNodeDirCheck", "(", ")", "{", "if", "(", "nodeDirectory", "!=", "null", ")", "{", "// attempt to remove the node directory", "try", "{", "if", "(", "session", ".", "exists", "(", "nodeDirectory", ",", "this", ...
called from the catch clauses in checkNodeDirectory
[ "called", "from", "the", "catch", "clauses", "in", "checkNodeDirectory" ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.impl/src/main/java/net/dempsy/router/shardutils/Subscriber.java#L169-L179
train
Dempsy/dempsy
dempsy-framework.api/src/main/java/net/dempsy/config/Cluster.java
Cluster.destination
public Cluster destination(final String... destinations) { final String applicationName = clusterId.applicationName; return destination(Arrays.stream(destinations).map(d -> new ClusterId(applicationName, d)).toArray(ClusterId[]::new)); }
java
public Cluster destination(final String... destinations) { final String applicationName = clusterId.applicationName; return destination(Arrays.stream(destinations).map(d -> new ClusterId(applicationName, d)).toArray(ClusterId[]::new)); }
[ "public", "Cluster", "destination", "(", "final", "String", "...", "destinations", ")", "{", "final", "String", "applicationName", "=", "clusterId", ".", "applicationName", ";", "return", "destination", "(", "Arrays", ".", "stream", "(", "destinations", ")", "."...
Set the list of explicit destination that outgoing messages should be limited to.
[ "Set", "the", "list", "of", "explicit", "destination", "that", "outgoing", "messages", "should", "be", "limited", "to", "." ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.api/src/main/java/net/dempsy/config/Cluster.java#L79-L82
train
Dempsy/dempsy
dempsy-framework.api/src/main/java/net/dempsy/config/Cluster.java
Cluster.setAppName
void setAppName(final String appName) { if (clusterId.applicationName != null && !clusterId.applicationName.equals(appName)) throw new IllegalStateException("Restting the application name on a cluster is not allowed."); clusterId = new ClusterId(appName, clusterId.clusterName); }
java
void setAppName(final String appName) { if (clusterId.applicationName != null && !clusterId.applicationName.equals(appName)) throw new IllegalStateException("Restting the application name on a cluster is not allowed."); clusterId = new ClusterId(appName, clusterId.clusterName); }
[ "void", "setAppName", "(", "final", "String", "appName", ")", "{", "if", "(", "clusterId", ".", "applicationName", "!=", "null", "&&", "!", "clusterId", ".", "applicationName", ".", "equals", "(", "appName", ")", ")", "throw", "new", "IllegalStateException", ...
This is called from Node
[ "This", "is", "called", "from", "Node" ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.api/src/main/java/net/dempsy/config/Cluster.java#L221-L225
train
Dempsy/dempsy
dempsy-framework.impl/src/main/java/net/dempsy/monitoring/dropwizard/DropwizardClusterStatsCollector.java
DropwizardClusterStatsCollector.getName
protected String getName(final String key) { return MetricRegistry.name(DropwizardClusterStatsCollector.class, "cluster", clusterId.applicationName, clusterId.clusterName, key); }
java
protected String getName(final String key) { return MetricRegistry.name(DropwizardClusterStatsCollector.class, "cluster", clusterId.applicationName, clusterId.clusterName, key); }
[ "protected", "String", "getName", "(", "final", "String", "key", ")", "{", "return", "MetricRegistry", ".", "name", "(", "DropwizardClusterStatsCollector", ".", "class", ",", "\"cluster\"", ",", "clusterId", ".", "applicationName", ",", "clusterId", ".", "clusterN...
protected access for testing purposes
[ "protected", "access", "for", "testing", "purposes" ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.impl/src/main/java/net/dempsy/monitoring/dropwizard/DropwizardClusterStatsCollector.java#L129-L131
train
Dempsy/dempsy
dempsy-framework.api/src/main/java/net/dempsy/lifecycle/annotation/MessageProcessor.java
MessageProcessor.newInstance
@SuppressWarnings("unchecked") @Override public T newInstance() throws DempsyException { return wrap(() -> (T) cloneMethod.invoke(prototype)); }
java
@SuppressWarnings("unchecked") @Override public T newInstance() throws DempsyException { return wrap(() -> (T) cloneMethod.invoke(prototype)); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Override", "public", "T", "newInstance", "(", ")", "throws", "DempsyException", "{", "return", "wrap", "(", "(", ")", "->", "(", "T", ")", "cloneMethod", ".", "invoke", "(", "prototype", ")", ")", ...
Creates a new instance from the prototype.
[ "Creates", "a", "new", "instance", "from", "the", "prototype", "." ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.api/src/main/java/net/dempsy/lifecycle/annotation/MessageProcessor.java#L95-L99
train
Dempsy/dempsy
dempsy-framework.api/src/main/java/net/dempsy/lifecycle/annotation/MessageProcessor.java
MessageProcessor.activate
@Override public void activate(final T instance, final Object key) throws DempsyException { wrap(() -> activationMethod.invoke(instance, key)); }
java
@Override public void activate(final T instance, final Object key) throws DempsyException { wrap(() -> activationMethod.invoke(instance, key)); }
[ "@", "Override", "public", "void", "activate", "(", "final", "T", "instance", ",", "final", "Object", "key", ")", "throws", "DempsyException", "{", "wrap", "(", "(", ")", "->", "activationMethod", ".", "invoke", "(", "instance", ",", "key", ")", ")", ";"...
Invokes the activation method of the passed instance.
[ "Invokes", "the", "activation", "method", "of", "the", "passed", "instance", "." ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.api/src/main/java/net/dempsy/lifecycle/annotation/MessageProcessor.java#L104-L107
train
Dempsy/dempsy
dempsy-framework.api/src/main/java/net/dempsy/lifecycle/annotation/MessageProcessor.java
MessageProcessor.invokeEvictable
@Override public boolean invokeEvictable(final T instance) throws DempsyException { return isEvictionSupported() ? (Boolean) wrap(() -> evictableMethod.invoke(instance)) : false; }
java
@Override public boolean invokeEvictable(final T instance) throws DempsyException { return isEvictionSupported() ? (Boolean) wrap(() -> evictableMethod.invoke(instance)) : false; }
[ "@", "Override", "public", "boolean", "invokeEvictable", "(", "final", "T", "instance", ")", "throws", "DempsyException", "{", "return", "isEvictionSupported", "(", ")", "?", "(", "Boolean", ")", "wrap", "(", "(", ")", "->", "evictableMethod", ".", "invoke", ...
Invokes the evictable method on the provided instance. If the evictable is not implemented, returns false.
[ "Invokes", "the", "evictable", "method", "on", "the", "provided", "instance", ".", "If", "the", "evictable", "is", "not", "implemented", "returns", "false", "." ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.api/src/main/java/net/dempsy/lifecycle/annotation/MessageProcessor.java#L165-L168
train
Dempsy/dempsy
dempsy-framework.impl/src/main/java/net/dempsy/output/OutputQuartzHelper.java
OutputQuartzHelper.getJobDetail
public JobDetail getJobDetail(OutputInvoker outputInvoker) { JobBuilder jobBuilder = JobBuilder.newJob(OutputJob.class); JobDetail jobDetail = jobBuilder.build(); jobDetail.getJobDataMap().put(OUTPUT_JOB_NAME, outputInvoker); return jobDetail; }
java
public JobDetail getJobDetail(OutputInvoker outputInvoker) { JobBuilder jobBuilder = JobBuilder.newJob(OutputJob.class); JobDetail jobDetail = jobBuilder.build(); jobDetail.getJobDataMap().put(OUTPUT_JOB_NAME, outputInvoker); return jobDetail; }
[ "public", "JobDetail", "getJobDetail", "(", "OutputInvoker", "outputInvoker", ")", "{", "JobBuilder", "jobBuilder", "=", "JobBuilder", ".", "newJob", "(", "OutputJob", ".", "class", ")", ";", "JobDetail", "jobDetail", "=", "jobBuilder", ".", "build", "(", ")", ...
Gets the job detail. @param outputInvoker the output invoker @return the job detail
[ "Gets", "the", "job", "detail", "." ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.impl/src/main/java/net/dempsy/output/OutputQuartzHelper.java#L48-L53
train
Dempsy/dempsy
dempsy-framework.impl/src/main/java/net/dempsy/output/OutputQuartzHelper.java
OutputQuartzHelper.getSimpleTrigger
public Trigger getSimpleTrigger(TimeUnit timeUnit, int timeInterval) { SimpleScheduleBuilder simpleScheduleBuilder = null; simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule(); switch (timeUnit) { case MILLISECONDS: simpleScheduleBuilder.withIntervalInMilliseconds(timeInterval).repeatForever(); break; case SECONDS: simpleScheduleBuilder.withIntervalInSeconds(timeInterval).repeatForever(); break; case MINUTES: simpleScheduleBuilder.withIntervalInMinutes(timeInterval).repeatForever(); break; case HOURS: simpleScheduleBuilder.withIntervalInHours(timeInterval).repeatForever(); break; case DAYS: simpleScheduleBuilder.withIntervalInHours(timeInterval * 24).repeatForever(); break; default: simpleScheduleBuilder.withIntervalInSeconds(1).repeatForever(); //default 1 sec } Trigger simpleTrigger = TriggerBuilder.newTrigger().withSchedule(simpleScheduleBuilder).build(); return simpleTrigger; }
java
public Trigger getSimpleTrigger(TimeUnit timeUnit, int timeInterval) { SimpleScheduleBuilder simpleScheduleBuilder = null; simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule(); switch (timeUnit) { case MILLISECONDS: simpleScheduleBuilder.withIntervalInMilliseconds(timeInterval).repeatForever(); break; case SECONDS: simpleScheduleBuilder.withIntervalInSeconds(timeInterval).repeatForever(); break; case MINUTES: simpleScheduleBuilder.withIntervalInMinutes(timeInterval).repeatForever(); break; case HOURS: simpleScheduleBuilder.withIntervalInHours(timeInterval).repeatForever(); break; case DAYS: simpleScheduleBuilder.withIntervalInHours(timeInterval * 24).repeatForever(); break; default: simpleScheduleBuilder.withIntervalInSeconds(1).repeatForever(); //default 1 sec } Trigger simpleTrigger = TriggerBuilder.newTrigger().withSchedule(simpleScheduleBuilder).build(); return simpleTrigger; }
[ "public", "Trigger", "getSimpleTrigger", "(", "TimeUnit", "timeUnit", ",", "int", "timeInterval", ")", "{", "SimpleScheduleBuilder", "simpleScheduleBuilder", "=", "null", ";", "simpleScheduleBuilder", "=", "SimpleScheduleBuilder", ".", "simpleSchedule", "(", ")", ";", ...
Gets the simple trigger. @param timeUnit the time unit @param timeInterval the time interval @return the simple trigger
[ "Gets", "the", "simple", "trigger", "." ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.impl/src/main/java/net/dempsy/output/OutputQuartzHelper.java#L62-L87
train
Dempsy/dempsy
dempsy-framework.impl/src/main/java/net/dempsy/output/OutputQuartzHelper.java
OutputQuartzHelper.getCronTrigger
public Trigger getCronTrigger(String cronExpression) { CronScheduleBuilder cronScheduleBuilder = null; Trigger cronTrigger = null; try { cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression); cronScheduleBuilder.withMisfireHandlingInstructionFireAndProceed(); TriggerBuilder<Trigger> cronTtriggerBuilder = TriggerBuilder.newTrigger(); cronTtriggerBuilder.withSchedule(cronScheduleBuilder); cronTrigger = cronTtriggerBuilder.build(); } catch (Exception pe) { logger.error("Error occurred while builiding the cronTrigger : " + pe.getMessage(), pe); } return cronTrigger; }
java
public Trigger getCronTrigger(String cronExpression) { CronScheduleBuilder cronScheduleBuilder = null; Trigger cronTrigger = null; try { cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression); cronScheduleBuilder.withMisfireHandlingInstructionFireAndProceed(); TriggerBuilder<Trigger> cronTtriggerBuilder = TriggerBuilder.newTrigger(); cronTtriggerBuilder.withSchedule(cronScheduleBuilder); cronTrigger = cronTtriggerBuilder.build(); } catch (Exception pe) { logger.error("Error occurred while builiding the cronTrigger : " + pe.getMessage(), pe); } return cronTrigger; }
[ "public", "Trigger", "getCronTrigger", "(", "String", "cronExpression", ")", "{", "CronScheduleBuilder", "cronScheduleBuilder", "=", "null", ";", "Trigger", "cronTrigger", "=", "null", ";", "try", "{", "cronScheduleBuilder", "=", "CronScheduleBuilder", ".", "cronSched...
Gets the cron trigger. @param cronExpression the cron expression @return the cron trigger
[ "Gets", "the", "cron", "trigger", "." ]
cd3415b51b6787a6a9d9589b15f00ce674b6f113
https://github.com/Dempsy/dempsy/blob/cd3415b51b6787a6a9d9589b15f00ce674b6f113/dempsy-framework.impl/src/main/java/net/dempsy/output/OutputQuartzHelper.java#L95-L108
train
lukas-krecan/future-converter
guava-common/src/main/java/net/javacrumbs/futureconverter/guavacommon/GuavaFutureUtils.java
GuavaFutureUtils.createListenableFuture
public static <T> ListenableFuture<T> createListenableFuture(ValueSourceFuture<T> valueSourceFuture) { if (valueSourceFuture instanceof ListenableFutureBackedValueSourceFuture) { return ((ListenableFutureBackedValueSourceFuture<T>) valueSourceFuture).getWrappedFuture(); } else { return new ValueSourceFutureBackedListenableFuture<>(valueSourceFuture); } }
java
public static <T> ListenableFuture<T> createListenableFuture(ValueSourceFuture<T> valueSourceFuture) { if (valueSourceFuture instanceof ListenableFutureBackedValueSourceFuture) { return ((ListenableFutureBackedValueSourceFuture<T>) valueSourceFuture).getWrappedFuture(); } else { return new ValueSourceFutureBackedListenableFuture<>(valueSourceFuture); } }
[ "public", "static", "<", "T", ">", "ListenableFuture", "<", "T", ">", "createListenableFuture", "(", "ValueSourceFuture", "<", "T", ">", "valueSourceFuture", ")", "{", "if", "(", "valueSourceFuture", "instanceof", "ListenableFutureBackedValueSourceFuture", ")", "{", ...
Creates listenable future from ValueSourceFuture. We have to send all Future API calls to ValueSourceFuture.
[ "Creates", "listenable", "future", "from", "ValueSourceFuture", ".", "We", "have", "to", "send", "all", "Future", "API", "calls", "to", "ValueSourceFuture", "." ]
652b845824de90b075cf5ddbbda6fdf440f3ed0a
https://github.com/lukas-krecan/future-converter/blob/652b845824de90b075cf5ddbbda6fdf440f3ed0a/guava-common/src/main/java/net/javacrumbs/futureconverter/guavacommon/GuavaFutureUtils.java#L36-L42
train
lukas-krecan/future-converter
apifuture-common/src/main/java/net/javacrumbs/futureconverter/apifuturecommon/ApiFutureUtils.java
ApiFutureUtils.createApiFuture
public static <T> ApiFuture<T> createApiFuture(ValueSourceFuture<T> valueSourceFuture) { if (valueSourceFuture instanceof ApiFutureBackedValueSourceFuture) { return ((ApiFutureBackedValueSourceFuture<T>) valueSourceFuture).getWrappedFuture(); } else { return new ValueSourceFutureBackedApiFuture<>(valueSourceFuture); } }
java
public static <T> ApiFuture<T> createApiFuture(ValueSourceFuture<T> valueSourceFuture) { if (valueSourceFuture instanceof ApiFutureBackedValueSourceFuture) { return ((ApiFutureBackedValueSourceFuture<T>) valueSourceFuture).getWrappedFuture(); } else { return new ValueSourceFutureBackedApiFuture<>(valueSourceFuture); } }
[ "public", "static", "<", "T", ">", "ApiFuture", "<", "T", ">", "createApiFuture", "(", "ValueSourceFuture", "<", "T", ">", "valueSourceFuture", ")", "{", "if", "(", "valueSourceFuture", "instanceof", "ApiFutureBackedValueSourceFuture", ")", "{", "return", "(", "...
Creates api future from ValueSourceFuture. We have to send all Future API calls to ValueSourceFuture.
[ "Creates", "api", "future", "from", "ValueSourceFuture", ".", "We", "have", "to", "send", "all", "Future", "API", "calls", "to", "ValueSourceFuture", "." ]
652b845824de90b075cf5ddbbda6fdf440f3ed0a
https://github.com/lukas-krecan/future-converter/blob/652b845824de90b075cf5ddbbda6fdf440f3ed0a/apifuture-common/src/main/java/net/javacrumbs/futureconverter/apifuturecommon/ApiFutureUtils.java#L36-L42
train
sebastiangraf/treetank
coremodules/node/src/main/java/org/treetank/axis/PrecedingAxis.java
PrecedingAxis.getLastChild
private void getLastChild() { // nodekey of the root of the current subtree final long parent = getNode().getDataKey(); // traverse tree in pre order to the leftmost leaf of the subtree and // push // all nodes to the stack if (((ITreeStructData)getNode()).hasFirstChild()) { while (((ITreeStructData)getNode()).hasFirstChild()) { mStack.push(getNode().getDataKey()); moveTo(((ITreeStructData)getNode()).getFirstChildKey()); } // traverse all the siblings of the leftmost leave and all their // descendants and push all of them to the stack while (((ITreeStructData)getNode()).hasRightSibling()) { mStack.push(getNode().getDataKey()); moveTo(((ITreeStructData)getNode()).getRightSiblingKey()); getLastChild(); } // step up the path till the root of the current subtree and process // all // right siblings and their descendants on each step if (getNode().hasParent() && (getNode().getParentKey() != parent)) { mStack.push(getNode().getDataKey()); while (getNode().hasParent() && (getNode().getParentKey() != parent)) { moveTo(getNode().getParentKey()); // traverse all the siblings of the leftmost leave and all // their // descendants and push all of them to the stack while (((ITreeStructData)getNode()).hasRightSibling()) { moveTo(((ITreeStructData)getNode()).getRightSiblingKey()); getLastChild(); mStack.push(getNode().getDataKey()); } } // set transaction to the node in the subtree that is last in // document // order moveTo(mStack.pop()); } } }
java
private void getLastChild() { // nodekey of the root of the current subtree final long parent = getNode().getDataKey(); // traverse tree in pre order to the leftmost leaf of the subtree and // push // all nodes to the stack if (((ITreeStructData)getNode()).hasFirstChild()) { while (((ITreeStructData)getNode()).hasFirstChild()) { mStack.push(getNode().getDataKey()); moveTo(((ITreeStructData)getNode()).getFirstChildKey()); } // traverse all the siblings of the leftmost leave and all their // descendants and push all of them to the stack while (((ITreeStructData)getNode()).hasRightSibling()) { mStack.push(getNode().getDataKey()); moveTo(((ITreeStructData)getNode()).getRightSiblingKey()); getLastChild(); } // step up the path till the root of the current subtree and process // all // right siblings and their descendants on each step if (getNode().hasParent() && (getNode().getParentKey() != parent)) { mStack.push(getNode().getDataKey()); while (getNode().hasParent() && (getNode().getParentKey() != parent)) { moveTo(getNode().getParentKey()); // traverse all the siblings of the leftmost leave and all // their // descendants and push all of them to the stack while (((ITreeStructData)getNode()).hasRightSibling()) { moveTo(((ITreeStructData)getNode()).getRightSiblingKey()); getLastChild(); mStack.push(getNode().getDataKey()); } } // set transaction to the node in the subtree that is last in // document // order moveTo(mStack.pop()); } } }
[ "private", "void", "getLastChild", "(", ")", "{", "// nodekey of the root of the current subtree", "final", "long", "parent", "=", "getNode", "(", ")", ".", "getDataKey", "(", ")", ";", "// traverse tree in pre order to the leftmost leaf of the subtree and", "// push", "// ...
Moves the transaction to the node in the current subtree, that is last in document order and pushes all other node key on a stack. At the end the stack contains all node keys except for the last one in reverse document order.
[ "Moves", "the", "transaction", "to", "the", "node", "in", "the", "current", "subtree", "that", "is", "last", "in", "document", "order", "and", "pushes", "all", "other", "node", "key", "on", "a", "stack", ".", "At", "the", "end", "the", "stack", "contains...
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/node/src/main/java/org/treetank/axis/PrecedingAxis.java#L134-L183
train
sebastiangraf/treetank
interfacemodules/jax-rx/src/main/java/org/jaxrx/core/Systems.java
Systems.getInstance
public static JaxRx getInstance(final String impl) { final String path = Systems.getSystems().get(impl); if (path == null) { throw new JaxRxException(404, "Unknown implementation: " + impl); } JaxRx jaxrx = INSTANCES.get(path); if (jaxrx == null) { try { jaxrx = (JaxRx)Class.forName(path).newInstance(); INSTANCES.put(path, jaxrx); } catch (final Exception ex) { throw new JaxRxException(ex); } } return jaxrx; }
java
public static JaxRx getInstance(final String impl) { final String path = Systems.getSystems().get(impl); if (path == null) { throw new JaxRxException(404, "Unknown implementation: " + impl); } JaxRx jaxrx = INSTANCES.get(path); if (jaxrx == null) { try { jaxrx = (JaxRx)Class.forName(path).newInstance(); INSTANCES.put(path, jaxrx); } catch (final Exception ex) { throw new JaxRxException(ex); } } return jaxrx; }
[ "public", "static", "JaxRx", "getInstance", "(", "final", "String", "impl", ")", "{", "final", "String", "path", "=", "Systems", ".", "getSystems", "(", ")", ".", "get", "(", "impl", ")", ";", "if", "(", "path", "==", "null", ")", "{", "throw", "new"...
Returns the instance for the specified implementation. If the system is unknown, throws an exception. @param impl implementation to be checked. @return instances
[ "Returns", "the", "instance", "for", "the", "specified", "implementation", ".", "If", "the", "system", "is", "unknown", "throws", "an", "exception", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/jaxrx/core/Systems.java#L134-L150
train
Bedework/bw-util
bw-util-xml/src/main/java/org/bedework/util/xml/NsContext.java
NsContext.add
public void add(final String prefix, final String uri) { if (prefix == null) { defaultNS = uri; } addToMap(prefix, uri); }
java
public void add(final String prefix, final String uri) { if (prefix == null) { defaultNS = uri; } addToMap(prefix, uri); }
[ "public", "void", "add", "(", "final", "String", "prefix", ",", "final", "String", "uri", ")", "{", "if", "(", "prefix", "==", "null", ")", "{", "defaultNS", "=", "uri", ";", "}", "addToMap", "(", "prefix", ",", "uri", ")", ";", "}" ]
Add a namespace to the maps @param prefix the prefix for generated xml @param uri the namespace uri
[ "Add", "a", "namespace", "to", "the", "maps" ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-xml/src/main/java/org/bedework/util/xml/NsContext.java#L123-L129
train
Bedework/bw-util
bw-util-xml/src/main/java/org/bedework/util/xml/NsContext.java
NsContext.appendNsName
public void appendNsName(final StringBuilder sb, final QName nm) { String uri = nm.getNamespaceURI(); String abbr; if ((defaultNS != null) && uri.equals(defaultNS)) { abbr = null; } else { abbr = keyUri.get(uri); if (abbr == null) { abbr = uri; } } if (abbr != null) { sb.append(abbr); sb.append(":"); } sb.append(nm.getLocalPart()); }
java
public void appendNsName(final StringBuilder sb, final QName nm) { String uri = nm.getNamespaceURI(); String abbr; if ((defaultNS != null) && uri.equals(defaultNS)) { abbr = null; } else { abbr = keyUri.get(uri); if (abbr == null) { abbr = uri; } } if (abbr != null) { sb.append(abbr); sb.append(":"); } sb.append(nm.getLocalPart()); }
[ "public", "void", "appendNsName", "(", "final", "StringBuilder", "sb", ",", "final", "QName", "nm", ")", "{", "String", "uri", "=", "nm", ".", "getNamespaceURI", "(", ")", ";", "String", "abbr", ";", "if", "(", "(", "defaultNS", "!=", "null", ")", "&&"...
Append the name with abbreviated namespace. @param sb for result @param nm QName object
[ "Append", "the", "name", "with", "abbreviated", "namespace", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-xml/src/main/java/org/bedework/util/xml/NsContext.java#L144-L164
train
Bedework/bw-util
bw-util-security/src/main/java/org/bedework/util/security/PasswordGenerator.java
PasswordGenerator.generate
public static String generate(final int length) { final StringBuilder password = new StringBuilder(length); double pik = random.nextDouble(); // random number [0,1] long ranno = (long) (pik * sigma); // weight by sum of frequencies long sum = 0; outer: for (int c1 = 0; c1 < 26; c1++) { for (int c2 = 0; c2 < 26; c2++) { for (int c3 = 0; c3 < 26; c3++) { sum += get(c1, c2, c3); if (sum > ranno) { password.append(alphabet.charAt(c1)); password.append(alphabet.charAt(c2)); password.append(alphabet.charAt(c3)); break outer; // Found start. } } } } // Now do a random walk. int nchar = 3; while (nchar < length) { final int c1 = alphabet.indexOf(password.charAt(nchar - 2)); final int c2 = alphabet.indexOf(password.charAt(nchar - 1)); sum = 0; for (int c3 = 0; c3 < 26; c3++) { sum += get(c1, c2, c3); } if (sum == 0) { break; } pik = random.nextDouble(); ranno = (long) (pik * sum); sum = 0; for (int c3 = 0; c3 < 26; c3++) { sum += get(c1, c2, c3); if (sum > ranno) { password.append(alphabet.charAt(c3)); break; } } nchar++; } return password.toString(); }
java
public static String generate(final int length) { final StringBuilder password = new StringBuilder(length); double pik = random.nextDouble(); // random number [0,1] long ranno = (long) (pik * sigma); // weight by sum of frequencies long sum = 0; outer: for (int c1 = 0; c1 < 26; c1++) { for (int c2 = 0; c2 < 26; c2++) { for (int c3 = 0; c3 < 26; c3++) { sum += get(c1, c2, c3); if (sum > ranno) { password.append(alphabet.charAt(c1)); password.append(alphabet.charAt(c2)); password.append(alphabet.charAt(c3)); break outer; // Found start. } } } } // Now do a random walk. int nchar = 3; while (nchar < length) { final int c1 = alphabet.indexOf(password.charAt(nchar - 2)); final int c2 = alphabet.indexOf(password.charAt(nchar - 1)); sum = 0; for (int c3 = 0; c3 < 26; c3++) { sum += get(c1, c2, c3); } if (sum == 0) { break; } pik = random.nextDouble(); ranno = (long) (pik * sum); sum = 0; for (int c3 = 0; c3 < 26; c3++) { sum += get(c1, c2, c3); if (sum > ranno) { password.append(alphabet.charAt(c3)); break; } } nchar++; } return password.toString(); }
[ "public", "static", "String", "generate", "(", "final", "int", "length", ")", "{", "final", "StringBuilder", "password", "=", "new", "StringBuilder", "(", "length", ")", ";", "double", "pik", "=", "random", ".", "nextDouble", "(", ")", ";", "// random number...
Generates a new password. @param length Length the password should have @return The new password
[ "Generates", "a", "new", "password", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-security/src/main/java/org/bedework/util/security/PasswordGenerator.java#L49-L98
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathParser.java
XPathParser.parseQuery
public void parseQuery() throws TTXPathException { // get first token, ignore all white spaces do { mToken = mScanner.nextToken(); } while (mToken.getType() == TokenType.SPACE); // parse the query according to the rules specified in the XPath 2.0 REC parseExpression(); // after the parsing of the expression no token must be left if (mToken.getType() != TokenType.END) { throw new IllegalStateException("The query has not been processed completely."); } }
java
public void parseQuery() throws TTXPathException { // get first token, ignore all white spaces do { mToken = mScanner.nextToken(); } while (mToken.getType() == TokenType.SPACE); // parse the query according to the rules specified in the XPath 2.0 REC parseExpression(); // after the parsing of the expression no token must be left if (mToken.getType() != TokenType.END) { throw new IllegalStateException("The query has not been processed completely."); } }
[ "public", "void", "parseQuery", "(", ")", "throws", "TTXPathException", "{", "// get first token, ignore all white spaces", "do", "{", "mToken", "=", "mScanner", ".", "nextToken", "(", ")", ";", "}", "while", "(", "mToken", ".", "getType", "(", ")", "==", "Tok...
Starts parsing the query. @throws TTXPathException
[ "Starts", "parsing", "the", "query", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathParser.java#L118-L132
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathParser.java
XPathParser.isReservedKeyword
private boolean isReservedKeyword() { final String content = mToken.getContent(); return isKindTest() || "item".equals(content) || "if".equals(content) || "empty-sequence".equals(content) || "typeswitch".equals(content); }
java
private boolean isReservedKeyword() { final String content = mToken.getContent(); return isKindTest() || "item".equals(content) || "if".equals(content) || "empty-sequence".equals(content) || "typeswitch".equals(content); }
[ "private", "boolean", "isReservedKeyword", "(", ")", "{", "final", "String", "content", "=", "mToken", ".", "getContent", "(", ")", ";", "return", "isKindTest", "(", ")", "||", "\"item\"", ".", "equals", "(", "content", ")", "||", "\"if\"", ".", "equals", ...
Although XPath is supposed to have no reserved words, some keywords are not allowed as function names in an unprefixed form because expression syntax takes precedence. @return true if the token is one of the reserved words of XPath 2.0
[ "Although", "XPath", "is", "supposed", "to", "have", "no", "reserved", "words", "some", "keywords", "are", "not", "allowed", "as", "function", "names", "in", "an", "unprefixed", "form", "because", "expression", "syntax", "takes", "precedence", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathParser.java#L791-L796
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathParser.java
XPathParser.isForwardAxis
private boolean isForwardAxis() { final String content = mToken.getContent(); return (mToken.getType() == TokenType.TEXT && ("child".equals(content) || ("descendant" .equals(content) || "descendant-or-self".equals(content) || "attribute".equals(content) || "self".equals(content) || "following".equals(content) || "following-sibling".equals(content) || "namespace" .equals(content)))); }
java
private boolean isForwardAxis() { final String content = mToken.getContent(); return (mToken.getType() == TokenType.TEXT && ("child".equals(content) || ("descendant" .equals(content) || "descendant-or-self".equals(content) || "attribute".equals(content) || "self".equals(content) || "following".equals(content) || "following-sibling".equals(content) || "namespace" .equals(content)))); }
[ "private", "boolean", "isForwardAxis", "(", ")", "{", "final", "String", "content", "=", "mToken", ".", "getContent", "(", ")", ";", "return", "(", "mToken", ".", "getType", "(", ")", "==", "TokenType", ".", "TEXT", "&&", "(", "\"child\"", ".", "equals",...
Checks if a given token represents a ForwardAxis. @return true if the token is a ForwardAxis
[ "Checks", "if", "a", "given", "token", "represents", "a", "ForwardAxis", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathParser.java#L900-L910
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathParser.java
XPathParser.consume
private void consume(final TokenType mType, final boolean mIgnoreWhitespace) { if (!is(mType, mIgnoreWhitespace)) { // error found by parser - stopping throw new IllegalStateException("Wrong token after " + mScanner.begin() + " at position " + mScanner.getPos() + " found " + mToken.getType() + " expected " + mType + "."); } }
java
private void consume(final TokenType mType, final boolean mIgnoreWhitespace) { if (!is(mType, mIgnoreWhitespace)) { // error found by parser - stopping throw new IllegalStateException("Wrong token after " + mScanner.begin() + " at position " + mScanner.getPos() + " found " + mToken.getType() + " expected " + mType + "."); } }
[ "private", "void", "consume", "(", "final", "TokenType", "mType", ",", "final", "boolean", "mIgnoreWhitespace", ")", "{", "if", "(", "!", "is", "(", "mType", ",", "mIgnoreWhitespace", ")", ")", "{", "// error found by parser - stopping", "throw", "new", "Illegal...
Consumes a token. Tests if it really has the expected type and if not returns an error message. Otherwise gets a new token from the scanner. If that new token is of type whitespace and the ignoreWhitespace parameter is true, a new token is retrieved, until the current token is not of type whitespace. @param mType the specified token type @param mIgnoreWhitespace if true all new tokens with type whitespace are ignored and the next token is retrieved from the scanner
[ "Consumes", "a", "token", ".", "Tests", "if", "it", "really", "has", "the", "expected", "type", "and", "if", "not", "returns", "an", "error", "message", ".", "Otherwise", "gets", "a", "new", "token", "from", "the", "scanner", ".", "If", "that", "new", ...
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathParser.java#L2097-L2104
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathParser.java
XPathParser.consume
private void consume(final String mName, final boolean mIgnoreWhitespace) { if (!is(mName, mIgnoreWhitespace)) { // error found by parser - stopping throw new IllegalStateException("Wrong token after " + mScanner.begin() + " found " + mToken.getContent() + ". Expected " + mName); } }
java
private void consume(final String mName, final boolean mIgnoreWhitespace) { if (!is(mName, mIgnoreWhitespace)) { // error found by parser - stopping throw new IllegalStateException("Wrong token after " + mScanner.begin() + " found " + mToken.getContent() + ". Expected " + mName); } }
[ "private", "void", "consume", "(", "final", "String", "mName", ",", "final", "boolean", "mIgnoreWhitespace", ")", "{", "if", "(", "!", "is", "(", "mName", ",", "mIgnoreWhitespace", ")", ")", "{", "// error found by parser - stopping", "throw", "new", "IllegalSta...
Consumes a token. Tests if it really has the expected name and if not returns an error message. Otherwise gets a new token from the scanner. If that new token is of type whitespace and the ignoreWhitespace parameter is true, a new token is retrieved, until the current token is not of type whitespace. @param mName the specified token content @param mIgnoreWhitespace if true all new tokens with type whitespace are ignored and the next token is retrieved from the scanner
[ "Consumes", "a", "token", ".", "Tests", "if", "it", "really", "has", "the", "expected", "name", "and", "if", "not", "returns", "an", "error", "message", ".", "Otherwise", "gets", "a", "new", "token", "from", "the", "scanner", ".", "If", "that", "new", ...
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathParser.java#L2119-L2126
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathParser.java
XPathParser.is
private boolean is(final String mName, final boolean mIgnoreWhitespace) { if (!mName.equals(mToken.getContent())) { return false; } if (mToken.getType() == TokenType.COMP || mToken.getType() == TokenType.EQ || mToken.getType() == TokenType.N_EQ || mToken.getType() == TokenType.PLUS || mToken.getType() == TokenType.MINUS || mToken.getType() == TokenType.STAR) { return is(mToken.getType(), mIgnoreWhitespace); } else { return is(TokenType.TEXT, mIgnoreWhitespace); } }
java
private boolean is(final String mName, final boolean mIgnoreWhitespace) { if (!mName.equals(mToken.getContent())) { return false; } if (mToken.getType() == TokenType.COMP || mToken.getType() == TokenType.EQ || mToken.getType() == TokenType.N_EQ || mToken.getType() == TokenType.PLUS || mToken.getType() == TokenType.MINUS || mToken.getType() == TokenType.STAR) { return is(mToken.getType(), mIgnoreWhitespace); } else { return is(TokenType.TEXT, mIgnoreWhitespace); } }
[ "private", "boolean", "is", "(", "final", "String", "mName", ",", "final", "boolean", "mIgnoreWhitespace", ")", "{", "if", "(", "!", "mName", ".", "equals", "(", "mToken", ".", "getContent", "(", ")", ")", ")", "{", "return", "false", ";", "}", "if", ...
Returns true or false if a token has the expected name. If the token has the given name, it gets a new token from the scanner. If that new token is of type whitespace and the ignoreWhitespace parameter is true, a new token is retrieved, until the current token is not of type whitespace. @param mName the specified token content @param mIgnoreWhitespace if true all new tokens with type whitespace are ignored and the next token is retrieved from the scanner @return is
[ "Returns", "true", "or", "false", "if", "a", "token", "has", "the", "expected", "name", ".", "If", "the", "token", "has", "the", "given", "name", "it", "gets", "a", "new", "token", "from", "the", "scanner", ".", "If", "that", "new", "token", "is", "o...
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathParser.java#L2141-L2154
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathParser.java
XPathParser.is
private boolean is(final TokenType mType, final boolean mIgnoreWhitespace) { if (mType != mToken.getType()) { return false; } do { // scan next token mToken = mScanner.nextToken(); } while (mIgnoreWhitespace && mToken.getType() == TokenType.SPACE); return true; }
java
private boolean is(final TokenType mType, final boolean mIgnoreWhitespace) { if (mType != mToken.getType()) { return false; } do { // scan next token mToken = mScanner.nextToken(); } while (mIgnoreWhitespace && mToken.getType() == TokenType.SPACE); return true; }
[ "private", "boolean", "is", "(", "final", "TokenType", "mType", ",", "final", "boolean", "mIgnoreWhitespace", ")", "{", "if", "(", "mType", "!=", "mToken", ".", "getType", "(", ")", ")", "{", "return", "false", ";", "}", "do", "{", "// scan next token", ...
Returns true or false if a token has the expected type. If so, a new token is retrieved from the scanner. If that new token is of type whitespace and the ignoreWhitespace parameter is true, a new token is retrieved, until the current token is not of type whitespace. @param mType the specified token content @param mIgnoreWhitespace if true all new tokens with type whitespace are ignored and the next token is retrieved from the scanner @return is
[ "Returns", "true", "or", "false", "if", "a", "token", "has", "the", "expected", "type", ".", "If", "so", "a", "new", "token", "is", "retrieved", "from", "the", "scanner", ".", "If", "that", "new", "token", "is", "of", "type", "whitespace", "and", "the"...
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathParser.java#L2169-L2182
train
Bedework/bw-util
bw-util-elasticsearch/src/main/java/org/bedework/util/elasticsearch/EsUtil.java
EsUtil.newIndex
public String newIndex(final String name, final String mappingPath) throws IndexException { try { final String newName = name + newIndexSuffix(); final IndicesAdminClient idx = getAdminIdx(); final CreateIndexRequestBuilder cirb = idx.prepareCreate(newName); final File f = new File(mappingPath); final byte[] sbBytes = Streams.copyToByteArray(f); cirb.setSource(sbBytes); final CreateIndexRequest cir = cirb.request(); final ActionFuture<CreateIndexResponse> af = idx.create(cir); /*resp = */af.actionGet(); //index(new UpdateInfo()); info("Index created"); return newName; } catch (final ElasticsearchException ese) { // Failed somehow error(ese); return null; } catch (final IndexException ie) { throw ie; } catch (final Throwable t) { error(t); throw new IndexException(t); } }
java
public String newIndex(final String name, final String mappingPath) throws IndexException { try { final String newName = name + newIndexSuffix(); final IndicesAdminClient idx = getAdminIdx(); final CreateIndexRequestBuilder cirb = idx.prepareCreate(newName); final File f = new File(mappingPath); final byte[] sbBytes = Streams.copyToByteArray(f); cirb.setSource(sbBytes); final CreateIndexRequest cir = cirb.request(); final ActionFuture<CreateIndexResponse> af = idx.create(cir); /*resp = */af.actionGet(); //index(new UpdateInfo()); info("Index created"); return newName; } catch (final ElasticsearchException ese) { // Failed somehow error(ese); return null; } catch (final IndexException ie) { throw ie; } catch (final Throwable t) { error(t); throw new IndexException(t); } }
[ "public", "String", "newIndex", "(", "final", "String", "name", ",", "final", "String", "mappingPath", ")", "throws", "IndexException", "{", "try", "{", "final", "String", "newName", "=", "name", "+", "newIndexSuffix", "(", ")", ";", "final", "IndicesAdminClie...
create a new index and return its name. No alias will point to the new index. @param name basis for new name @param mappingPath path to mapping file. @return name of created index. @throws IndexException for errors
[ "create", "a", "new", "index", "and", "return", "its", "name", ".", "No", "alias", "will", "point", "to", "the", "new", "index", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-elasticsearch/src/main/java/org/bedework/util/elasticsearch/EsUtil.java#L315-L351
train
Bedework/bw-util
bw-util-elasticsearch/src/main/java/org/bedework/util/elasticsearch/EsUtil.java
EsUtil.purgeIndexes
public List<String> purgeIndexes(final Set<String> prefixes) throws IndexException { final Set<IndexInfo> indexes = getIndexInfo(); final List<String> purged = new ArrayList<>(); if (Util.isEmpty(indexes)) { return purged; } purge: for (final IndexInfo ii: indexes) { final String idx = ii.getIndexName(); if (!hasPrefix(idx, prefixes)) { continue purge; } /* Don't delete those pointed to by any aliases */ if (!Util.isEmpty(ii.getAliases())) { continue purge; } purged.add(idx); } deleteIndexes(purged); return purged; }
java
public List<String> purgeIndexes(final Set<String> prefixes) throws IndexException { final Set<IndexInfo> indexes = getIndexInfo(); final List<String> purged = new ArrayList<>(); if (Util.isEmpty(indexes)) { return purged; } purge: for (final IndexInfo ii: indexes) { final String idx = ii.getIndexName(); if (!hasPrefix(idx, prefixes)) { continue purge; } /* Don't delete those pointed to by any aliases */ if (!Util.isEmpty(ii.getAliases())) { continue purge; } purged.add(idx); } deleteIndexes(purged); return purged; }
[ "public", "List", "<", "String", ">", "purgeIndexes", "(", "final", "Set", "<", "String", ">", "prefixes", ")", "throws", "IndexException", "{", "final", "Set", "<", "IndexInfo", ">", "indexes", "=", "getIndexInfo", "(", ")", ";", "final", "List", "<", "...
Remove any index that doesn't have an alias and starts with the given prefix @param prefixes Ignore indexes that have names that don't start with any of these @return list of purged indexes @throws IndexException
[ "Remove", "any", "index", "that", "doesn", "t", "have", "an", "alias", "and", "starts", "with", "the", "given", "prefix" ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-elasticsearch/src/main/java/org/bedework/util/elasticsearch/EsUtil.java#L398-L427
train
Bedework/bw-util
bw-util-elasticsearch/src/main/java/org/bedework/util/elasticsearch/EsUtil.java
EsUtil.swapIndex
public int swapIndex(final String index, final String alias) throws IndexException { //IndicesAliasesResponse resp = null; try { /* index is the index we were just indexing into */ final IndicesAdminClient idx = getAdminIdx(); final GetAliasesRequestBuilder igarb = idx.prepareGetAliases( alias); final ActionFuture<GetAliasesResponse> getAliasesAf = idx.getAliases(igarb.request()); final GetAliasesResponse garesp = getAliasesAf.actionGet(); final ImmutableOpenMap<String, List<AliasMetaData>> aliasesmeta = garesp.getAliases(); final IndicesAliasesRequestBuilder iarb = idx.prepareAliases(); final Iterator<String> it = aliasesmeta.keysIt(); while (it.hasNext()) { final String indexName = it.next(); for (final AliasMetaData amd: aliasesmeta.get(indexName)) { if(amd.getAlias().equals(alias)) { iarb.removeAlias(indexName, alias); } } } iarb.addAlias(index, alias); final ActionFuture<IndicesAliasesResponse> af = idx.aliases(iarb.request()); /*resp = */af.actionGet(); return 0; } catch (final ElasticsearchException ese) { // Failed somehow error(ese); return -1; } catch (final IndexException ie) { throw ie; } catch (final Throwable t) { throw new IndexException(t); } }
java
public int swapIndex(final String index, final String alias) throws IndexException { //IndicesAliasesResponse resp = null; try { /* index is the index we were just indexing into */ final IndicesAdminClient idx = getAdminIdx(); final GetAliasesRequestBuilder igarb = idx.prepareGetAliases( alias); final ActionFuture<GetAliasesResponse> getAliasesAf = idx.getAliases(igarb.request()); final GetAliasesResponse garesp = getAliasesAf.actionGet(); final ImmutableOpenMap<String, List<AliasMetaData>> aliasesmeta = garesp.getAliases(); final IndicesAliasesRequestBuilder iarb = idx.prepareAliases(); final Iterator<String> it = aliasesmeta.keysIt(); while (it.hasNext()) { final String indexName = it.next(); for (final AliasMetaData amd: aliasesmeta.get(indexName)) { if(amd.getAlias().equals(alias)) { iarb.removeAlias(indexName, alias); } } } iarb.addAlias(index, alias); final ActionFuture<IndicesAliasesResponse> af = idx.aliases(iarb.request()); /*resp = */af.actionGet(); return 0; } catch (final ElasticsearchException ese) { // Failed somehow error(ese); return -1; } catch (final IndexException ie) { throw ie; } catch (final Throwable t) { throw new IndexException(t); } }
[ "public", "int", "swapIndex", "(", "final", "String", "index", ",", "final", "String", "alias", ")", "throws", "IndexException", "{", "//IndicesAliasesResponse resp = null;", "try", "{", "/* index is the index we were just indexing into\n */", "final", "IndicesAdminClie...
Changes the givenm alias to refer tot eh supplied index name @param index the index we were building @param alias to refer to this index @return 0 fir ok <0 for not ok @throws IndexException
[ "Changes", "the", "givenm", "alias", "to", "refer", "tot", "eh", "supplied", "index", "name" ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-elasticsearch/src/main/java/org/bedework/util/elasticsearch/EsUtil.java#L436-L486
train
Bedework/bw-util
bw-util-dav/src/main/java/org/bedework/util/dav/DavUtil.java
DavUtil.syncReport
public Collection<DavChild> syncReport(final BasicHttpClient cl, final String path, final String syncToken, final Collection<QName> props) throws Throwable { final StringWriter sw = new StringWriter(); final XmlEmit xml = getXml(); addNs(xml, WebdavTags.namespace); xml.startEmit(sw); /* <?xml version="1.0" encoding="utf-8" ?> <D:sync-collection xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav"> <D:sync-token/> <D:prop> <D:getetag/> </D:prop> </D:sync-collection> */ xml.openTag(WebdavTags.syncCollection); if (syncToken == null) { xml.emptyTag(WebdavTags.syncToken); } else { xml.property(WebdavTags.syncToken, syncToken); } xml.property(WebdavTags.synclevel, "1"); xml.openTag(WebdavTags.prop); xml.emptyTag(WebdavTags.getetag); if (props != null) { for (final QName pr: props) { if (pr.equals(WebdavTags.getetag)) { continue; } addNs(xml, pr.getNamespaceURI()); xml.emptyTag(pr); } } xml.closeTag(WebdavTags.prop); xml.closeTag(WebdavTags.syncCollection); final byte[] content = sw.toString().getBytes(); final int res = sendRequest(cl, "REPORT", path, depth0, "text/xml", // contentType, content.length, // contentLen, content); if (res == HttpServletResponse.SC_NOT_FOUND) { return null; } final int SC_MULTI_STATUS = 207; // not defined for some reason if (res != SC_MULTI_STATUS) { if (debug()) { debug("Got response " + res + " for path " + path); } //throw new Exception("Got response " + res + " for path " + path); return null; } final Document doc = parseContent(cl.getResponseBodyAsStream()); final Element root = doc.getDocumentElement(); /* <!ELEMENT multistatus (response+, responsedescription?) > */ expect(root, WebdavTags.multistatus); return processResponses(getChildren(root), null); }
java
public Collection<DavChild> syncReport(final BasicHttpClient cl, final String path, final String syncToken, final Collection<QName> props) throws Throwable { final StringWriter sw = new StringWriter(); final XmlEmit xml = getXml(); addNs(xml, WebdavTags.namespace); xml.startEmit(sw); /* <?xml version="1.0" encoding="utf-8" ?> <D:sync-collection xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav"> <D:sync-token/> <D:prop> <D:getetag/> </D:prop> </D:sync-collection> */ xml.openTag(WebdavTags.syncCollection); if (syncToken == null) { xml.emptyTag(WebdavTags.syncToken); } else { xml.property(WebdavTags.syncToken, syncToken); } xml.property(WebdavTags.synclevel, "1"); xml.openTag(WebdavTags.prop); xml.emptyTag(WebdavTags.getetag); if (props != null) { for (final QName pr: props) { if (pr.equals(WebdavTags.getetag)) { continue; } addNs(xml, pr.getNamespaceURI()); xml.emptyTag(pr); } } xml.closeTag(WebdavTags.prop); xml.closeTag(WebdavTags.syncCollection); final byte[] content = sw.toString().getBytes(); final int res = sendRequest(cl, "REPORT", path, depth0, "text/xml", // contentType, content.length, // contentLen, content); if (res == HttpServletResponse.SC_NOT_FOUND) { return null; } final int SC_MULTI_STATUS = 207; // not defined for some reason if (res != SC_MULTI_STATUS) { if (debug()) { debug("Got response " + res + " for path " + path); } //throw new Exception("Got response " + res + " for path " + path); return null; } final Document doc = parseContent(cl.getResponseBodyAsStream()); final Element root = doc.getDocumentElement(); /* <!ELEMENT multistatus (response+, responsedescription?) > */ expect(root, WebdavTags.multistatus); return processResponses(getChildren(root), null); }
[ "public", "Collection", "<", "DavChild", ">", "syncReport", "(", "final", "BasicHttpClient", "cl", ",", "final", "String", "path", ",", "final", "String", "syncToken", ",", "final", "Collection", "<", "QName", ">", "props", ")", "throws", "Throwable", "{", "...
Do a synch report on the targeted collection. @param cl http client @param path of collection @param syncToken from last report or null @param props null for a default set @return Collection of DavChild or null for not found @throws Throwable
[ "Do", "a", "synch", "report", "on", "the", "targeted", "collection", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-dav/src/main/java/org/bedework/util/dav/DavUtil.java#L320-L396
train
Bedework/bw-util
bw-util-dav/src/main/java/org/bedework/util/dav/DavUtil.java
DavUtil.addNs
protected void addNs(final XmlEmit xml, final String val) throws Throwable { if (xml.getNameSpace(val) == null) { xml.addNs(new NameSpace(val, null), false); } }
java
protected void addNs(final XmlEmit xml, final String val) throws Throwable { if (xml.getNameSpace(val) == null) { xml.addNs(new NameSpace(val, null), false); } }
[ "protected", "void", "addNs", "(", "final", "XmlEmit", "xml", ",", "final", "String", "val", ")", "throws", "Throwable", "{", "if", "(", "xml", ".", "getNameSpace", "(", "val", ")", "==", "null", ")", "{", "xml", ".", "addNs", "(", "new", "NameSpace", ...
Add a namespace @param val @throws Throwable
[ "Add", "a", "namespace" ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-dav/src/main/java/org/bedework/util/dav/DavUtil.java#L571-L576
train
Bedework/bw-util
bw-util-dav/src/main/java/org/bedework/util/dav/DavUtil.java
DavUtil.parseContent
protected Document parseContent(final InputStream in) throws Throwable { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(new InputSource(new InputStreamReader(in))); }
java
protected Document parseContent(final InputStream in) throws Throwable { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(new InputSource(new InputStreamReader(in))); }
[ "protected", "Document", "parseContent", "(", "final", "InputStream", "in", ")", "throws", "Throwable", "{", "DocumentBuilderFactory", "factory", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ";", "factory", ".", "setNamespaceAware", "(", "true", ")",...
Parse the content, and return the DOM representation. @param in content as stream @return Document Parsed body or null for no body @exception Throwable Some error occurred.
[ "Parse", "the", "content", "and", "return", "the", "DOM", "representation", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-dav/src/main/java/org/bedework/util/dav/DavUtil.java#L584-L591
train
Bedework/bw-util
bw-util-dav/src/main/java/org/bedework/util/dav/DavUtil.java
DavUtil.parseError
public Element parseError(final InputStream in) { try { final Document doc = parseContent(in); final Element root = doc.getDocumentElement(); expect(root, WebdavTags.error); final List<Element> els = getChildren(root); if (els.size() != 1) { return null; } return els.get(0); } catch (final Throwable ignored) { return null; } }
java
public Element parseError(final InputStream in) { try { final Document doc = parseContent(in); final Element root = doc.getDocumentElement(); expect(root, WebdavTags.error); final List<Element> els = getChildren(root); if (els.size() != 1) { return null; } return els.get(0); } catch (final Throwable ignored) { return null; } }
[ "public", "Element", "parseError", "(", "final", "InputStream", "in", ")", "{", "try", "{", "final", "Document", "doc", "=", "parseContent", "(", "in", ")", ";", "final", "Element", "root", "=", "doc", ".", "getDocumentElement", "(", ")", ";", "expect", ...
Parse a DAV error response @param in response @return a single error element or null
[ "Parse", "a", "DAV", "error", "response" ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-dav/src/main/java/org/bedework/util/dav/DavUtil.java#L598-L616
train
sebastiangraf/treetank
interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/util/RESTResponseHelper.java
RESTResponseHelper.createResultElement
private static Element createResultElement(final Document document) { final Element ttResponse = document.createElementNS("http://jaxrx.org/", "result"); ttResponse.setPrefix("jaxrx"); return ttResponse; }
java
private static Element createResultElement(final Document document) { final Element ttResponse = document.createElementNS("http://jaxrx.org/", "result"); ttResponse.setPrefix("jaxrx"); return ttResponse; }
[ "private", "static", "Element", "createResultElement", "(", "final", "Document", "document", ")", "{", "final", "Element", "ttResponse", "=", "document", ".", "createElementNS", "(", "\"http://jaxrx.org/\"", ",", "\"result\"", ")", ";", "ttResponse", ".", "setPrefix...
This method creates the TreeTank response XML element. @param document The {@link Document} instance for the response. @return The created XML {@link Element}.
[ "This", "method", "creates", "the", "TreeTank", "response", "XML", "element", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/util/RESTResponseHelper.java#L92-L96
train
sebastiangraf/treetank
interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/util/RESTResponseHelper.java
RESTResponseHelper.buildResponseOfDomLR
public static StreamingOutput buildResponseOfDomLR(final IStorage pDatabase, final IBackendFactory pStorageFac, final IRevisioning pRevision) { final StreamingOutput sOutput = new StreamingOutput() { @Override public void write(final OutputStream output) throws IOException, WebApplicationException { Document document; try { document = createSurroundingXMLResp(); final Element resElement = RESTResponseHelper.createResultElement(document); List<Element> collections; try { collections = RESTResponseHelper.createCollectionElementDBs(pDatabase, document, pStorageFac, pRevision); } catch (final TTException exce) { throw new WebApplicationException(exce); } for (final Element resource : collections) { resElement.appendChild(resource); } document.appendChild(resElement); final DOMSource domSource = new DOMSource(document); final StreamResult streamResult = new StreamResult(output); final Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(domSource, streamResult); } catch (final ParserConfigurationException exce) { throw new WebApplicationException(exce); } catch (final TransformerConfigurationException exce) { throw new WebApplicationException(exce); } catch (final TransformerFactoryConfigurationError exce) { throw new WebApplicationException(exce); } catch (final TransformerException exce) { throw new WebApplicationException(exce); } } }; return sOutput; }
java
public static StreamingOutput buildResponseOfDomLR(final IStorage pDatabase, final IBackendFactory pStorageFac, final IRevisioning pRevision) { final StreamingOutput sOutput = new StreamingOutput() { @Override public void write(final OutputStream output) throws IOException, WebApplicationException { Document document; try { document = createSurroundingXMLResp(); final Element resElement = RESTResponseHelper.createResultElement(document); List<Element> collections; try { collections = RESTResponseHelper.createCollectionElementDBs(pDatabase, document, pStorageFac, pRevision); } catch (final TTException exce) { throw new WebApplicationException(exce); } for (final Element resource : collections) { resElement.appendChild(resource); } document.appendChild(resElement); final DOMSource domSource = new DOMSource(document); final StreamResult streamResult = new StreamResult(output); final Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(domSource, streamResult); } catch (final ParserConfigurationException exce) { throw new WebApplicationException(exce); } catch (final TransformerConfigurationException exce) { throw new WebApplicationException(exce); } catch (final TransformerFactoryConfigurationError exce) { throw new WebApplicationException(exce); } catch (final TransformerException exce) { throw new WebApplicationException(exce); } } }; return sOutput; }
[ "public", "static", "StreamingOutput", "buildResponseOfDomLR", "(", "final", "IStorage", "pDatabase", ",", "final", "IBackendFactory", "pStorageFac", ",", "final", "IRevisioning", "pRevision", ")", "{", "final", "StreamingOutput", "sOutput", "=", "new", "StreamingOutput...
This method builds the overview for the resources and collection we offer in our implementation. @param pDatabase path to the storage @param pStorageFac factory for creating backends @param pRevision revision algorithm utilized @return The streaming output for the HTTP response body.
[ "This", "method", "builds", "the", "overview", "for", "the", "resources", "and", "collection", "we", "offer", "in", "our", "implementation", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/util/RESTResponseHelper.java#L145-L187
train
Bedework/bw-util
bw-util-http/src/main/java/org/bedework/util/http/HttpUtil.java
HttpUtil.getUrl
public static String getUrl(final HttpServletRequest request) { try { final StringBuffer sb = request.getRequestURL(); if (sb != null) { return sb.toString(); } // Presumably portlet - see what happens with uri return request.getRequestURI(); } catch (Throwable t) { return "BogusURL.this.is.probably.a.portal"; } }
java
public static String getUrl(final HttpServletRequest request) { try { final StringBuffer sb = request.getRequestURL(); if (sb != null) { return sb.toString(); } // Presumably portlet - see what happens with uri return request.getRequestURI(); } catch (Throwable t) { return "BogusURL.this.is.probably.a.portal"; } }
[ "public", "static", "String", "getUrl", "(", "final", "HttpServletRequest", "request", ")", "{", "try", "{", "final", "StringBuffer", "sb", "=", "request", ".", "getRequestURL", "(", ")", ";", "if", "(", "sb", "!=", "null", ")", "{", "return", "sb", ".",...
Returns the String url from the request. @param request incoming request @return String url from the request
[ "Returns", "the", "String", "url", "from", "the", "request", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-http/src/main/java/org/bedework/util/http/HttpUtil.java#L304-L316
train
Bedework/bw-util
bw-util-servlet/src/main/java/org/bedework/util/servlet/SessionListener.java
SessionListener.logSessionCounts
protected void logSessionCounts(final HttpSession sess, final boolean start) { StringBuffer sb; String appname = getAppName(sess); Counts ct = getCounts(appname); if (start) { sb = new StringBuffer("SESSION-START:"); } else { sb = new StringBuffer("SESSION-END:"); } sb.append(getSessionId(sess)); sb.append(":"); sb.append(appname); sb.append(":"); sb.append(ct.activeSessions); sb.append(":"); sb.append(ct.totalSessions); sb.append(":"); sb.append(Runtime.getRuntime().freeMemory()/(1024 * 1024)); sb.append("M:"); sb.append(Runtime.getRuntime().totalMemory()/(1024 * 1024)); sb.append("M"); info(sb.toString()); }
java
protected void logSessionCounts(final HttpSession sess, final boolean start) { StringBuffer sb; String appname = getAppName(sess); Counts ct = getCounts(appname); if (start) { sb = new StringBuffer("SESSION-START:"); } else { sb = new StringBuffer("SESSION-END:"); } sb.append(getSessionId(sess)); sb.append(":"); sb.append(appname); sb.append(":"); sb.append(ct.activeSessions); sb.append(":"); sb.append(ct.totalSessions); sb.append(":"); sb.append(Runtime.getRuntime().freeMemory()/(1024 * 1024)); sb.append("M:"); sb.append(Runtime.getRuntime().totalMemory()/(1024 * 1024)); sb.append("M"); info(sb.toString()); }
[ "protected", "void", "logSessionCounts", "(", "final", "HttpSession", "sess", ",", "final", "boolean", "start", ")", "{", "StringBuffer", "sb", ";", "String", "appname", "=", "getAppName", "(", "sess", ")", ";", "Counts", "ct", "=", "getCounts", "(", "appnam...
Log the session counters for applications that maintain them. @param sess HttpSession for the session id @param start true for session start
[ "Log", "the", "session", "counters", "for", "applications", "that", "maintain", "them", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-servlet/src/main/java/org/bedework/util/servlet/SessionListener.java#L116-L142
train
Bedework/bw-util
bw-util-servlet/src/main/java/org/bedework/util/servlet/SessionListener.java
SessionListener.getSessionId
private String getSessionId(final HttpSession sess) { try { if (sess == null) { return "NO-SESSIONID"; } else { return sess.getId(); } } catch (Throwable t) { return "SESSION-ID-EXCEPTION"; } }
java
private String getSessionId(final HttpSession sess) { try { if (sess == null) { return "NO-SESSIONID"; } else { return sess.getId(); } } catch (Throwable t) { return "SESSION-ID-EXCEPTION"; } }
[ "private", "String", "getSessionId", "(", "final", "HttpSession", "sess", ")", "{", "try", "{", "if", "(", "sess", "==", "null", ")", "{", "return", "\"NO-SESSIONID\"", ";", "}", "else", "{", "return", "sess", ".", "getId", "(", ")", ";", "}", "}", "...
Get the session id for the loggers. @param sess @return String session id
[ "Get", "the", "session", "id", "for", "the", "loggers", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-servlet/src/main/java/org/bedework/util/servlet/SessionListener.java#L177-L187
train
Bedework/bw-util
bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/PresentationState.java
PresentationState.checkBrowserType
public void checkBrowserType(final HttpServletRequest request) { String reqpar = request.getParameter(getBrowserTypeRequestName()); if (reqpar != null) { if (reqpar.equals("!")) { // Go back to unsticky browser type setBrowserTypeSticky(false); } else { setBrowserType(reqpar); setBrowserTypeSticky(false); } } reqpar = request.getParameter(getBrowserTypeStickyRequestName()); if (reqpar != null) { if (reqpar.equals("!")) { // Go back to unsticky browser type setBrowserTypeSticky(false); } else { setBrowserType(reqpar); setBrowserTypeSticky(true); } } }
java
public void checkBrowserType(final HttpServletRequest request) { String reqpar = request.getParameter(getBrowserTypeRequestName()); if (reqpar != null) { if (reqpar.equals("!")) { // Go back to unsticky browser type setBrowserTypeSticky(false); } else { setBrowserType(reqpar); setBrowserTypeSticky(false); } } reqpar = request.getParameter(getBrowserTypeStickyRequestName()); if (reqpar != null) { if (reqpar.equals("!")) { // Go back to unsticky browser type setBrowserTypeSticky(false); } else { setBrowserType(reqpar); setBrowserTypeSticky(true); } } }
[ "public", "void", "checkBrowserType", "(", "final", "HttpServletRequest", "request", ")", "{", "String", "reqpar", "=", "request", ".", "getParameter", "(", "getBrowserTypeRequestName", "(", ")", ")", ";", "if", "(", "reqpar", "!=", "null", ")", "{", "if", "...
Allow user to explicitly set the browser type. @param request Needed to locate parameters
[ "Allow", "user", "to", "explicitly", "set", "the", "browser", "type", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/PresentationState.java#L251-L274
train
Bedework/bw-util
bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/PresentationState.java
PresentationState.checkContentType
public void checkContentType(final HttpServletRequest request) { String reqpar = request.getParameter(getContentTypeRequestName()); if (reqpar != null) { if (reqpar.equals("!")) { // Go back to unsticky content type setContentTypeSticky(false); } else { setContentType(reqpar); setContentTypeSticky(false); } } reqpar = request.getParameter(getContentTypeStickyRequestName()); if (reqpar != null) { if (reqpar.equals("!")) { // Go back to unsticky content type setContentTypeSticky(false); } else { setContentType(reqpar); setContentTypeSticky(true); } } }
java
public void checkContentType(final HttpServletRequest request) { String reqpar = request.getParameter(getContentTypeRequestName()); if (reqpar != null) { if (reqpar.equals("!")) { // Go back to unsticky content type setContentTypeSticky(false); } else { setContentType(reqpar); setContentTypeSticky(false); } } reqpar = request.getParameter(getContentTypeStickyRequestName()); if (reqpar != null) { if (reqpar.equals("!")) { // Go back to unsticky content type setContentTypeSticky(false); } else { setContentType(reqpar); setContentTypeSticky(true); } } }
[ "public", "void", "checkContentType", "(", "final", "HttpServletRequest", "request", ")", "{", "String", "reqpar", "=", "request", ".", "getParameter", "(", "getContentTypeRequestName", "(", ")", ")", ";", "if", "(", "reqpar", "!=", "null", ")", "{", "if", "...
Allow user to explicitly set the content type. @param request Needed to locate session
[ "Allow", "user", "to", "explicitly", "set", "the", "content", "type", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/PresentationState.java#L344-L367
train
Bedework/bw-util
bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/PresentationState.java
PresentationState.checkContentName
public void checkContentName(final HttpServletRequest request) { String reqpar = request.getParameter(getContentNameRequestName()); // Set to null if not found. setContentName(reqpar); }
java
public void checkContentName(final HttpServletRequest request) { String reqpar = request.getParameter(getContentNameRequestName()); // Set to null if not found. setContentName(reqpar); }
[ "public", "void", "checkContentName", "(", "final", "HttpServletRequest", "request", ")", "{", "String", "reqpar", "=", "request", ".", "getParameter", "(", "getContentNameRequestName", "(", ")", ")", ";", "// Set to null if not found.", "setContentName", "(", "reqpar...
Allow user to explicitly set the filename of the content. @param request Needed to locate session
[ "Allow", "user", "to", "explicitly", "set", "the", "filename", "of", "the", "content", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/PresentationState.java#L407-L412
train
Bedework/bw-util
bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/PresentationState.java
PresentationState.checkSkinName
public void checkSkinName(final HttpServletRequest request) { String reqpar = request.getParameter(getSkinNameRequestName()); if (reqpar != null) { if (reqpar.equals("!")) { // Go back to unsticky SkinName setSkinNameSticky(false); } else { setSkinName(reqpar); setSkinNameSticky(false); } } reqpar = request.getParameter(getSkinNameStickyRequestName()); if (reqpar != null) { if (reqpar.equals("!")) { // Go back to unsticky SkinName setSkinNameSticky(false); } else { setSkinName(reqpar); setSkinNameSticky(true); } } }
java
public void checkSkinName(final HttpServletRequest request) { String reqpar = request.getParameter(getSkinNameRequestName()); if (reqpar != null) { if (reqpar.equals("!")) { // Go back to unsticky SkinName setSkinNameSticky(false); } else { setSkinName(reqpar); setSkinNameSticky(false); } } reqpar = request.getParameter(getSkinNameStickyRequestName()); if (reqpar != null) { if (reqpar.equals("!")) { // Go back to unsticky SkinName setSkinNameSticky(false); } else { setSkinName(reqpar); setSkinNameSticky(true); } } }
[ "public", "void", "checkSkinName", "(", "final", "HttpServletRequest", "request", ")", "{", "String", "reqpar", "=", "request", ".", "getParameter", "(", "getSkinNameRequestName", "(", ")", ")", ";", "if", "(", "reqpar", "!=", "null", ")", "{", "if", "(", ...
Allow user to explicitly set the skin name. @param request Needed to locate session
[ "Allow", "user", "to", "explicitly", "set", "the", "skin", "name", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/PresentationState.java#L482-L505
train
Bedework/bw-util
bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/PresentationState.java
PresentationState.checkRefreshXslt
public void checkRefreshXslt(final HttpServletRequest request) { String reqpar = request.getParameter(getRefreshXSLTRequestName()); if (reqpar == null) { return; } if (reqpar.equals("yes")) { setForceXSLTRefresh(true); } if (reqpar.equals("always")) { setForceXSLTRefreshAlways(true); } if (reqpar.equals("!")) { setForceXSLTRefreshAlways(false); } }
java
public void checkRefreshXslt(final HttpServletRequest request) { String reqpar = request.getParameter(getRefreshXSLTRequestName()); if (reqpar == null) { return; } if (reqpar.equals("yes")) { setForceXSLTRefresh(true); } if (reqpar.equals("always")) { setForceXSLTRefreshAlways(true); } if (reqpar.equals("!")) { setForceXSLTRefreshAlways(false); } }
[ "public", "void", "checkRefreshXslt", "(", "final", "HttpServletRequest", "request", ")", "{", "String", "reqpar", "=", "request", ".", "getParameter", "(", "getRefreshXSLTRequestName", "(", ")", ")", ";", "if", "(", "reqpar", "==", "null", ")", "{", "return",...
Allow user to indicate how we should refresh the xslt. @param request Needed to locate session
[ "Allow", "user", "to", "indicate", "how", "we", "should", "refresh", "the", "xslt", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/PresentationState.java#L561-L579
train
Bedework/bw-util
bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/PresentationState.java
PresentationState.checkNoXSLT
public void checkNoXSLT(final HttpServletRequest request) { String reqpar = request.getParameter(getNoXSLTRequestName()); if (reqpar != null) { if (reqpar.equals("!")) { // Go back to unsticky noXslt setNoXSLTSticky(false); } else { setNoXSLT(true); } } reqpar = request.getParameter(getNoXSLTStickyRequestName()); if (reqpar != null) { if (reqpar.equals("!")) { // Go back to unsticky noXslt setNoXSLTSticky(false); } else { setNoXSLT(true); setNoXSLTSticky(true); } } }
java
public void checkNoXSLT(final HttpServletRequest request) { String reqpar = request.getParameter(getNoXSLTRequestName()); if (reqpar != null) { if (reqpar.equals("!")) { // Go back to unsticky noXslt setNoXSLTSticky(false); } else { setNoXSLT(true); } } reqpar = request.getParameter(getNoXSLTStickyRequestName()); if (reqpar != null) { if (reqpar.equals("!")) { // Go back to unsticky noXslt setNoXSLTSticky(false); } else { setNoXSLT(true); setNoXSLTSticky(true); } } }
[ "public", "void", "checkNoXSLT", "(", "final", "HttpServletRequest", "request", ")", "{", "String", "reqpar", "=", "request", ".", "getParameter", "(", "getNoXSLTRequestName", "(", ")", ")", ";", "if", "(", "reqpar", "!=", "null", ")", "{", "if", "(", "req...
Allow user to suppress XSLT transform for one request. Used for debugging - provides the raw xml. @param request Needed to locate session
[ "Allow", "user", "to", "suppress", "XSLT", "transform", "for", "one", "request", ".", "Used", "for", "debugging", "-", "provides", "the", "raw", "xml", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/PresentationState.java#L650-L672
train
centic9/commons-dost
src/main/java/org/dstadler/commons/svn/SVNCommands.java
SVNCommands.getBranchLog
public static Map<Long, LogEntry> getBranchLog(String[] branches, long startRevision, long endRevision, String baseUrl, String user, String pwd) throws IOException, SAXException { try (InputStream inStr = getBranchLogStream(branches, startRevision, endRevision, baseUrl, user, pwd)) { return new SVNLogFileParser(branches).parseContent(inStr); } catch (SAXException e) { throw new SAXException("While parsing branch-log of " + Arrays.toString(branches) + ", start: " + startRevision + ", end: " + endRevision + " with user " + user, e); } }
java
public static Map<Long, LogEntry> getBranchLog(String[] branches, long startRevision, long endRevision, String baseUrl, String user, String pwd) throws IOException, SAXException { try (InputStream inStr = getBranchLogStream(branches, startRevision, endRevision, baseUrl, user, pwd)) { return new SVNLogFileParser(branches).parseContent(inStr); } catch (SAXException e) { throw new SAXException("While parsing branch-log of " + Arrays.toString(branches) + ", start: " + startRevision + ", end: " + endRevision + " with user " + user, e); } }
[ "public", "static", "Map", "<", "Long", ",", "LogEntry", ">", "getBranchLog", "(", "String", "[", "]", "branches", ",", "long", "startRevision", ",", "long", "endRevision", ",", "String", "baseUrl", ",", "String", "user", ",", "String", "pwd", ")", "throws...
Retrieve the XML-log of changes on the given branch, in a specified range of revisions. @param branches The list of branches to fetch logs for, currently only the first entry is used! @param startRevision The SVN revision to use as starting point for the log-entries. @param endRevision The SVN revision to use as end point for the log-entries. In case <code>endRevision</code> is <code>-1</code>, HEAD revision is being used @param baseUrl The SVN url to connect to @param user The SVN user or null if the default user from the machine should be used @param pwd The SVN password or null if the default user from the machine should be used @return A mapping of revision numbers to the {@link LogEntry}. @return All matching log-entries as map of timestamp to {@link LogEntry} @throws IOException Execution of the SVN sub-process failed or the sub-process returned a exit value indicating a failure @throws SAXException If the resulting SVN XML log output could not be parsed
[ "Retrieve", "the", "XML", "-", "log", "of", "changes", "on", "the", "given", "branch", "in", "a", "specified", "range", "of", "revisions", "." ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/svn/SVNCommands.java#L97-L103
train
centic9/commons-dost
src/main/java/org/dstadler/commons/svn/SVNCommands.java
SVNCommands.getRemoteFileContent
public static InputStream getRemoteFileContent(String file, long revision, String baseUrl, String user, String pwd) throws IOException { // svn cat -r 666 file CommandLine cmdLine = new CommandLine(SVN_CMD); cmdLine.addArgument(CMD_CAT); addDefaultArguments(cmdLine, user, pwd); cmdLine.addArgument("-r"); cmdLine.addArgument(Long.toString(revision)); cmdLine.addArgument(baseUrl + file); return ExecutionHelper.getCommandResult(cmdLine, new File("."), 0, 120000); }
java
public static InputStream getRemoteFileContent(String file, long revision, String baseUrl, String user, String pwd) throws IOException { // svn cat -r 666 file CommandLine cmdLine = new CommandLine(SVN_CMD); cmdLine.addArgument(CMD_CAT); addDefaultArguments(cmdLine, user, pwd); cmdLine.addArgument("-r"); cmdLine.addArgument(Long.toString(revision)); cmdLine.addArgument(baseUrl + file); return ExecutionHelper.getCommandResult(cmdLine, new File("."), 0, 120000); }
[ "public", "static", "InputStream", "getRemoteFileContent", "(", "String", "file", ",", "long", "revision", ",", "String", "baseUrl", ",", "String", "user", ",", "String", "pwd", ")", "throws", "IOException", "{", "// svn cat -r 666 file", "CommandLine", "cmdLine", ...
Retrieve the contents of a file from the web-interface of the SVN server. @param file The file to fetch from the SVN server via @param revision The SVN revision to use @param baseUrl The SVN url to connect to @param user The SVN user or null if the default user from the machine should be used @param pwd The SVN password or null if the default user from the machine should be used @return The contents of the file. @return An InputStream which provides the content of the revision of the specified file @throws IOException Execution of the SVN sub-process failed or the sub-process returned a exit value indicating a failure
[ "Retrieve", "the", "contents", "of", "a", "file", "from", "the", "web", "-", "interface", "of", "the", "SVN", "server", "." ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/svn/SVNCommands.java#L229-L239
train
centic9/commons-dost
src/main/java/org/dstadler/commons/svn/SVNCommands.java
SVNCommands.branchExists
public static boolean branchExists(String branch, String baseUrl) { CommandLine cmdLine = new CommandLine(SVN_CMD); cmdLine.addArgument(CMD_LOG); cmdLine.addArgument(OPT_XML); addDefaultArguments(cmdLine, null, null); cmdLine.addArgument("-r"); cmdLine.addArgument("HEAD:HEAD"); cmdLine.addArgument(baseUrl + branch); try (InputStream inStr = ExecutionHelper.getCommandResult(cmdLine, new File("."), 0, 120000)) { return true; } catch (IOException e) { log.log(Level.FINE, "Branch " + branch + " not found or other error", e); return false; } }
java
public static boolean branchExists(String branch, String baseUrl) { CommandLine cmdLine = new CommandLine(SVN_CMD); cmdLine.addArgument(CMD_LOG); cmdLine.addArgument(OPT_XML); addDefaultArguments(cmdLine, null, null); cmdLine.addArgument("-r"); cmdLine.addArgument("HEAD:HEAD"); cmdLine.addArgument(baseUrl + branch); try (InputStream inStr = ExecutionHelper.getCommandResult(cmdLine, new File("."), 0, 120000)) { return true; } catch (IOException e) { log.log(Level.FINE, "Branch " + branch + " not found or other error", e); return false; } }
[ "public", "static", "boolean", "branchExists", "(", "String", "branch", ",", "String", "baseUrl", ")", "{", "CommandLine", "cmdLine", "=", "new", "CommandLine", "(", "SVN_CMD", ")", ";", "cmdLine", ".", "addArgument", "(", "CMD_LOG", ")", ";", "cmdLine", "."...
Check if the given branch already exists @param branch The name of the branch including the path to the branch, e.g. branches/4.2.x @param baseUrl The SVN url to connect to @return true if the branch already exists, false otherwise.
[ "Check", "if", "the", "given", "branch", "already", "exists" ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/svn/SVNCommands.java#L248-L263
train
centic9/commons-dost
src/main/java/org/dstadler/commons/svn/SVNCommands.java
SVNCommands.getBranchRevision
public static long getBranchRevision(String branch, String baseUrl) throws IOException { CommandLine cmdLine = new CommandLine(SVN_CMD); cmdLine.addArgument(CMD_LOG); cmdLine.addArgument(OPT_XML); addDefaultArguments(cmdLine, null, null); cmdLine.addArgument("-v"); cmdLine.addArgument("-r0:HEAD"); cmdLine.addArgument("--stop-on-copy"); cmdLine.addArgument("--limit"); cmdLine.addArgument("1"); cmdLine.addArgument(baseUrl + branch); try (InputStream inStr = ExecutionHelper.getCommandResult(cmdLine, new File("."), 0, 120000)) { String xml = IOUtils.toString(inStr, "UTF-8"); log.info("XML:\n" + xml); // read the revision Matcher matcher = Pattern.compile("copyfrom-rev=\"([0-9]+)\"").matcher(xml); if (!matcher.find()) { throw new IOException("Could not find copyfrom-rev entry in xml: " + xml); } log.info("Found copyfrom-rev: " + matcher.group(1)); return Long.parseLong(matcher.group(1)); } }
java
public static long getBranchRevision(String branch, String baseUrl) throws IOException { CommandLine cmdLine = new CommandLine(SVN_CMD); cmdLine.addArgument(CMD_LOG); cmdLine.addArgument(OPT_XML); addDefaultArguments(cmdLine, null, null); cmdLine.addArgument("-v"); cmdLine.addArgument("-r0:HEAD"); cmdLine.addArgument("--stop-on-copy"); cmdLine.addArgument("--limit"); cmdLine.addArgument("1"); cmdLine.addArgument(baseUrl + branch); try (InputStream inStr = ExecutionHelper.getCommandResult(cmdLine, new File("."), 0, 120000)) { String xml = IOUtils.toString(inStr, "UTF-8"); log.info("XML:\n" + xml); // read the revision Matcher matcher = Pattern.compile("copyfrom-rev=\"([0-9]+)\"").matcher(xml); if (!matcher.find()) { throw new IOException("Could not find copyfrom-rev entry in xml: " + xml); } log.info("Found copyfrom-rev: " + matcher.group(1)); return Long.parseLong(matcher.group(1)); } }
[ "public", "static", "long", "getBranchRevision", "(", "String", "branch", ",", "String", "baseUrl", ")", "throws", "IOException", "{", "CommandLine", "cmdLine", "=", "new", "CommandLine", "(", "SVN_CMD", ")", ";", "cmdLine", ".", "addArgument", "(", "CMD_LOG", ...
Return the revision from which the branch was branched off. @param branch The name of the branch including the path to the branch, e.g. branches/4.2.x @param baseUrl The SVN url to connect to @return The revision where the branch was branched off from it's parent branch. @throws IOException Execution of the SVN sub-process failed or the sub-process returned a exit value indicating a failure
[ "Return", "the", "revision", "from", "which", "the", "branch", "was", "branched", "off", "." ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/svn/SVNCommands.java#L274-L299
train
centic9/commons-dost
src/main/java/org/dstadler/commons/svn/SVNCommands.java
SVNCommands.getLastRevision
public static long getLastRevision(String branch, String baseUrl, String user, String pwd) throws IOException { CommandLine cmdLine = new CommandLine(SVN_CMD); cmdLine.addArgument("info"); addDefaultArguments(cmdLine, user, pwd); cmdLine.addArgument(baseUrl + branch); try (InputStream inStr = ExecutionHelper.getCommandResult(cmdLine, new File("."), 0, 120000)) { String info = IOUtils.toString(inStr, "UTF-8"); log.info("Info:\n" + info); /* svn info http://... Repository Root: https://svn-lnz.emea.cpwr.corp/svn/dev Repository UUID: 35fb04cf-4f84-b44d-92fa-8d0d0442729e Revision: 390864 Node Kind: directory */ // read the revision Matcher matcher = Pattern.compile("Revision: ([0-9]+)").matcher(info); if (!matcher.find()) { throw new IOException("Could not find Revision entry in info-output: " + info); } log.info("Found rev: " + matcher.group(1) + " for branch " + branch); return Long.parseLong(matcher.group(1)); } }
java
public static long getLastRevision(String branch, String baseUrl, String user, String pwd) throws IOException { CommandLine cmdLine = new CommandLine(SVN_CMD); cmdLine.addArgument("info"); addDefaultArguments(cmdLine, user, pwd); cmdLine.addArgument(baseUrl + branch); try (InputStream inStr = ExecutionHelper.getCommandResult(cmdLine, new File("."), 0, 120000)) { String info = IOUtils.toString(inStr, "UTF-8"); log.info("Info:\n" + info); /* svn info http://... Repository Root: https://svn-lnz.emea.cpwr.corp/svn/dev Repository UUID: 35fb04cf-4f84-b44d-92fa-8d0d0442729e Revision: 390864 Node Kind: directory */ // read the revision Matcher matcher = Pattern.compile("Revision: ([0-9]+)").matcher(info); if (!matcher.find()) { throw new IOException("Could not find Revision entry in info-output: " + info); } log.info("Found rev: " + matcher.group(1) + " for branch " + branch); return Long.parseLong(matcher.group(1)); } }
[ "public", "static", "long", "getLastRevision", "(", "String", "branch", ",", "String", "baseUrl", ",", "String", "user", ",", "String", "pwd", ")", "throws", "IOException", "{", "CommandLine", "cmdLine", "=", "new", "CommandLine", "(", "SVN_CMD", ")", ";", "...
Return the last revision of the given branch. Uses the full svn repository if branch is "" @param branch The name of the branch including the path to the branch, e.g. branches/4.2.x @param baseUrl The SVN url to connect to @param user The SVN user or null if the default user from the machine should be used @param pwd The SVN password or null if the default user from the machine should be used @return The contents of the file. @return The last revision where a check-in was made on the branch @throws IOException Execution of the SVN sub-process failed or the sub-process returned a exit value indicating a failure
[ "Return", "the", "last", "revision", "of", "the", "given", "branch", ".", "Uses", "the", "full", "svn", "repository", "if", "branch", "is" ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/svn/SVNCommands.java#L312-L339
train
centic9/commons-dost
src/main/java/org/dstadler/commons/svn/SVNCommands.java
SVNCommands.getPendingCheckins
public static InputStream getPendingCheckins(File directory) throws IOException { CommandLine cmdLine = new CommandLine(SVN_CMD); cmdLine.addArgument(CMD_STATUS); addDefaultArguments(cmdLine, null, null); return ExecutionHelper.getCommandResult(cmdLine, directory, -1, 120000); }
java
public static InputStream getPendingCheckins(File directory) throws IOException { CommandLine cmdLine = new CommandLine(SVN_CMD); cmdLine.addArgument(CMD_STATUS); addDefaultArguments(cmdLine, null, null); return ExecutionHelper.getCommandResult(cmdLine, directory, -1, 120000); }
[ "public", "static", "InputStream", "getPendingCheckins", "(", "File", "directory", ")", "throws", "IOException", "{", "CommandLine", "cmdLine", "=", "new", "CommandLine", "(", "SVN_CMD", ")", ";", "cmdLine", ".", "addArgument", "(", "CMD_STATUS", ")", ";", "addD...
Performs a "svn status" and returns the list of changes in the svn tree at the given directory in the format that the svn command provides them. @param directory The local working directory @return A stream which returns a textual list of changes as reported by "svn status", should be closed by the caller @throws IOException Execution of the SVN sub-process failed or the sub-process returned a exit value indicating a failure
[ "Performs", "a", "svn", "status", "and", "returns", "the", "list", "of", "changes", "in", "the", "svn", "tree", "at", "the", "given", "directory", "in", "the", "format", "that", "the", "svn", "command", "provides", "them", "." ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/svn/SVNCommands.java#L363-L369
train
centic9/commons-dost
src/main/java/org/dstadler/commons/svn/SVNCommands.java
SVNCommands.recordMerge
public static InputStream recordMerge(File directory, String branchName, long... revisions) throws IOException { // svn merge -c 3328 --record-only ^/calc/trunk CommandLine cmdLine = new CommandLine(SVN_CMD); cmdLine.addArgument(CMD_MERGE); addDefaultArguments(cmdLine, null, null); cmdLine.addArgument("--record-only"); cmdLine.addArgument("-c"); StringBuilder revs = new StringBuilder(); for (long revision : revisions) { revs.append(revision).append(","); } cmdLine.addArgument(revs.toString()); // leads to "non-inheritable merges" // cmdLine.addArgument("--depth"); // cmdLine.addArgument("empty"); cmdLine.addArgument("^" + branchName); //cmdLine.addArgument("."); // current dir return ExecutionHelper.getCommandResult(cmdLine, directory, 0, 120000); }
java
public static InputStream recordMerge(File directory, String branchName, long... revisions) throws IOException { // svn merge -c 3328 --record-only ^/calc/trunk CommandLine cmdLine = new CommandLine(SVN_CMD); cmdLine.addArgument(CMD_MERGE); addDefaultArguments(cmdLine, null, null); cmdLine.addArgument("--record-only"); cmdLine.addArgument("-c"); StringBuilder revs = new StringBuilder(); for (long revision : revisions) { revs.append(revision).append(","); } cmdLine.addArgument(revs.toString()); // leads to "non-inheritable merges" // cmdLine.addArgument("--depth"); // cmdLine.addArgument("empty"); cmdLine.addArgument("^" + branchName); //cmdLine.addArgument("."); // current dir return ExecutionHelper.getCommandResult(cmdLine, directory, 0, 120000); }
[ "public", "static", "InputStream", "recordMerge", "(", "File", "directory", ",", "String", "branchName", ",", "long", "...", "revisions", ")", "throws", "IOException", "{", "// \t\t\t\tsvn merge -c 3328 --record-only ^/calc/trunk", "CommandLine", "cmdLine", "=", "new", ...
Record a manual merge from one branch to the local working directory. @param directory The local working directory @param branchName The branch that was merged in manually @param revisions The list of merged revisions. @return A stream which provides the output of the "svn merge" command, should be closed by the caller @throws IOException Execution of the SVN sub-process failed or the sub-process returned a exit value indicating a failure
[ "Record", "a", "manual", "merge", "from", "one", "branch", "to", "the", "local", "working", "directory", "." ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/svn/SVNCommands.java#L491-L510
train
centic9/commons-dost
src/main/java/org/dstadler/commons/svn/SVNCommands.java
SVNCommands.verifyNoPendingChanges
public static boolean verifyNoPendingChanges(File directory) throws IOException { log.info("Checking that there are no pending changes on trunk-working copy"); try (InputStream inStr = getPendingCheckins(directory)) { List<String> lines = IOUtils.readLines(inStr, "UTF-8"); if (lines.size() > 0) { log.info("Found the following checkouts:\n" + ArrayUtils.toString(lines.toArray(), "\n")); return true; } } return false; }
java
public static boolean verifyNoPendingChanges(File directory) throws IOException { log.info("Checking that there are no pending changes on trunk-working copy"); try (InputStream inStr = getPendingCheckins(directory)) { List<String> lines = IOUtils.readLines(inStr, "UTF-8"); if (lines.size() > 0) { log.info("Found the following checkouts:\n" + ArrayUtils.toString(lines.toArray(), "\n")); return true; } } return false; }
[ "public", "static", "boolean", "verifyNoPendingChanges", "(", "File", "directory", ")", "throws", "IOException", "{", "log", ".", "info", "(", "\"Checking that there are no pending changes on trunk-working copy\"", ")", ";", "try", "(", "InputStream", "inStr", "=", "get...
Check if there are pending changes on the branch, returns true if changes are found. @param directory The local working directory @return True if there are pending changes, false otherwise @throws IOException Execution of the SVN sub-process failed or the sub-process returned a exit value indicating a failure
[ "Check", "if", "there", "are", "pending", "changes", "on", "the", "branch", "returns", "true", "if", "changes", "are", "found", "." ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/svn/SVNCommands.java#L520-L531
train