id
int32
0
165k
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
150,900
mytechia/mytechia_commons
mytechia-commons-modelaction/src/main/java/com/mytechia/commons/framework/modelaction/action/async/AsyncActionPool.java
AsyncActionPool.createThreads
private void createThreads(int threadCount) { for(int i=0; i<threadCount; i++) { AsyncActionWorkerThread worker = new AsyncActionWorkerThread("Async-Action-Worker-"+i); this.threadPool.add(worker); worker.start(); } }
java
private void createThreads(int threadCount) { for(int i=0; i<threadCount; i++) { AsyncActionWorkerThread worker = new AsyncActionWorkerThread("Async-Action-Worker-"+i); this.threadPool.add(worker); worker.start(); } }
[ "private", "void", "createThreads", "(", "int", "threadCount", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "threadCount", ";", "i", "++", ")", "{", "AsyncActionWorkerThread", "worker", "=", "new", "AsyncActionWorkerThread", "(", "\"Async-Action-Worker-\"", "+", "i", ")", ";", "this", ".", "threadPool", ".", "add", "(", "worker", ")", ";", "worker", ".", "start", "(", ")", ";", "}", "}" ]
Creates the worker threads and starts their execution @param threadCount the number of worker threads to create
[ "Creates", "the", "worker", "threads", "and", "starts", "their", "execution" ]
02251879085f271a1fb51663a1c8eddc8be78ae7
https://github.com/mytechia/mytechia_commons/blob/02251879085f271a1fb51663a1c8eddc8be78ae7/mytechia-commons-modelaction/src/main/java/com/mytechia/commons/framework/modelaction/action/async/AsyncActionPool.java#L76-L87
150,901
mytechia/mytechia_commons
mytechia-commons-modelaction/src/main/java/com/mytechia/commons/framework/modelaction/action/async/AsyncActionPool.java
AsyncActionPool.addAction
public void addAction(ModelAction action, ModelActionListener listener) { synchronized(actionQueue) { this.actionQueue.add(new ModelActionEntry(action, listener)); } wakeUp(); }
java
public void addAction(ModelAction action, ModelActionListener listener) { synchronized(actionQueue) { this.actionQueue.add(new ModelActionEntry(action, listener)); } wakeUp(); }
[ "public", "void", "addAction", "(", "ModelAction", "action", ",", "ModelActionListener", "listener", ")", "{", "synchronized", "(", "actionQueue", ")", "{", "this", ".", "actionQueue", ".", "add", "(", "new", "ModelActionEntry", "(", "action", ",", "listener", ")", ")", ";", "}", "wakeUp", "(", ")", ";", "}" ]
Adds an action to the processing queue @param action the action to execute @param listener an optional listener object to be notified of the action end state
[ "Adds", "an", "action", "to", "the", "processing", "queue" ]
02251879085f271a1fb51663a1c8eddc8be78ae7
https://github.com/mytechia/mytechia_commons/blob/02251879085f271a1fb51663a1c8eddc8be78ae7/mytechia-commons-modelaction/src/main/java/com/mytechia/commons/framework/modelaction/action/async/AsyncActionPool.java#L95-L104
150,902
mytechia/mytechia_commons
mytechia-commons-modelaction/src/main/java/com/mytechia/commons/framework/modelaction/action/async/AsyncActionPool.java
AsyncActionPool.pollAction
private ModelActionEntry pollAction() { ModelActionEntry action = null; while(!stop) { synchronized(actionQueue) { action = this.actionQueue.poll(); } if (action != null) { break; } else { synchronized(semaphore) { try { semaphore.wait(); } catch (InterruptedException ex) { ex.printStackTrace(); ////////// } } } } return action; }
java
private ModelActionEntry pollAction() { ModelActionEntry action = null; while(!stop) { synchronized(actionQueue) { action = this.actionQueue.poll(); } if (action != null) { break; } else { synchronized(semaphore) { try { semaphore.wait(); } catch (InterruptedException ex) { ex.printStackTrace(); ////////// } } } } return action; }
[ "private", "ModelActionEntry", "pollAction", "(", ")", "{", "ModelActionEntry", "action", "=", "null", ";", "while", "(", "!", "stop", ")", "{", "synchronized", "(", "actionQueue", ")", "{", "action", "=", "this", ".", "actionQueue", ".", "poll", "(", ")", ";", "}", "if", "(", "action", "!=", "null", ")", "{", "break", ";", "}", "else", "{", "synchronized", "(", "semaphore", ")", "{", "try", "{", "semaphore", ".", "wait", "(", ")", ";", "}", "catch", "(", "InterruptedException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "//////////", "}", "}", "}", "}", "return", "action", ";", "}" ]
Retrieves an action from the queue It is a blocking method, it blocks until an action is available in the queue or the processing pool is stopped
[ "Retrieves", "an", "action", "from", "the", "queue", "It", "is", "a", "blocking", "method", "it", "blocks", "until", "an", "action", "is", "available", "in", "the", "queue", "or", "the", "processing", "pool", "is", "stopped" ]
02251879085f271a1fb51663a1c8eddc8be78ae7
https://github.com/mytechia/mytechia_commons/blob/02251879085f271a1fb51663a1c8eddc8be78ae7/mytechia-commons-modelaction/src/main/java/com/mytechia/commons/framework/modelaction/action/async/AsyncActionPool.java#L111-L138
150,903
jtrfp/javamod
src/main/java/de/quippy/jmac/tools/CircleBuffer.java
CircleBuffer.CreateBuffer
public void CreateBuffer(int nBytes, int nMaxDirectWriteBytes) { m_nMaxDirectWriteBytes = nMaxDirectWriteBytes; m_nTotal = nBytes + 1 + nMaxDirectWriteBytes; m_pBuffer = new byte[m_nTotal]; byteBuffer = new ByteBuffer(); m_nHead = 0; m_nTail = 0; m_nEndCap = m_nTotal; }
java
public void CreateBuffer(int nBytes, int nMaxDirectWriteBytes) { m_nMaxDirectWriteBytes = nMaxDirectWriteBytes; m_nTotal = nBytes + 1 + nMaxDirectWriteBytes; m_pBuffer = new byte[m_nTotal]; byteBuffer = new ByteBuffer(); m_nHead = 0; m_nTail = 0; m_nEndCap = m_nTotal; }
[ "public", "void", "CreateBuffer", "(", "int", "nBytes", ",", "int", "nMaxDirectWriteBytes", ")", "{", "m_nMaxDirectWriteBytes", "=", "nMaxDirectWriteBytes", ";", "m_nTotal", "=", "nBytes", "+", "1", "+", "nMaxDirectWriteBytes", ";", "m_pBuffer", "=", "new", "byte", "[", "m_nTotal", "]", ";", "byteBuffer", "=", "new", "ByteBuffer", "(", ")", ";", "m_nHead", "=", "0", ";", "m_nTail", "=", "0", ";", "m_nEndCap", "=", "m_nTotal", ";", "}" ]
create the buffer
[ "create", "the", "buffer" ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/jmac/tools/CircleBuffer.java#L39-L47
150,904
livetribe/livetribe-slp
osgi/bundle/src/main/java/org/livetribe/slp/osgi/UserAgentManagedServiceFactory.java
UserAgentManagedServiceFactory.updated
public void updated(String pid, Dictionary dictionary) throws ConfigurationException { LOGGER.entering(CLASS_NAME, "updated", new Object[]{pid, dictionary}); deleted(pid); UserAgent userAgent = SLP.newUserAgent(dictionary == null ? null : DictionarySettings.from(dictionary)); if (LOGGER.isLoggable(Level.FINER)) LOGGER.finer("User Agent " + pid + " starting..."); userAgent.start(); if (LOGGER.isLoggable(Level.FINE)) LOGGER.fine("User Agent " + pid + " started successfully"); ServiceRegistration serviceRegistration = bundleContext.registerService(IServiceAgent.class.getName(), userAgent, dictionary); userAgents.put(pid, serviceRegistration); LOGGER.exiting(CLASS_NAME, "updated"); }
java
public void updated(String pid, Dictionary dictionary) throws ConfigurationException { LOGGER.entering(CLASS_NAME, "updated", new Object[]{pid, dictionary}); deleted(pid); UserAgent userAgent = SLP.newUserAgent(dictionary == null ? null : DictionarySettings.from(dictionary)); if (LOGGER.isLoggable(Level.FINER)) LOGGER.finer("User Agent " + pid + " starting..."); userAgent.start(); if (LOGGER.isLoggable(Level.FINE)) LOGGER.fine("User Agent " + pid + " started successfully"); ServiceRegistration serviceRegistration = bundleContext.registerService(IServiceAgent.class.getName(), userAgent, dictionary); userAgents.put(pid, serviceRegistration); LOGGER.exiting(CLASS_NAME, "updated"); }
[ "public", "void", "updated", "(", "String", "pid", ",", "Dictionary", "dictionary", ")", "throws", "ConfigurationException", "{", "LOGGER", ".", "entering", "(", "CLASS_NAME", ",", "\"updated\"", ",", "new", "Object", "[", "]", "{", "pid", ",", "dictionary", "}", ")", ";", "deleted", "(", "pid", ")", ";", "UserAgent", "userAgent", "=", "SLP", ".", "newUserAgent", "(", "dictionary", "==", "null", "?", "null", ":", "DictionarySettings", ".", "from", "(", "dictionary", ")", ")", ";", "if", "(", "LOGGER", ".", "isLoggable", "(", "Level", ".", "FINER", ")", ")", "LOGGER", ".", "finer", "(", "\"User Agent \"", "+", "pid", "+", "\" starting...\"", ")", ";", "userAgent", ".", "start", "(", ")", ";", "if", "(", "LOGGER", ".", "isLoggable", "(", "Level", ".", "FINE", ")", ")", "LOGGER", ".", "fine", "(", "\"User Agent \"", "+", "pid", "+", "\" started successfully\"", ")", ";", "ServiceRegistration", "serviceRegistration", "=", "bundleContext", ".", "registerService", "(", "IServiceAgent", ".", "class", ".", "getName", "(", ")", ",", "userAgent", ",", "dictionary", ")", ";", "userAgents", ".", "put", "(", "pid", ",", "serviceRegistration", ")", ";", "LOGGER", ".", "exiting", "(", "CLASS_NAME", ",", "\"updated\"", ")", ";", "}" ]
Update the SLP user agent's configuration, unregistering from the OSGi service registry and stopping it if it had already started. The new SLP user agent will be started with the new configuration and registered in the OSGi service registry using the configuration parameters as service properties. @param pid The PID for this configuration. @param dictionary The dictionary used to configure the SLP user agent. @throws ConfigurationException Thrown if an error occurs during the SLP user agent's configuration.
[ "Update", "the", "SLP", "user", "agent", "s", "configuration", "unregistering", "from", "the", "OSGi", "service", "registry", "and", "stopping", "it", "if", "it", "had", "already", "started", ".", "The", "new", "SLP", "user", "agent", "will", "be", "started", "with", "the", "new", "configuration", "and", "registered", "in", "the", "OSGi", "service", "registry", "using", "the", "configuration", "parameters", "as", "service", "properties", "." ]
6cc13dbe81feab133fe3dd291ca081cbc6e1f591
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/osgi/bundle/src/main/java/org/livetribe/slp/osgi/UserAgentManagedServiceFactory.java#L95-L113
150,905
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/BannedDependencies.java
BannedDependencies.checkDependencies
private Set<Artifact> checkDependencies( Set<Artifact> dependencies, List<String> thePatterns ) throws EnforcerRuleException { Set<Artifact> foundMatches = null; if ( thePatterns != null && thePatterns.size() > 0 ) { for ( String pattern : thePatterns ) { String[] subStrings = pattern.split( ":" ); subStrings = StringUtils.stripAll( subStrings ); for ( Artifact artifact : dependencies ) { if ( compareDependency( subStrings, artifact ) ) { // only create if needed if ( foundMatches == null ) { foundMatches = new HashSet<Artifact>(); } foundMatches.add( artifact ); } } } } return foundMatches; }
java
private Set<Artifact> checkDependencies( Set<Artifact> dependencies, List<String> thePatterns ) throws EnforcerRuleException { Set<Artifact> foundMatches = null; if ( thePatterns != null && thePatterns.size() > 0 ) { for ( String pattern : thePatterns ) { String[] subStrings = pattern.split( ":" ); subStrings = StringUtils.stripAll( subStrings ); for ( Artifact artifact : dependencies ) { if ( compareDependency( subStrings, artifact ) ) { // only create if needed if ( foundMatches == null ) { foundMatches = new HashSet<Artifact>(); } foundMatches.add( artifact ); } } } } return foundMatches; }
[ "private", "Set", "<", "Artifact", ">", "checkDependencies", "(", "Set", "<", "Artifact", ">", "dependencies", ",", "List", "<", "String", ">", "thePatterns", ")", "throws", "EnforcerRuleException", "{", "Set", "<", "Artifact", ">", "foundMatches", "=", "null", ";", "if", "(", "thePatterns", "!=", "null", "&&", "thePatterns", ".", "size", "(", ")", ">", "0", ")", "{", "for", "(", "String", "pattern", ":", "thePatterns", ")", "{", "String", "[", "]", "subStrings", "=", "pattern", ".", "split", "(", "\":\"", ")", ";", "subStrings", "=", "StringUtils", ".", "stripAll", "(", "subStrings", ")", ";", "for", "(", "Artifact", "artifact", ":", "dependencies", ")", "{", "if", "(", "compareDependency", "(", "subStrings", ",", "artifact", ")", ")", "{", "// only create if needed", "if", "(", "foundMatches", "==", "null", ")", "{", "foundMatches", "=", "new", "HashSet", "<", "Artifact", ">", "(", ")", ";", "}", "foundMatches", ".", "add", "(", "artifact", ")", ";", "}", "}", "}", "}", "return", "foundMatches", ";", "}" ]
Checks the set of dependencies against the list of patterns. @param thePatterns the patterns @param dependencies the dependencies @return a set containing artifacts matching one of the patterns or <code>null</code> @throws EnforcerRuleException the enforcer rule exception
[ "Checks", "the", "set", "of", "dependencies", "against", "the", "list", "of", "patterns", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/BannedDependencies.java#L99-L128
150,906
livetribe/livetribe-slp
core/src/main/java/org/livetribe/slp/settings/Editors.java
Editors.register
public static void register(Class<?> typeClass, Class<? extends PropertyEditor> editorClass) { synchronized (editors) { editors.put(typeClass, editorClass); } }
java
public static void register(Class<?> typeClass, Class<? extends PropertyEditor> editorClass) { synchronized (editors) { editors.put(typeClass, editorClass); } }
[ "public", "static", "void", "register", "(", "Class", "<", "?", ">", "typeClass", ",", "Class", "<", "?", "extends", "PropertyEditor", ">", "editorClass", ")", "{", "synchronized", "(", "editors", ")", "{", "editors", ".", "put", "(", "typeClass", ",", "editorClass", ")", ";", "}", "}" ]
Registers the given editor class to be used to edit values of the given type class. @param typeClass the class of objects to be edited @param editorClass the editor class
[ "Registers", "the", "given", "editor", "class", "to", "be", "used", "to", "edit", "values", "of", "the", "given", "type", "class", "." ]
6cc13dbe81feab133fe3dd291ca081cbc6e1f591
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/settings/Editors.java#L42-L48
150,907
GerdHolz/TOVAL
src/de/invation/code/toval/graphic/ui/VerticalLabelUI.java
VerticalLabelUI.getBaseline
@Override public int getBaseline(JComponent c, int width, int height) { super.getBaseline(c, width, height); return -1; }
java
@Override public int getBaseline(JComponent c, int width, int height) { super.getBaseline(c, width, height); return -1; }
[ "@", "Override", "public", "int", "getBaseline", "(", "JComponent", "c", ",", "int", "width", ",", "int", "height", ")", "{", "super", ".", "getBaseline", "(", "c", ",", "width", ",", "height", ")", ";", "return", "-", "1", ";", "}" ]
Overridden to always return -1, since a vertical label does not have a meaningful baseline. @see ComponentUI#getBaseline(JComponent, int, int)
[ "Overridden", "to", "always", "return", "-", "1", "since", "a", "vertical", "label", "does", "not", "have", "a", "meaningful", "baseline", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/graphic/ui/VerticalLabelUI.java#L66-L70
150,908
GerdHolz/TOVAL
src/de/invation/code/toval/graphic/ui/VerticalLabelUI.java
VerticalLabelUI.getBaselineResizeBehavior
@Override public Component.BaselineResizeBehavior getBaselineResizeBehavior( JComponent c) { super.getBaselineResizeBehavior(c); return Component.BaselineResizeBehavior.OTHER; }
java
@Override public Component.BaselineResizeBehavior getBaselineResizeBehavior( JComponent c) { super.getBaselineResizeBehavior(c); return Component.BaselineResizeBehavior.OTHER; }
[ "@", "Override", "public", "Component", ".", "BaselineResizeBehavior", "getBaselineResizeBehavior", "(", "JComponent", "c", ")", "{", "super", ".", "getBaselineResizeBehavior", "(", "c", ")", ";", "return", "Component", ".", "BaselineResizeBehavior", ".", "OTHER", ";", "}" ]
Overridden to always return Component.BaselineResizeBehavior.OTHER, since a vertical label does not have a meaningful baseline @see ComponentUI#getBaselineResizeBehavior(javax.swing.JComponent)
[ "Overridden", "to", "always", "return", "Component", ".", "BaselineResizeBehavior", ".", "OTHER", "since", "a", "vertical", "label", "does", "not", "have", "a", "meaningful", "baseline" ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/graphic/ui/VerticalLabelUI.java#L78-L83
150,909
GerdHolz/TOVAL
src/de/invation/code/toval/graphic/ui/VerticalLabelUI.java
VerticalLabelUI.paint
@Override public void paint(Graphics g, JComponent c) { Graphics2D g2 = (Graphics2D) g.create(); if (clockwiseRotation) { g2.rotate(Math.PI / 2, c.getSize().width / 2, c.getSize().width / 2); } else { g2.rotate(-Math.PI / 2, c.getSize().height / 2, c.getSize().height / 2); } super.paint(g2, c); }
java
@Override public void paint(Graphics g, JComponent c) { Graphics2D g2 = (Graphics2D) g.create(); if (clockwiseRotation) { g2.rotate(Math.PI / 2, c.getSize().width / 2, c.getSize().width / 2); } else { g2.rotate(-Math.PI / 2, c.getSize().height / 2, c.getSize().height / 2); } super.paint(g2, c); }
[ "@", "Override", "public", "void", "paint", "(", "Graphics", "g", ",", "JComponent", "c", ")", "{", "Graphics2D", "g2", "=", "(", "Graphics2D", ")", "g", ".", "create", "(", ")", ";", "if", "(", "clockwiseRotation", ")", "{", "g2", ".", "rotate", "(", "Math", ".", "PI", "/", "2", ",", "c", ".", "getSize", "(", ")", ".", "width", "/", "2", ",", "c", ".", "getSize", "(", ")", ".", "width", "/", "2", ")", ";", "}", "else", "{", "g2", ".", "rotate", "(", "-", "Math", ".", "PI", "/", "2", ",", "c", ".", "getSize", "(", ")", ".", "height", "/", "2", ",", "c", ".", "getSize", "(", ")", ".", "height", "/", "2", ")", ";", "}", "super", ".", "paint", "(", "g2", ",", "c", ")", ";", "}" ]
Transforms the Graphics for vertical rendering and invokes the super method.
[ "Transforms", "the", "Graphics", "for", "vertical", "rendering", "and", "invokes", "the", "super", "method", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/graphic/ui/VerticalLabelUI.java#L113-L122
150,910
jtrfp/javamod
src/main/java/de/quippy/mp3/decoder/BitReserve.java
BitReserve.hgetbits
public int hgetbits(int N) { totbit += N; int val = 0; int pos = buf_byte_idx; if (pos+N < BUFSIZE) { while (N-- > 0) { val <<= 1; val |= ((buf[pos++]!=0) ? 1 : 0); } } else { while (N-- > 0) { val <<= 1; val |= ((buf[pos]!=0) ? 1 : 0); pos = (pos+1) & BUFSIZE_MASK; } } buf_byte_idx = pos; return val; }
java
public int hgetbits(int N) { totbit += N; int val = 0; int pos = buf_byte_idx; if (pos+N < BUFSIZE) { while (N-- > 0) { val <<= 1; val |= ((buf[pos++]!=0) ? 1 : 0); } } else { while (N-- > 0) { val <<= 1; val |= ((buf[pos]!=0) ? 1 : 0); pos = (pos+1) & BUFSIZE_MASK; } } buf_byte_idx = pos; return val; }
[ "public", "int", "hgetbits", "(", "int", "N", ")", "{", "totbit", "+=", "N", ";", "int", "val", "=", "0", ";", "int", "pos", "=", "buf_byte_idx", ";", "if", "(", "pos", "+", "N", "<", "BUFSIZE", ")", "{", "while", "(", "N", "--", ">", "0", ")", "{", "val", "<<=", "1", ";", "val", "|=", "(", "(", "buf", "[", "pos", "++", "]", "!=", "0", ")", "?", "1", ":", "0", ")", ";", "}", "}", "else", "{", "while", "(", "N", "--", ">", "0", ")", "{", "val", "<<=", "1", ";", "val", "|=", "(", "(", "buf", "[", "pos", "]", "!=", "0", ")", "?", "1", ":", "0", ")", ";", "pos", "=", "(", "pos", "+", "1", ")", "&", "BUFSIZE_MASK", ";", "}", "}", "buf_byte_idx", "=", "pos", ";", "return", "val", ";", "}" ]
Read a number bits from the bit stream. @param N the number of
[ "Read", "a", "number", "bits", "from", "the", "bit", "stream", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/mp3/decoder/BitReserve.java#L83-L109
150,911
jtrfp/javamod
src/main/java/de/quippy/mp3/decoder/BitReserve.java
BitReserve.hputbuf
public void hputbuf(int val) { int ofs = offset; buf[ofs++] = val & 0x80; buf[ofs++] = val & 0x40; buf[ofs++] = val & 0x20; buf[ofs++] = val & 0x10; buf[ofs++] = val & 0x08; buf[ofs++] = val & 0x04; buf[ofs++] = val & 0x02; buf[ofs++] = val & 0x01; if (ofs==BUFSIZE) offset = 0; else offset = ofs; }
java
public void hputbuf(int val) { int ofs = offset; buf[ofs++] = val & 0x80; buf[ofs++] = val & 0x40; buf[ofs++] = val & 0x20; buf[ofs++] = val & 0x10; buf[ofs++] = val & 0x08; buf[ofs++] = val & 0x04; buf[ofs++] = val & 0x02; buf[ofs++] = val & 0x01; if (ofs==BUFSIZE) offset = 0; else offset = ofs; }
[ "public", "void", "hputbuf", "(", "int", "val", ")", "{", "int", "ofs", "=", "offset", ";", "buf", "[", "ofs", "++", "]", "=", "val", "&", "0x80", ";", "buf", "[", "ofs", "++", "]", "=", "val", "&", "0x40", ";", "buf", "[", "ofs", "++", "]", "=", "val", "&", "0x20", ";", "buf", "[", "ofs", "++", "]", "=", "val", "&", "0x10", ";", "buf", "[", "ofs", "++", "]", "=", "val", "&", "0x08", ";", "buf", "[", "ofs", "++", "]", "=", "val", "&", "0x04", ";", "buf", "[", "ofs", "++", "]", "=", "val", "&", "0x02", ";", "buf", "[", "ofs", "++", "]", "=", "val", "&", "0x01", ";", "if", "(", "ofs", "==", "BUFSIZE", ")", "offset", "=", "0", ";", "else", "offset", "=", "ofs", ";", "}" ]
Write 8 bits into the bit stream.
[ "Write", "8", "bits", "into", "the", "bit", "stream", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/mp3/decoder/BitReserve.java#L182-L199
150,912
jtrfp/javamod
src/main/java/de/quippy/mp3/decoder/BitReserve.java
BitReserve.rewindNbytes
public void rewindNbytes(int N) { int bits = (N << 3); totbit -= bits; buf_byte_idx -= bits; if (buf_byte_idx<0) buf_byte_idx += BUFSIZE; }
java
public void rewindNbytes(int N) { int bits = (N << 3); totbit -= bits; buf_byte_idx -= bits; if (buf_byte_idx<0) buf_byte_idx += BUFSIZE; }
[ "public", "void", "rewindNbytes", "(", "int", "N", ")", "{", "int", "bits", "=", "(", "N", "<<", "3", ")", ";", "totbit", "-=", "bits", ";", "buf_byte_idx", "-=", "bits", ";", "if", "(", "buf_byte_idx", "<", "0", ")", "buf_byte_idx", "+=", "BUFSIZE", ";", "}" ]
Rewind N bytes in Stream.
[ "Rewind", "N", "bytes", "in", "Stream", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/mp3/decoder/BitReserve.java#L215-L222
150,913
Bernardo-MG/velocity-config-tool
src/main/java/com/bernardomg/velocity/tool/ConfigTool.java
ConfigTool.configure
@Override protected final void configure(final ValueParser values) { final Object velocityContext; // Value from the parser final ToolContext ctxt; // Casted context final Object decorationObj; // Value of the decoration key checkNotNull(values, "Received a null pointer as values"); velocityContext = values.get(ConfigToolConstants.VELOCITY_CONTEXT_KEY); if (velocityContext instanceof ToolContext) { ctxt = (ToolContext) velocityContext; loadFileId(ctxt); decorationObj = ctxt.get(ConfigToolConstants.DECORATION_KEY); if (decorationObj instanceof DecorationModel) { processDecoration((DecorationModel) decorationObj); } } }
java
@Override protected final void configure(final ValueParser values) { final Object velocityContext; // Value from the parser final ToolContext ctxt; // Casted context final Object decorationObj; // Value of the decoration key checkNotNull(values, "Received a null pointer as values"); velocityContext = values.get(ConfigToolConstants.VELOCITY_CONTEXT_KEY); if (velocityContext instanceof ToolContext) { ctxt = (ToolContext) velocityContext; loadFileId(ctxt); decorationObj = ctxt.get(ConfigToolConstants.DECORATION_KEY); if (decorationObj instanceof DecorationModel) { processDecoration((DecorationModel) decorationObj); } } }
[ "@", "Override", "protected", "final", "void", "configure", "(", "final", "ValueParser", "values", ")", "{", "final", "Object", "velocityContext", ";", "// Value from the parser", "final", "ToolContext", "ctxt", ";", "// Casted context", "final", "Object", "decorationObj", ";", "// Value of the decoration key", "checkNotNull", "(", "values", ",", "\"Received a null pointer as values\"", ")", ";", "velocityContext", "=", "values", ".", "get", "(", "ConfigToolConstants", ".", "VELOCITY_CONTEXT_KEY", ")", ";", "if", "(", "velocityContext", "instanceof", "ToolContext", ")", "{", "ctxt", "=", "(", "ToolContext", ")", "velocityContext", ";", "loadFileId", "(", "ctxt", ")", ";", "decorationObj", "=", "ctxt", ".", "get", "(", "ConfigToolConstants", ".", "DECORATION_KEY", ")", ";", "if", "(", "decorationObj", "instanceof", "DecorationModel", ")", "{", "processDecoration", "(", "(", "DecorationModel", ")", "decorationObj", ")", ";", "}", "}", "}" ]
Sets up the tool with the skin configuration and file id.
[ "Sets", "up", "the", "tool", "with", "the", "skin", "configuration", "and", "file", "id", "." ]
2147d9ee745573a434cd37f1c5d0c22985e80953
https://github.com/Bernardo-MG/velocity-config-tool/blob/2147d9ee745573a434cd37f1c5d0c22985e80953/src/main/java/com/bernardomg/velocity/tool/ConfigTool.java#L307-L327
150,914
actorapp/droidkit-actors
actors/src/main/java/com/droidkit/actors/ActorSystem.java
ActorSystem.addDispatcher
public void addDispatcher(String dispatcherId, AbsActorDispatcher dispatcher) { synchronized (dispatchers) { if (dispatchers.containsKey(dispatcherId)) { return; } dispatchers.put(dispatcherId, dispatcher); } }
java
public void addDispatcher(String dispatcherId, AbsActorDispatcher dispatcher) { synchronized (dispatchers) { if (dispatchers.containsKey(dispatcherId)) { return; } dispatchers.put(dispatcherId, dispatcher); } }
[ "public", "void", "addDispatcher", "(", "String", "dispatcherId", ",", "AbsActorDispatcher", "dispatcher", ")", "{", "synchronized", "(", "dispatchers", ")", "{", "if", "(", "dispatchers", ".", "containsKey", "(", "dispatcherId", ")", ")", "{", "return", ";", "}", "dispatchers", ".", "put", "(", "dispatcherId", ",", "dispatcher", ")", ";", "}", "}" ]
Registering custom dispatcher @param dispatcherId dispatcher id @param dispatcher dispatcher object
[ "Registering", "custom", "dispatcher" ]
fdb72fcfdd1c5e54a970f203a33a71fa54344217
https://github.com/actorapp/droidkit-actors/blob/fdb72fcfdd1c5e54a970f203a33a71fa54344217/actors/src/main/java/com/droidkit/actors/ActorSystem.java#L83-L90
150,915
actorapp/droidkit-actors
actors/src/main/java/com/droidkit/actors/ActorSystem.java
ActorSystem.actorOf
public <T extends Actor> ActorRef actorOf(Class<T> actor, String path) { return actorOf(Props.create(actor), path); }
java
public <T extends Actor> ActorRef actorOf(Class<T> actor, String path) { return actorOf(Props.create(actor), path); }
[ "public", "<", "T", "extends", "Actor", ">", "ActorRef", "actorOf", "(", "Class", "<", "T", ">", "actor", ",", "String", "path", ")", "{", "return", "actorOf", "(", "Props", ".", "create", "(", "actor", ")", ",", "path", ")", ";", "}" ]
Creating or getting existing actor from actor class @param actor Actor Class @param path Actor Path @param <T> Actor Class @return ActorRef
[ "Creating", "or", "getting", "existing", "actor", "from", "actor", "class" ]
fdb72fcfdd1c5e54a970f203a33a71fa54344217
https://github.com/actorapp/droidkit-actors/blob/fdb72fcfdd1c5e54a970f203a33a71fa54344217/actors/src/main/java/com/droidkit/actors/ActorSystem.java#L104-L106
150,916
actorapp/droidkit-actors
actors/src/main/java/com/droidkit/actors/ActorSystem.java
ActorSystem.actorOf
public ActorRef actorOf(Props props, String path) { String dispatcherId = props.getDispatcher() == null ? DEFAULT_DISPATCHER : props.getDispatcher(); AbsActorDispatcher mailboxesDispatcher; synchronized (dispatchers) { if (!dispatchers.containsKey(dispatcherId)) { throw new RuntimeException("Unknown dispatcherId '" + dispatcherId + "'"); } mailboxesDispatcher = dispatchers.get(dispatcherId); } return mailboxesDispatcher.referenceActor(path, props); }
java
public ActorRef actorOf(Props props, String path) { String dispatcherId = props.getDispatcher() == null ? DEFAULT_DISPATCHER : props.getDispatcher(); AbsActorDispatcher mailboxesDispatcher; synchronized (dispatchers) { if (!dispatchers.containsKey(dispatcherId)) { throw new RuntimeException("Unknown dispatcherId '" + dispatcherId + "'"); } mailboxesDispatcher = dispatchers.get(dispatcherId); } return mailboxesDispatcher.referenceActor(path, props); }
[ "public", "ActorRef", "actorOf", "(", "Props", "props", ",", "String", "path", ")", "{", "String", "dispatcherId", "=", "props", ".", "getDispatcher", "(", ")", "==", "null", "?", "DEFAULT_DISPATCHER", ":", "props", ".", "getDispatcher", "(", ")", ";", "AbsActorDispatcher", "mailboxesDispatcher", ";", "synchronized", "(", "dispatchers", ")", "{", "if", "(", "!", "dispatchers", ".", "containsKey", "(", "dispatcherId", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Unknown dispatcherId '\"", "+", "dispatcherId", "+", "\"'\"", ")", ";", "}", "mailboxesDispatcher", "=", "dispatchers", ".", "get", "(", "dispatcherId", ")", ";", "}", "return", "mailboxesDispatcher", ".", "referenceActor", "(", "path", ",", "props", ")", ";", "}" ]
Creating or getting existing actor from actor props @param props Actor Props @param path Actor Path @return ActorRef
[ "Creating", "or", "getting", "existing", "actor", "from", "actor", "props" ]
fdb72fcfdd1c5e54a970f203a33a71fa54344217
https://github.com/actorapp/droidkit-actors/blob/fdb72fcfdd1c5e54a970f203a33a71fa54344217/actors/src/main/java/com/droidkit/actors/ActorSystem.java#L115-L127
150,917
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/plugins/ExtensionPoints.java
ExtensionPoints.add
@SuppressWarnings("unchecked") public static <T extends Plugin> void add(ExtensionPoint<T> point) { ArrayList<Plugin> plugins = new ArrayList<>(); synchronized (points) { points.add(point); for (Iterator<Plugin> it = waitingPlugins.iterator(); it.hasNext(); ) { Plugin pi = it.next(); if (point.getPluginClass().isAssignableFrom(pi.getClass())) { plugins.add(pi); it.remove(); } } } synchronized (point) { for (Plugin pi : plugins) point.addPlugin((T)pi); } }
java
@SuppressWarnings("unchecked") public static <T extends Plugin> void add(ExtensionPoint<T> point) { ArrayList<Plugin> plugins = new ArrayList<>(); synchronized (points) { points.add(point); for (Iterator<Plugin> it = waitingPlugins.iterator(); it.hasNext(); ) { Plugin pi = it.next(); if (point.getPluginClass().isAssignableFrom(pi.getClass())) { plugins.add(pi); it.remove(); } } } synchronized (point) { for (Plugin pi : plugins) point.addPlugin((T)pi); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", "extends", "Plugin", ">", "void", "add", "(", "ExtensionPoint", "<", "T", ">", "point", ")", "{", "ArrayList", "<", "Plugin", ">", "plugins", "=", "new", "ArrayList", "<>", "(", ")", ";", "synchronized", "(", "points", ")", "{", "points", ".", "add", "(", "point", ")", ";", "for", "(", "Iterator", "<", "Plugin", ">", "it", "=", "waitingPlugins", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "Plugin", "pi", "=", "it", ".", "next", "(", ")", ";", "if", "(", "point", ".", "getPluginClass", "(", ")", ".", "isAssignableFrom", "(", "pi", ".", "getClass", "(", ")", ")", ")", "{", "plugins", ".", "add", "(", "pi", ")", ";", "it", ".", "remove", "(", ")", ";", "}", "}", "}", "synchronized", "(", "point", ")", "{", "for", "(", "Plugin", "pi", ":", "plugins", ")", "point", ".", "addPlugin", "(", "(", "T", ")", "pi", ")", ";", "}", "}" ]
Add an extension point.
[ "Add", "an", "extension", "point", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/plugins/ExtensionPoints.java#L31-L48
150,918
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/plugins/ExtensionPoints.java
ExtensionPoints.add
@SuppressWarnings("unchecked") public static void add(String epClassName, Plugin pi) { ExtensionPoint<Plugin> ep = null; synchronized (points) { for (ExtensionPoint<?> point : points) if (point.getClass().getName().equals(epClassName)) { ep = (ExtensionPoint<Plugin>)point; break; } if (ep == null) { waitingPlugins.add(pi); return; } } synchronized (ep) { ep.addPlugin(pi); } }
java
@SuppressWarnings("unchecked") public static void add(String epClassName, Plugin pi) { ExtensionPoint<Plugin> ep = null; synchronized (points) { for (ExtensionPoint<?> point : points) if (point.getClass().getName().equals(epClassName)) { ep = (ExtensionPoint<Plugin>)point; break; } if (ep == null) { waitingPlugins.add(pi); return; } } synchronized (ep) { ep.addPlugin(pi); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "void", "add", "(", "String", "epClassName", ",", "Plugin", "pi", ")", "{", "ExtensionPoint", "<", "Plugin", ">", "ep", "=", "null", ";", "synchronized", "(", "points", ")", "{", "for", "(", "ExtensionPoint", "<", "?", ">", "point", ":", "points", ")", "if", "(", "point", ".", "getClass", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "epClassName", ")", ")", "{", "ep", "=", "(", "ExtensionPoint", "<", "Plugin", ">", ")", "point", ";", "break", ";", "}", "if", "(", "ep", "==", "null", ")", "{", "waitingPlugins", ".", "add", "(", "pi", ")", ";", "return", ";", "}", "}", "synchronized", "(", "ep", ")", "{", "ep", ".", "addPlugin", "(", "pi", ")", ";", "}", "}" ]
Add a plug-in for the given extension point class name.
[ "Add", "a", "plug", "-", "in", "for", "the", "given", "extension", "point", "class", "name", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/plugins/ExtensionPoints.java#L58-L75
150,919
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/plugins/ExtensionPoints.java
ExtensionPoints.allPluginsLoaded
public static void allPluginsLoaded() { StringBuilder s = new StringBuilder(1024); s.append("Extension points:"); synchronized (points) { for (ExtensionPoint<?> ep : points) ep.allPluginsLoaded(); for (ExtensionPoint<?> ep : points) { s.append("\r\n- "); ep.printInfo(s); } points.trimToSize(); } synchronized (customs) { for (Iterator<CustomExtensionPoint> it = customs.iterator(); it.hasNext(); ) { CustomExtensionPoint ep = it.next(); s.append("\r\n- "); ep.printInfo(s); if (!ep.keepAfterInit()) it.remove(); } customs.trimToSize(); } LCCore.getApplication().getDefaultLogger().info(s.toString()); logRemainingPlugins(); }
java
public static void allPluginsLoaded() { StringBuilder s = new StringBuilder(1024); s.append("Extension points:"); synchronized (points) { for (ExtensionPoint<?> ep : points) ep.allPluginsLoaded(); for (ExtensionPoint<?> ep : points) { s.append("\r\n- "); ep.printInfo(s); } points.trimToSize(); } synchronized (customs) { for (Iterator<CustomExtensionPoint> it = customs.iterator(); it.hasNext(); ) { CustomExtensionPoint ep = it.next(); s.append("\r\n- "); ep.printInfo(s); if (!ep.keepAfterInit()) it.remove(); } customs.trimToSize(); } LCCore.getApplication().getDefaultLogger().info(s.toString()); logRemainingPlugins(); }
[ "public", "static", "void", "allPluginsLoaded", "(", ")", "{", "StringBuilder", "s", "=", "new", "StringBuilder", "(", "1024", ")", ";", "s", ".", "append", "(", "\"Extension points:\"", ")", ";", "synchronized", "(", "points", ")", "{", "for", "(", "ExtensionPoint", "<", "?", ">", "ep", ":", "points", ")", "ep", ".", "allPluginsLoaded", "(", ")", ";", "for", "(", "ExtensionPoint", "<", "?", ">", "ep", ":", "points", ")", "{", "s", ".", "append", "(", "\"\\r\\n- \"", ")", ";", "ep", ".", "printInfo", "(", "s", ")", ";", "}", "points", ".", "trimToSize", "(", ")", ";", "}", "synchronized", "(", "customs", ")", "{", "for", "(", "Iterator", "<", "CustomExtensionPoint", ">", "it", "=", "customs", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "CustomExtensionPoint", "ep", "=", "it", ".", "next", "(", ")", ";", "s", ".", "append", "(", "\"\\r\\n- \"", ")", ";", "ep", ".", "printInfo", "(", "s", ")", ";", "if", "(", "!", "ep", ".", "keepAfterInit", "(", ")", ")", "it", ".", "remove", "(", ")", ";", "}", "customs", ".", "trimToSize", "(", ")", ";", "}", "LCCore", ".", "getApplication", "(", ")", ".", "getDefaultLogger", "(", ")", ".", "info", "(", "s", ".", "toString", "(", ")", ")", ";", "logRemainingPlugins", "(", ")", ";", "}" ]
Call the method allPluginsLoaded on every extension point.
[ "Call", "the", "method", "allPluginsLoaded", "on", "every", "extension", "point", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/plugins/ExtensionPoints.java#L107-L131
150,920
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/plugins/ExtensionPoints.java
ExtensionPoints.logRemainingPlugins
public static void logRemainingPlugins() { Logger logger = LCCore.getApplication().getDefaultLogger(); if (!logger.warn()) return; synchronized (points) { for (Plugin pi : waitingPlugins) logger.warn("Plugin ignored because extension point is not loaded: " + pi.getClass().getName()); } }
java
public static void logRemainingPlugins() { Logger logger = LCCore.getApplication().getDefaultLogger(); if (!logger.warn()) return; synchronized (points) { for (Plugin pi : waitingPlugins) logger.warn("Plugin ignored because extension point is not loaded: " + pi.getClass().getName()); } }
[ "public", "static", "void", "logRemainingPlugins", "(", ")", "{", "Logger", "logger", "=", "LCCore", ".", "getApplication", "(", ")", ".", "getDefaultLogger", "(", ")", ";", "if", "(", "!", "logger", ".", "warn", "(", ")", ")", "return", ";", "synchronized", "(", "points", ")", "{", "for", "(", "Plugin", "pi", ":", "waitingPlugins", ")", "logger", ".", "warn", "(", "\"Plugin ignored because extension point is not loaded: \"", "+", "pi", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "}" ]
Print to the error console the plugins that are available without their corresponding extension point.
[ "Print", "to", "the", "error", "console", "the", "plugins", "that", "are", "available", "without", "their", "corresponding", "extension", "point", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/plugins/ExtensionPoints.java#L141-L149
150,921
jpaoletti/java-presentation-manager
modules/jpm-core/src/main/java/jpaoletti/jpm/core/Highlights.java
Highlights.getHighlights
public List<Highlight> getHighlights(Entity entity, Field field, Object instance) { if (field == null) { return getHighlights(entity, instance); } final List<Highlight> result = new ArrayList<Highlight>(); for (Highlight highlight : highlights) { if (!highlight.getScope().equals(INSTANCE)) { if (match(instance, field, highlight)) { result.add(highlight); } } } return result; }
java
public List<Highlight> getHighlights(Entity entity, Field field, Object instance) { if (field == null) { return getHighlights(entity, instance); } final List<Highlight> result = new ArrayList<Highlight>(); for (Highlight highlight : highlights) { if (!highlight.getScope().equals(INSTANCE)) { if (match(instance, field, highlight)) { result.add(highlight); } } } return result; }
[ "public", "List", "<", "Highlight", ">", "getHighlights", "(", "Entity", "entity", ",", "Field", "field", ",", "Object", "instance", ")", "{", "if", "(", "field", "==", "null", ")", "{", "return", "getHighlights", "(", "entity", ",", "instance", ")", ";", "}", "final", "List", "<", "Highlight", ">", "result", "=", "new", "ArrayList", "<", "Highlight", ">", "(", ")", ";", "for", "(", "Highlight", "highlight", ":", "highlights", ")", "{", "if", "(", "!", "highlight", ".", "getScope", "(", ")", ".", "equals", "(", "INSTANCE", ")", ")", "{", "if", "(", "match", "(", "instance", ",", "field", ",", "highlight", ")", ")", "{", "result", ".", "add", "(", "highlight", ")", ";", "}", "}", "}", "return", "result", ";", "}" ]
Return all the highlights that matches the given instance in the given field of the given entity @param entity The entity @param field The field @param instance The instance @return The highlight
[ "Return", "all", "the", "highlights", "that", "matches", "the", "given", "instance", "in", "the", "given", "field", "of", "the", "given", "entity" ]
d5aab55638383695db244744b4bfe27c5200e04f
https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-core/src/main/java/jpaoletti/jpm/core/Highlights.java#L58-L71
150,922
jpaoletti/java-presentation-manager
modules/jpm-core/src/main/java/jpaoletti/jpm/core/Highlights.java
Highlights.getHighlight
public Highlight getHighlight(Entity entity, Object instance) { for (Highlight highlight : highlights) { if (highlight.getScope().equals(INSTANCE)) { for (Field field : entity.getOrderedFields()) { if (match(instance, field, highlight)) { return highlight; } } } } return null; }
java
public Highlight getHighlight(Entity entity, Object instance) { for (Highlight highlight : highlights) { if (highlight.getScope().equals(INSTANCE)) { for (Field field : entity.getOrderedFields()) { if (match(instance, field, highlight)) { return highlight; } } } } return null; }
[ "public", "Highlight", "getHighlight", "(", "Entity", "entity", ",", "Object", "instance", ")", "{", "for", "(", "Highlight", "highlight", ":", "highlights", ")", "{", "if", "(", "highlight", ".", "getScope", "(", ")", ".", "equals", "(", "INSTANCE", ")", ")", "{", "for", "(", "Field", "field", ":", "entity", ".", "getOrderedFields", "(", ")", ")", "{", "if", "(", "match", "(", "instance", ",", "field", ",", "highlight", ")", ")", "{", "return", "highlight", ";", "}", "}", "}", "}", "return", "null", ";", "}" ]
Return the first highlight that match in any value of this instance with some of the highlights values. @param entity The entity @param instance The instance @return The Highlinght
[ "Return", "the", "first", "highlight", "that", "match", "in", "any", "value", "of", "this", "instance", "with", "some", "of", "the", "highlights", "values", "." ]
d5aab55638383695db244744b4bfe27c5200e04f
https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-core/src/main/java/jpaoletti/jpm/core/Highlights.java#L81-L92
150,923
jpaoletti/java-presentation-manager
modules/jpm-core/src/main/java/jpaoletti/jpm/core/Highlights.java
Highlights.match
protected boolean match(Object instance, Field field, Highlight highlight) { try { Object o = getPm().get(instance, field.getProperty()); if (o != null && o.toString().equals(highlight.getValue()) && highlight.getField().equals(field.getId())) { return true; } } catch (Exception e) { } return false; }
java
protected boolean match(Object instance, Field field, Highlight highlight) { try { Object o = getPm().get(instance, field.getProperty()); if (o != null && o.toString().equals(highlight.getValue()) && highlight.getField().equals(field.getId())) { return true; } } catch (Exception e) { } return false; }
[ "protected", "boolean", "match", "(", "Object", "instance", ",", "Field", "field", ",", "Highlight", "highlight", ")", "{", "try", "{", "Object", "o", "=", "getPm", "(", ")", ".", "get", "(", "instance", ",", "field", ".", "getProperty", "(", ")", ")", ";", "if", "(", "o", "!=", "null", "&&", "o", ".", "toString", "(", ")", ".", "equals", "(", "highlight", ".", "getValue", "(", ")", ")", "&&", "highlight", ".", "getField", "(", ")", ".", "equals", "(", "field", ".", "getId", "(", ")", ")", ")", "{", "return", "true", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "return", "false", ";", "}" ]
Indicate if the field of the given instance matches with the given highlight @param instance The instance @param field The field @param highlight The highlight @return true if match
[ "Indicate", "if", "the", "field", "of", "the", "given", "instance", "matches", "with", "the", "given", "highlight" ]
d5aab55638383695db244744b4bfe27c5200e04f
https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-core/src/main/java/jpaoletti/jpm/core/Highlights.java#L125-L134
150,924
livetribe/livetribe-slp
osgi/bundle/src/main/java/org/livetribe/slp/osgi/ByServicePropertiesServiceTracker.java
ByServicePropertiesServiceTracker.generateServiceInfo
private ServiceInfo generateServiceInfo(ServiceReference reference) { Map<String, String> map = Utils.toMap(reference); Set<String> keys = map.keySet(); String slpUrl = Utils.subst((String)reference.getProperty(SLP_URL), map); ServiceURL serviceURL; if (keys.contains(SLP_URL_LIFETIME)) { try { int lifetime = Integer.parseInt((String)reference.getProperty(SLP_URL_LIFETIME)); serviceURL = new ServiceURL(slpUrl, lifetime); } catch (NumberFormatException e) { serviceURL = new ServiceURL(slpUrl); } } else { serviceURL = new ServiceURL(slpUrl); } String language; if (keys.contains(SLP_LANGUAGE)) language = (String)reference.getProperty(SLP_LANGUAGE); else language = Locale.getDefault().getLanguage(); Scopes scopes = Scopes.NONE; if (keys.contains(SLP_SCOPES)) { String[] values = ((String)reference.getProperty(SLP_SCOPES)).split(","); for (int i = 0; i < values.length; i++) values[i] = values[i].trim(); scopes = Scopes.from(values); } ServiceType serviceType = null; if (keys.contains(SLP_SERVICE_TYPE)) { serviceType = new ServiceType((String)reference.getProperty(SLP_SERVICE_TYPE)); } map.remove(SLP_URL); map.remove(SLP_URL_LIFETIME); map.remove(SLP_LANGUAGE); map.remove(SLP_SCOPES); map.remove(SLP_SERVICE_TYPE); Attributes attributes = Attributes.from(map); ServiceInfo serviceInfo; if (serviceType != null) { serviceInfo = new ServiceInfo(serviceType, serviceURL, language, scopes, attributes); } else { serviceInfo = new ServiceInfo(serviceURL, language, scopes, attributes); } return serviceInfo; }
java
private ServiceInfo generateServiceInfo(ServiceReference reference) { Map<String, String> map = Utils.toMap(reference); Set<String> keys = map.keySet(); String slpUrl = Utils.subst((String)reference.getProperty(SLP_URL), map); ServiceURL serviceURL; if (keys.contains(SLP_URL_LIFETIME)) { try { int lifetime = Integer.parseInt((String)reference.getProperty(SLP_URL_LIFETIME)); serviceURL = new ServiceURL(slpUrl, lifetime); } catch (NumberFormatException e) { serviceURL = new ServiceURL(slpUrl); } } else { serviceURL = new ServiceURL(slpUrl); } String language; if (keys.contains(SLP_LANGUAGE)) language = (String)reference.getProperty(SLP_LANGUAGE); else language = Locale.getDefault().getLanguage(); Scopes scopes = Scopes.NONE; if (keys.contains(SLP_SCOPES)) { String[] values = ((String)reference.getProperty(SLP_SCOPES)).split(","); for (int i = 0; i < values.length; i++) values[i] = values[i].trim(); scopes = Scopes.from(values); } ServiceType serviceType = null; if (keys.contains(SLP_SERVICE_TYPE)) { serviceType = new ServiceType((String)reference.getProperty(SLP_SERVICE_TYPE)); } map.remove(SLP_URL); map.remove(SLP_URL_LIFETIME); map.remove(SLP_LANGUAGE); map.remove(SLP_SCOPES); map.remove(SLP_SERVICE_TYPE); Attributes attributes = Attributes.from(map); ServiceInfo serviceInfo; if (serviceType != null) { serviceInfo = new ServiceInfo(serviceType, serviceURL, language, scopes, attributes); } else { serviceInfo = new ServiceInfo(serviceURL, language, scopes, attributes); } return serviceInfo; }
[ "private", "ServiceInfo", "generateServiceInfo", "(", "ServiceReference", "reference", ")", "{", "Map", "<", "String", ",", "String", ">", "map", "=", "Utils", ".", "toMap", "(", "reference", ")", ";", "Set", "<", "String", ">", "keys", "=", "map", ".", "keySet", "(", ")", ";", "String", "slpUrl", "=", "Utils", ".", "subst", "(", "(", "String", ")", "reference", ".", "getProperty", "(", "SLP_URL", ")", ",", "map", ")", ";", "ServiceURL", "serviceURL", ";", "if", "(", "keys", ".", "contains", "(", "SLP_URL_LIFETIME", ")", ")", "{", "try", "{", "int", "lifetime", "=", "Integer", ".", "parseInt", "(", "(", "String", ")", "reference", ".", "getProperty", "(", "SLP_URL_LIFETIME", ")", ")", ";", "serviceURL", "=", "new", "ServiceURL", "(", "slpUrl", ",", "lifetime", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "serviceURL", "=", "new", "ServiceURL", "(", "slpUrl", ")", ";", "}", "}", "else", "{", "serviceURL", "=", "new", "ServiceURL", "(", "slpUrl", ")", ";", "}", "String", "language", ";", "if", "(", "keys", ".", "contains", "(", "SLP_LANGUAGE", ")", ")", "language", "=", "(", "String", ")", "reference", ".", "getProperty", "(", "SLP_LANGUAGE", ")", ";", "else", "language", "=", "Locale", ".", "getDefault", "(", ")", ".", "getLanguage", "(", ")", ";", "Scopes", "scopes", "=", "Scopes", ".", "NONE", ";", "if", "(", "keys", ".", "contains", "(", "SLP_SCOPES", ")", ")", "{", "String", "[", "]", "values", "=", "(", "(", "String", ")", "reference", ".", "getProperty", "(", "SLP_SCOPES", ")", ")", ".", "split", "(", "\",\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "values", ".", "length", ";", "i", "++", ")", "values", "[", "i", "]", "=", "values", "[", "i", "]", ".", "trim", "(", ")", ";", "scopes", "=", "Scopes", ".", "from", "(", "values", ")", ";", "}", "ServiceType", "serviceType", "=", "null", ";", "if", "(", "keys", ".", "contains", "(", "SLP_SERVICE_TYPE", ")", ")", "{", "serviceType", "=", "new", "ServiceType", "(", "(", "String", ")", "reference", ".", "getProperty", "(", "SLP_SERVICE_TYPE", ")", ")", ";", "}", "map", ".", "remove", "(", "SLP_URL", ")", ";", "map", ".", "remove", "(", "SLP_URL_LIFETIME", ")", ";", "map", ".", "remove", "(", "SLP_LANGUAGE", ")", ";", "map", ".", "remove", "(", "SLP_SCOPES", ")", ";", "map", ".", "remove", "(", "SLP_SERVICE_TYPE", ")", ";", "Attributes", "attributes", "=", "Attributes", ".", "from", "(", "map", ")", ";", "ServiceInfo", "serviceInfo", ";", "if", "(", "serviceType", "!=", "null", ")", "{", "serviceInfo", "=", "new", "ServiceInfo", "(", "serviceType", ",", "serviceURL", ",", "language", ",", "scopes", ",", "attributes", ")", ";", "}", "else", "{", "serviceInfo", "=", "new", "ServiceInfo", "(", "serviceURL", ",", "language", ",", "scopes", ",", "attributes", ")", ";", "}", "return", "serviceInfo", ";", "}" ]
Generate SLP service information by scraping relevant information from the OSGi service reference's properties. @param reference the OSGi service reference used to generate the SLP service information @return the generated SLP service information
[ "Generate", "SLP", "service", "information", "by", "scraping", "relevant", "information", "from", "the", "OSGi", "service", "reference", "s", "properties", "." ]
6cc13dbe81feab133fe3dd291ca081cbc6e1f591
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/osgi/bundle/src/main/java/org/livetribe/slp/osgi/ByServicePropertiesServiceTracker.java#L225-L288
150,925
actorapp/droidkit-actors
actors/src/main/java/com/droidkit/actors/Actor.java
Actor.combine
public AskFuture combine(AskCallback<Object[]> callback, AskFuture... futures) { AskFuture future = combine(futures); future.addListener(callback); return future; }
java
public AskFuture combine(AskCallback<Object[]> callback, AskFuture... futures) { AskFuture future = combine(futures); future.addListener(callback); return future; }
[ "public", "AskFuture", "combine", "(", "AskCallback", "<", "Object", "[", "]", ">", "callback", ",", "AskFuture", "...", "futures", ")", "{", "AskFuture", "future", "=", "combine", "(", "futures", ")", ";", "future", ".", "addListener", "(", "callback", ")", ";", "return", "future", ";", "}" ]
Combine multiple asks to single one @param callback asks callback @param futures futures from ask @return future
[ "Combine", "multiple", "asks", "to", "single", "one" ]
fdb72fcfdd1c5e54a970f203a33a71fa54344217
https://github.com/actorapp/droidkit-actors/blob/fdb72fcfdd1c5e54a970f203a33a71fa54344217/actors/src/main/java/com/droidkit/actors/Actor.java#L205-L209
150,926
actorapp/droidkit-actors
actors/src/main/java/com/droidkit/actors/Actor.java
Actor.ask
public <T> void ask(Future<T> future, FutureCallback<T> callback) { typedAsk.ask(future, callback); }
java
public <T> void ask(Future<T> future, FutureCallback<T> callback) { typedAsk.ask(future, callback); }
[ "public", "<", "T", ">", "void", "ask", "(", "Future", "<", "T", ">", "future", ",", "FutureCallback", "<", "T", ">", "callback", ")", "{", "typedAsk", ".", "ask", "(", "future", ",", "callback", ")", ";", "}" ]
Ask TypedActor future method for result @param future Future of ask @param callback callback for ask @param <T> type of result
[ "Ask", "TypedActor", "future", "method", "for", "result" ]
fdb72fcfdd1c5e54a970f203a33a71fa54344217
https://github.com/actorapp/droidkit-actors/blob/fdb72fcfdd1c5e54a970f203a33a71fa54344217/actors/src/main/java/com/droidkit/actors/Actor.java#L306-L308
150,927
actorapp/droidkit-actors
actors/src/main/java/com/droidkit/actors/Actor.java
Actor.proxy
public <T> T proxy(final T src, Class<T> tClass) { return callbackExtension.proxy(src, tClass); }
java
public <T> T proxy(final T src, Class<T> tClass) { return callbackExtension.proxy(src, tClass); }
[ "public", "<", "T", ">", "T", "proxy", "(", "final", "T", "src", ",", "Class", "<", "T", ">", "tClass", ")", "{", "return", "callbackExtension", ".", "proxy", "(", "src", ",", "tClass", ")", ";", "}" ]
Proxy callback interface for invoking methods as actor messages @param src sourceCallback @param tClass callback class @param <T> type of callback @return proxy callback
[ "Proxy", "callback", "interface", "for", "invoking", "methods", "as", "actor", "messages" ]
fdb72fcfdd1c5e54a970f203a33a71fa54344217
https://github.com/actorapp/droidkit-actors/blob/fdb72fcfdd1c5e54a970f203a33a71fa54344217/actors/src/main/java/com/droidkit/actors/Actor.java#L318-L320
150,928
actorapp/droidkit-actors
actors/src/main/java/com/droidkit/actors/ActorRef.java
ActorRef.sendOnce
public void sendOnce(Object message, long delay, ActorRef sender) { dispatcher.sendMessageOnce(endpoint, message, ActorTime.currentTime() + delay, sender); }
java
public void sendOnce(Object message, long delay, ActorRef sender) { dispatcher.sendMessageOnce(endpoint, message, ActorTime.currentTime() + delay, sender); }
[ "public", "void", "sendOnce", "(", "Object", "message", ",", "long", "delay", ",", "ActorRef", "sender", ")", "{", "dispatcher", ".", "sendMessageOnce", "(", "endpoint", ",", "message", ",", "ActorTime", ".", "currentTime", "(", ")", "+", "delay", ",", "sender", ")", ";", "}" ]
Send message once @param message message @param delay delay @param sender sender
[ "Send", "message", "once" ]
fdb72fcfdd1c5e54a970f203a33a71fa54344217
https://github.com/actorapp/droidkit-actors/blob/fdb72fcfdd1c5e54a970f203a33a71fa54344217/actors/src/main/java/com/droidkit/actors/ActorRef.java#L125-L127
150,929
OSSIndex/heuristic-version
src/main/java/net/ossindex/version/VersionFactory.java
VersionFactory.getVersion
public IVersion getVersion(String vstring) throws InvalidRangeException { IVersionRange range = getRange(vstring); if (range == null) { return null; } return range.getMinimum(); }
java
public IVersion getVersion(String vstring) throws InvalidRangeException { IVersionRange range = getRange(vstring); if (range == null) { return null; } return range.getMinimum(); }
[ "public", "IVersion", "getVersion", "(", "String", "vstring", ")", "throws", "InvalidRangeException", "{", "IVersionRange", "range", "=", "getRange", "(", "vstring", ")", ";", "if", "(", "range", "==", "null", ")", "{", "return", "null", ";", "}", "return", "range", ".", "getMinimum", "(", ")", ";", "}" ]
Get a version implementation. Return the best match for the provided string. @param vstring A string version to be parsed @return A version implementation
[ "Get", "a", "version", "implementation", ".", "Return", "the", "best", "match", "for", "the", "provided", "string", "." ]
9fe33a49d74acec54ddb91de9a3c3cd2f98fba40
https://github.com/OSSIndex/heuristic-version/blob/9fe33a49d74acec54ddb91de9a3c3cd2f98fba40/src/main/java/net/ossindex/version/VersionFactory.java#L106-L113
150,930
OSSIndex/heuristic-version
src/main/java/net/ossindex/version/VersionFactory.java
VersionFactory.getRange
public IVersionRange getRange(String vstring) throws InvalidRangeException { if (vstring == null || vstring.isEmpty()) { if (strict) { throw new InvalidRangeException("Cannot have an empty version"); } else { IVersion version = new NamedVersion(""); return new VersionSet(version); } } try { InputStream stream = new ByteArrayInputStream(vstring.getBytes(StandardCharsets.UTF_8)); ANTLRInputStream input = new ANTLRInputStream(stream); VersionErrorListener errorListener = new VersionErrorListener(); VersionLexer lexer = new VersionLexer(input); lexer.removeErrorListeners(); lexer.addErrorListener(errorListener); CommonTokenStream tokens = new CommonTokenStream(lexer); VersionParser parser = new VersionParser(tokens); parser.addErrorListener(errorListener); RangeContext context = parser.range(); ParseTreeWalker walker = new ParseTreeWalker(); VersionListener listener = new VersionListener(strict); walker.walk(listener, context); IVersionRange range = listener.getRange(); if (errorListener.hasErrors()) { if (strict) { throw new InvalidRangeException("Parse errors on " + vstring); } range.setHasErrors(true); } return range; } catch (EmptyStackException e) { if (strict) { throw new InvalidRangeException(e); } System.err.println("ERROR: Could not parse: " + vstring); } catch (InvalidRangeRuntimeException e) { // These are always critical. They indicate a fundamental problem with the version range. throw new InvalidRangeException(e.getMessage(), e); } catch (Exception e) { // Parse errors and wot not will come here if (strict) { throw new InvalidRangeException(e); } System.err.println("ERROR: Could not parse: " + vstring); } // Fall back to a named version IVersion version = new NamedVersion(vstring); return new VersionSet(version); }
java
public IVersionRange getRange(String vstring) throws InvalidRangeException { if (vstring == null || vstring.isEmpty()) { if (strict) { throw new InvalidRangeException("Cannot have an empty version"); } else { IVersion version = new NamedVersion(""); return new VersionSet(version); } } try { InputStream stream = new ByteArrayInputStream(vstring.getBytes(StandardCharsets.UTF_8)); ANTLRInputStream input = new ANTLRInputStream(stream); VersionErrorListener errorListener = new VersionErrorListener(); VersionLexer lexer = new VersionLexer(input); lexer.removeErrorListeners(); lexer.addErrorListener(errorListener); CommonTokenStream tokens = new CommonTokenStream(lexer); VersionParser parser = new VersionParser(tokens); parser.addErrorListener(errorListener); RangeContext context = parser.range(); ParseTreeWalker walker = new ParseTreeWalker(); VersionListener listener = new VersionListener(strict); walker.walk(listener, context); IVersionRange range = listener.getRange(); if (errorListener.hasErrors()) { if (strict) { throw new InvalidRangeException("Parse errors on " + vstring); } range.setHasErrors(true); } return range; } catch (EmptyStackException e) { if (strict) { throw new InvalidRangeException(e); } System.err.println("ERROR: Could not parse: " + vstring); } catch (InvalidRangeRuntimeException e) { // These are always critical. They indicate a fundamental problem with the version range. throw new InvalidRangeException(e.getMessage(), e); } catch (Exception e) { // Parse errors and wot not will come here if (strict) { throw new InvalidRangeException(e); } System.err.println("ERROR: Could not parse: " + vstring); } // Fall back to a named version IVersion version = new NamedVersion(vstring); return new VersionSet(version); }
[ "public", "IVersionRange", "getRange", "(", "String", "vstring", ")", "throws", "InvalidRangeException", "{", "if", "(", "vstring", "==", "null", "||", "vstring", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "strict", ")", "{", "throw", "new", "InvalidRangeException", "(", "\"Cannot have an empty version\"", ")", ";", "}", "else", "{", "IVersion", "version", "=", "new", "NamedVersion", "(", "\"\"", ")", ";", "return", "new", "VersionSet", "(", "version", ")", ";", "}", "}", "try", "{", "InputStream", "stream", "=", "new", "ByteArrayInputStream", "(", "vstring", ".", "getBytes", "(", "StandardCharsets", ".", "UTF_8", ")", ")", ";", "ANTLRInputStream", "input", "=", "new", "ANTLRInputStream", "(", "stream", ")", ";", "VersionErrorListener", "errorListener", "=", "new", "VersionErrorListener", "(", ")", ";", "VersionLexer", "lexer", "=", "new", "VersionLexer", "(", "input", ")", ";", "lexer", ".", "removeErrorListeners", "(", ")", ";", "lexer", ".", "addErrorListener", "(", "errorListener", ")", ";", "CommonTokenStream", "tokens", "=", "new", "CommonTokenStream", "(", "lexer", ")", ";", "VersionParser", "parser", "=", "new", "VersionParser", "(", "tokens", ")", ";", "parser", ".", "addErrorListener", "(", "errorListener", ")", ";", "RangeContext", "context", "=", "parser", ".", "range", "(", ")", ";", "ParseTreeWalker", "walker", "=", "new", "ParseTreeWalker", "(", ")", ";", "VersionListener", "listener", "=", "new", "VersionListener", "(", "strict", ")", ";", "walker", ".", "walk", "(", "listener", ",", "context", ")", ";", "IVersionRange", "range", "=", "listener", ".", "getRange", "(", ")", ";", "if", "(", "errorListener", ".", "hasErrors", "(", ")", ")", "{", "if", "(", "strict", ")", "{", "throw", "new", "InvalidRangeException", "(", "\"Parse errors on \"", "+", "vstring", ")", ";", "}", "range", ".", "setHasErrors", "(", "true", ")", ";", "}", "return", "range", ";", "}", "catch", "(", "EmptyStackException", "e", ")", "{", "if", "(", "strict", ")", "{", "throw", "new", "InvalidRangeException", "(", "e", ")", ";", "}", "System", ".", "err", ".", "println", "(", "\"ERROR: Could not parse: \"", "+", "vstring", ")", ";", "}", "catch", "(", "InvalidRangeRuntimeException", "e", ")", "{", "// These are always critical. They indicate a fundamental problem with the version range.", "throw", "new", "InvalidRangeException", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// Parse errors and wot not will come here", "if", "(", "strict", ")", "{", "throw", "new", "InvalidRangeException", "(", "e", ")", ";", "}", "System", ".", "err", ".", "println", "(", "\"ERROR: Could not parse: \"", "+", "vstring", ")", ";", "}", "// Fall back to a named version", "IVersion", "version", "=", "new", "NamedVersion", "(", "vstring", ")", ";", "return", "new", "VersionSet", "(", "version", ")", ";", "}" ]
Get a version range
[ "Get", "a", "version", "range" ]
9fe33a49d74acec54ddb91de9a3c3cd2f98fba40
https://github.com/OSSIndex/heuristic-version/blob/9fe33a49d74acec54ddb91de9a3c3cd2f98fba40/src/main/java/net/ossindex/version/VersionFactory.java#L132-L194
150,931
OSSIndex/heuristic-version
src/main/java/net/ossindex/version/VersionFactory.java
VersionFactory.merge
public IVersionRange merge(IVersionRange... ranges) { if (ranges.length < 2) { return ranges[0]; } // Check the type of the first range if (!(ranges[0] instanceof VersionRange)) { if (!(ranges[0] instanceof OrRange)) { throw new UnsupportedOperationException("Incorrect type for ranges[0]"); } if (((OrRange) ranges[0]).size() != 2) { throw new UnsupportedOperationException("Incorrect size for ranges[0]"); } } else { if (!((VersionRange) ranges[0]).isUnbounded()) { throw new UnsupportedOperationException("ranges[0] should be unbounded (> or >=)"); } } int lastIndex = ranges.length - 1; // Check the type of the last range if (!(ranges[lastIndex] instanceof VersionRange)) { if (!(ranges[lastIndex] instanceof OrRange)) { throw new UnsupportedOperationException("Incorrect type for ranges[last]"); } if (((OrRange) ranges[lastIndex]).size() != 2) { throw new UnsupportedOperationException("Incorrect size for ranges[last]"); } } else { if (((VersionRange) ranges[lastIndex]).isUnbounded()) { throw new UnsupportedOperationException("ranges[0] should be bounded (< or <=)"); } } // Check the rest of the types for (int i = 1; i < lastIndex; i++) { if (!(ranges[i] instanceof OrRange)) { throw new UnsupportedOperationException("Incorrect type for ranges[" + i + "]"); } if (((OrRange) ranges[i]).size() != 2) { throw new UnsupportedOperationException("Incorrect size for ranges[" + i + "]"); } } List<IVersionRange> results = new LinkedList<IVersionRange>(); IVersionRange last = null; for (int i = 0; i < ranges.length; i++) { IVersionRange range = ranges[i]; if (last == null) { if (range instanceof VersionRange) { last = range; } else { OrRange orange = (OrRange) range; results.add(orange.first()); last = orange.last(); } } else { if (range instanceof VersionRange) { AndRange arange = new AndRange(last, range); results.add(arange); last = null; } else { OrRange orange = (OrRange) range; AndRange arange = new AndRange(last, orange.first()); results.add(arange); last = orange.last(); } } } if (last != null) { results.add(last); } return new OrRange(results); }
java
public IVersionRange merge(IVersionRange... ranges) { if (ranges.length < 2) { return ranges[0]; } // Check the type of the first range if (!(ranges[0] instanceof VersionRange)) { if (!(ranges[0] instanceof OrRange)) { throw new UnsupportedOperationException("Incorrect type for ranges[0]"); } if (((OrRange) ranges[0]).size() != 2) { throw new UnsupportedOperationException("Incorrect size for ranges[0]"); } } else { if (!((VersionRange) ranges[0]).isUnbounded()) { throw new UnsupportedOperationException("ranges[0] should be unbounded (> or >=)"); } } int lastIndex = ranges.length - 1; // Check the type of the last range if (!(ranges[lastIndex] instanceof VersionRange)) { if (!(ranges[lastIndex] instanceof OrRange)) { throw new UnsupportedOperationException("Incorrect type for ranges[last]"); } if (((OrRange) ranges[lastIndex]).size() != 2) { throw new UnsupportedOperationException("Incorrect size for ranges[last]"); } } else { if (((VersionRange) ranges[lastIndex]).isUnbounded()) { throw new UnsupportedOperationException("ranges[0] should be bounded (< or <=)"); } } // Check the rest of the types for (int i = 1; i < lastIndex; i++) { if (!(ranges[i] instanceof OrRange)) { throw new UnsupportedOperationException("Incorrect type for ranges[" + i + "]"); } if (((OrRange) ranges[i]).size() != 2) { throw new UnsupportedOperationException("Incorrect size for ranges[" + i + "]"); } } List<IVersionRange> results = new LinkedList<IVersionRange>(); IVersionRange last = null; for (int i = 0; i < ranges.length; i++) { IVersionRange range = ranges[i]; if (last == null) { if (range instanceof VersionRange) { last = range; } else { OrRange orange = (OrRange) range; results.add(orange.first()); last = orange.last(); } } else { if (range instanceof VersionRange) { AndRange arange = new AndRange(last, range); results.add(arange); last = null; } else { OrRange orange = (OrRange) range; AndRange arange = new AndRange(last, orange.first()); results.add(arange); last = orange.last(); } } } if (last != null) { results.add(last); } return new OrRange(results); }
[ "public", "IVersionRange", "merge", "(", "IVersionRange", "...", "ranges", ")", "{", "if", "(", "ranges", ".", "length", "<", "2", ")", "{", "return", "ranges", "[", "0", "]", ";", "}", "// Check the type of the first range", "if", "(", "!", "(", "ranges", "[", "0", "]", "instanceof", "VersionRange", ")", ")", "{", "if", "(", "!", "(", "ranges", "[", "0", "]", "instanceof", "OrRange", ")", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Incorrect type for ranges[0]\"", ")", ";", "}", "if", "(", "(", "(", "OrRange", ")", "ranges", "[", "0", "]", ")", ".", "size", "(", ")", "!=", "2", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Incorrect size for ranges[0]\"", ")", ";", "}", "}", "else", "{", "if", "(", "!", "(", "(", "VersionRange", ")", "ranges", "[", "0", "]", ")", ".", "isUnbounded", "(", ")", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"ranges[0] should be unbounded (> or >=)\"", ")", ";", "}", "}", "int", "lastIndex", "=", "ranges", ".", "length", "-", "1", ";", "// Check the type of the last range", "if", "(", "!", "(", "ranges", "[", "lastIndex", "]", "instanceof", "VersionRange", ")", ")", "{", "if", "(", "!", "(", "ranges", "[", "lastIndex", "]", "instanceof", "OrRange", ")", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Incorrect type for ranges[last]\"", ")", ";", "}", "if", "(", "(", "(", "OrRange", ")", "ranges", "[", "lastIndex", "]", ")", ".", "size", "(", ")", "!=", "2", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Incorrect size for ranges[last]\"", ")", ";", "}", "}", "else", "{", "if", "(", "(", "(", "VersionRange", ")", "ranges", "[", "lastIndex", "]", ")", ".", "isUnbounded", "(", ")", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"ranges[0] should be bounded (< or <=)\"", ")", ";", "}", "}", "// Check the rest of the types", "for", "(", "int", "i", "=", "1", ";", "i", "<", "lastIndex", ";", "i", "++", ")", "{", "if", "(", "!", "(", "ranges", "[", "i", "]", "instanceof", "OrRange", ")", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Incorrect type for ranges[\"", "+", "i", "+", "\"]\"", ")", ";", "}", "if", "(", "(", "(", "OrRange", ")", "ranges", "[", "i", "]", ")", ".", "size", "(", ")", "!=", "2", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Incorrect size for ranges[\"", "+", "i", "+", "\"]\"", ")", ";", "}", "}", "List", "<", "IVersionRange", ">", "results", "=", "new", "LinkedList", "<", "IVersionRange", ">", "(", ")", ";", "IVersionRange", "last", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ranges", ".", "length", ";", "i", "++", ")", "{", "IVersionRange", "range", "=", "ranges", "[", "i", "]", ";", "if", "(", "last", "==", "null", ")", "{", "if", "(", "range", "instanceof", "VersionRange", ")", "{", "last", "=", "range", ";", "}", "else", "{", "OrRange", "orange", "=", "(", "OrRange", ")", "range", ";", "results", ".", "add", "(", "orange", ".", "first", "(", ")", ")", ";", "last", "=", "orange", ".", "last", "(", ")", ";", "}", "}", "else", "{", "if", "(", "range", "instanceof", "VersionRange", ")", "{", "AndRange", "arange", "=", "new", "AndRange", "(", "last", ",", "range", ")", ";", "results", ".", "add", "(", "arange", ")", ";", "last", "=", "null", ";", "}", "else", "{", "OrRange", "orange", "=", "(", "OrRange", ")", "range", ";", "AndRange", "arange", "=", "new", "AndRange", "(", "last", ",", "orange", ".", "first", "(", ")", ")", ";", "results", ".", "add", "(", "arange", ")", ";", "last", "=", "orange", ".", "last", "(", ")", ";", "}", "}", "}", "if", "(", "last", "!=", "null", ")", "{", "results", ".", "add", "(", "last", ")", ";", "}", "return", "new", "OrRange", "(", "results", ")", ";", "}" ]
Given two "or" ranges or "simple" ranges, merge them together. We are assuming that the ranges are provided in order for now. For example: >1.0.0 merged with (<2.0.0 | >3.0.0) will become (>1.0.0 <2.0.0 | >3.0.0)
[ "Given", "two", "or", "ranges", "or", "simple", "ranges", "merge", "them", "together", ".", "We", "are", "assuming", "that", "the", "ranges", "are", "provided", "in", "order", "for", "now", "." ]
9fe33a49d74acec54ddb91de9a3c3cd2f98fba40
https://github.com/OSSIndex/heuristic-version/blob/9fe33a49d74acec54ddb91de9a3c3cd2f98fba40/src/main/java/net/ossindex/version/VersionFactory.java#L242-L324
150,932
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/concurrent/synch/WaitingDataQueueSynchronizationPoint.java
WaitingDataQueueSynchronizationPoint.newDataReady
public void newDataReady(DataType data) { ArrayList<Runnable> list; synchronized (this) { if (end) throw new IllegalStateException("method endOfData already called, method newDataReady is not allowed anymore"); waitingData.addLast(data); list = listeners; listeners = null; } if (list != null) { for (Runnable listener : list) listener.run(); } // notify after listeners synchronized (this) { this.notify(); } }
java
public void newDataReady(DataType data) { ArrayList<Runnable> list; synchronized (this) { if (end) throw new IllegalStateException("method endOfData already called, method newDataReady is not allowed anymore"); waitingData.addLast(data); list = listeners; listeners = null; } if (list != null) { for (Runnable listener : list) listener.run(); } // notify after listeners synchronized (this) { this.notify(); } }
[ "public", "void", "newDataReady", "(", "DataType", "data", ")", "{", "ArrayList", "<", "Runnable", ">", "list", ";", "synchronized", "(", "this", ")", "{", "if", "(", "end", ")", "throw", "new", "IllegalStateException", "(", "\"method endOfData already called, method newDataReady is not allowed anymore\"", ")", ";", "waitingData", ".", "addLast", "(", "data", ")", ";", "list", "=", "listeners", ";", "listeners", "=", "null", ";", "}", "if", "(", "list", "!=", "null", ")", "{", "for", "(", "Runnable", "listener", ":", "list", ")", "listener", ".", "run", "(", ")", ";", "}", "// notify after listeners\r", "synchronized", "(", "this", ")", "{", "this", ".", "notify", "(", ")", ";", "}", "}" ]
Queue a new data, which may unblock a thread waiting for it.
[ "Queue", "a", "new", "data", "which", "may", "unblock", "a", "thread", "waiting", "for", "it", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/concurrent/synch/WaitingDataQueueSynchronizationPoint.java#L61-L76
150,933
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/concurrent/synch/WaitingDataQueueSynchronizationPoint.java
WaitingDataQueueSynchronizationPoint.endOfData
public void endOfData() { ArrayList<Runnable> list = null; synchronized (this) { end = true; if (waitingData.isEmpty()) { list = listeners; listeners = null; } } if (list != null) { for (Runnable listener : list) listener.run(); } // notify after listeners synchronized (this) { this.notifyAll(); } }
java
public void endOfData() { ArrayList<Runnable> list = null; synchronized (this) { end = true; if (waitingData.isEmpty()) { list = listeners; listeners = null; } } if (list != null) { for (Runnable listener : list) listener.run(); } // notify after listeners synchronized (this) { this.notifyAll(); } }
[ "public", "void", "endOfData", "(", ")", "{", "ArrayList", "<", "Runnable", ">", "list", "=", "null", ";", "synchronized", "(", "this", ")", "{", "end", "=", "true", ";", "if", "(", "waitingData", ".", "isEmpty", "(", ")", ")", "{", "list", "=", "listeners", ";", "listeners", "=", "null", ";", "}", "}", "if", "(", "list", "!=", "null", ")", "{", "for", "(", "Runnable", "listener", ":", "list", ")", "listener", ".", "run", "(", ")", ";", "}", "// notify after listeners\r", "synchronized", "(", "this", ")", "{", "this", ".", "notifyAll", "(", ")", ";", "}", "}" ]
Signal that no more data will be queued, so any waiting thread can be unblocked.
[ "Signal", "that", "no", "more", "data", "will", "be", "queued", "so", "any", "waiting", "thread", "can", "be", "unblocked", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/concurrent/synch/WaitingDataQueueSynchronizationPoint.java#L79-L95
150,934
livetribe/livetribe-slp
core/src/main/java/org/livetribe/slp/settings/Key.java
Key.from
public static <S> Key<S> from(String key, Class<? extends S> valueClass) { return new Key<S>(key, valueClass); }
java
public static <S> Key<S> from(String key, Class<? extends S> valueClass) { return new Key<S>(key, valueClass); }
[ "public", "static", "<", "S", ">", "Key", "<", "S", ">", "from", "(", "String", "key", ",", "Class", "<", "?", "extends", "S", ">", "valueClass", ")", "{", "return", "new", "Key", "<", "S", ">", "(", "key", ",", "valueClass", ")", ";", "}" ]
Creates a new Key with the given key string and value class. @param key the key string representing this Key @param valueClass the class of the value associated with this Key @return a new Key with the given key string and value class
[ "Creates", "a", "new", "Key", "with", "the", "given", "key", "string", "and", "value", "class", "." ]
6cc13dbe81feab133fe3dd291ca081cbc6e1f591
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/settings/Key.java#L39-L42
150,935
livetribe/livetribe-slp
core/src/main/java/org/livetribe/slp/settings/Key.java
Key.convert
public T convert(Object value) { T result = null; if (value != null) { if (getValueClass().isInstance(value)) result = getValueClass().cast(value); else result = convertFromString(value.toString()); } return result; }
java
public T convert(Object value) { T result = null; if (value != null) { if (getValueClass().isInstance(value)) result = getValueClass().cast(value); else result = convertFromString(value.toString()); } return result; }
[ "public", "T", "convert", "(", "Object", "value", ")", "{", "T", "result", "=", "null", ";", "if", "(", "value", "!=", "null", ")", "{", "if", "(", "getValueClass", "(", ")", ".", "isInstance", "(", "value", ")", ")", "result", "=", "getValueClass", "(", ")", ".", "cast", "(", "value", ")", ";", "else", "result", "=", "convertFromString", "(", "value", ".", "toString", "(", ")", ")", ";", "}", "return", "result", ";", "}" ]
Converts the given value object into an object of the value class specified by this Key. @param value the value to convert @return an object of the value class specified by this Key @see #convertFromString(String)
[ "Converts", "the", "given", "value", "object", "into", "an", "object", "of", "the", "value", "class", "specified", "by", "this", "Key", "." ]
6cc13dbe81feab133fe3dd291ca081cbc6e1f591
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/settings/Key.java#L82-L93
150,936
actorapp/droidkit-actors
actors/src/main/java/com/droidkit/actors/mailbox/AbsActorDispatcher.java
AbsActorDispatcher.initDispatcher
protected void initDispatcher(AbstractDispatcher<Envelope, MailboxesQueue> dispatcher) { if (this.dispatcher != null) { throw new RuntimeException("Double dispatcher init"); } this.dispatcher = dispatcher; }
java
protected void initDispatcher(AbstractDispatcher<Envelope, MailboxesQueue> dispatcher) { if (this.dispatcher != null) { throw new RuntimeException("Double dispatcher init"); } this.dispatcher = dispatcher; }
[ "protected", "void", "initDispatcher", "(", "AbstractDispatcher", "<", "Envelope", ",", "MailboxesQueue", ">", "dispatcher", ")", "{", "if", "(", "this", ".", "dispatcher", "!=", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"Double dispatcher init\"", ")", ";", "}", "this", ".", "dispatcher", "=", "dispatcher", ";", "}" ]
Must be called in super constructor @param dispatcher thread dispatcher
[ "Must", "be", "called", "in", "super", "constructor" ]
fdb72fcfdd1c5e54a970f203a33a71fa54344217
https://github.com/actorapp/droidkit-actors/blob/fdb72fcfdd1c5e54a970f203a33a71fa54344217/actors/src/main/java/com/droidkit/actors/mailbox/AbsActorDispatcher.java#L39-L44
150,937
hawkular/hawkular-inventory
hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/PathFragment.java
PathFragment.from
public static PathFragment[] from(Filter... filters) { PathFragment[] ret = new PathFragment[filters.length]; Arrays.setAll(ret, (i) -> new PathFragment(filters[i])); return ret; }
java
public static PathFragment[] from(Filter... filters) { PathFragment[] ret = new PathFragment[filters.length]; Arrays.setAll(ret, (i) -> new PathFragment(filters[i])); return ret; }
[ "public", "static", "PathFragment", "[", "]", "from", "(", "Filter", "...", "filters", ")", "{", "PathFragment", "[", "]", "ret", "=", "new", "PathFragment", "[", "filters", ".", "length", "]", ";", "Arrays", ".", "setAll", "(", "ret", ",", "(", "i", ")", "-", ">", "new", "PathFragment", "(", "filters", "[", "i", "]", ")", ")", ";", "return", "ret", ";", "}" ]
Constructs path fragments corresponding to the provided filters. @param filters the filters to create path fragments from @return the path fragments
[ "Constructs", "path", "fragments", "corresponding", "to", "the", "provided", "filters", "." ]
f56dc10323dca21777feb5b609a9e9cc70ffaf62
https://github.com/hawkular/hawkular-inventory/blob/f56dc10323dca21777feb5b609a9e9cc70ffaf62/hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/PathFragment.java#L38-L42
150,938
livetribe/livetribe-slp
core/src/main/java/org/livetribe/slp/spi/msg/IdentifierExtension.java
IdentifierExtension.findFirst
public static IdentifierExtension findFirst(Collection<? extends Extension> extensions) { for (Extension extension : extensions) { if (IDENTIFIER_EXTENSION_ID == extension.getId()) return (IdentifierExtension)extension; } return null; }
java
public static IdentifierExtension findFirst(Collection<? extends Extension> extensions) { for (Extension extension : extensions) { if (IDENTIFIER_EXTENSION_ID == extension.getId()) return (IdentifierExtension)extension; } return null; }
[ "public", "static", "IdentifierExtension", "findFirst", "(", "Collection", "<", "?", "extends", "Extension", ">", "extensions", ")", "{", "for", "(", "Extension", "extension", ":", "extensions", ")", "{", "if", "(", "IDENTIFIER_EXTENSION_ID", "==", "extension", ".", "getId", "(", ")", ")", "return", "(", "IdentifierExtension", ")", "extension", ";", "}", "return", "null", ";", "}" ]
Returns the first IdentifierExtension found in the given collection of extensions, or null if no IdentifierExtensions exist in the given collection.
[ "Returns", "the", "first", "IdentifierExtension", "found", "in", "the", "given", "collection", "of", "extensions", "or", "null", "if", "no", "IdentifierExtensions", "exist", "in", "the", "given", "collection", "." ]
6cc13dbe81feab133fe3dd291ca081cbc6e1f591
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/spi/msg/IdentifierExtension.java#L182-L189
150,939
livetribe/livetribe-slp
core/src/main/java/org/livetribe/slp/spi/msg/IdentifierExtension.java
IdentifierExtension.findAll
public static Collection<IdentifierExtension> findAll(Collection<? extends Extension> extensions) { List<IdentifierExtension> result = new ArrayList<IdentifierExtension>(); for (Extension extension : extensions) { if (IDENTIFIER_EXTENSION_ID == extension.getId()) result.add((IdentifierExtension)extension); } return result; }
java
public static Collection<IdentifierExtension> findAll(Collection<? extends Extension> extensions) { List<IdentifierExtension> result = new ArrayList<IdentifierExtension>(); for (Extension extension : extensions) { if (IDENTIFIER_EXTENSION_ID == extension.getId()) result.add((IdentifierExtension)extension); } return result; }
[ "public", "static", "Collection", "<", "IdentifierExtension", ">", "findAll", "(", "Collection", "<", "?", "extends", "Extension", ">", "extensions", ")", "{", "List", "<", "IdentifierExtension", ">", "result", "=", "new", "ArrayList", "<", "IdentifierExtension", ">", "(", ")", ";", "for", "(", "Extension", "extension", ":", "extensions", ")", "{", "if", "(", "IDENTIFIER_EXTENSION_ID", "==", "extension", ".", "getId", "(", ")", ")", "result", ".", "add", "(", "(", "IdentifierExtension", ")", "extension", ")", ";", "}", "return", "result", ";", "}" ]
Returns all IdentifierExtensions found in the given collection of extensions.
[ "Returns", "all", "IdentifierExtensions", "found", "in", "the", "given", "collection", "of", "extensions", "." ]
6cc13dbe81feab133fe3dd291ca081cbc6e1f591
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/spi/msg/IdentifierExtension.java#L194-L202
150,940
jtrfp/javamod
src/main/java/de/quippy/mp3/decoder/JavaLayerUtils.java
JavaLayerUtils.deserialize
static public Object deserialize(InputStream in, Class<?> cls) throws IOException { if (cls==null) throw new NullPointerException("cls"); Object obj = deserialize(in); if (!cls.isInstance(obj)) { throw new InvalidObjectException("type of deserialized instance not of required class."); } return obj; }
java
static public Object deserialize(InputStream in, Class<?> cls) throws IOException { if (cls==null) throw new NullPointerException("cls"); Object obj = deserialize(in); if (!cls.isInstance(obj)) { throw new InvalidObjectException("type of deserialized instance not of required class."); } return obj; }
[ "static", "public", "Object", "deserialize", "(", "InputStream", "in", ",", "Class", "<", "?", ">", "cls", ")", "throws", "IOException", "{", "if", "(", "cls", "==", "null", ")", "throw", "new", "NullPointerException", "(", "\"cls\"", ")", ";", "Object", "obj", "=", "deserialize", "(", "in", ")", ";", "if", "(", "!", "cls", ".", "isInstance", "(", "obj", ")", ")", "{", "throw", "new", "InvalidObjectException", "(", "\"type of deserialized instance not of required class.\"", ")", ";", "}", "return", "obj", ";", "}" ]
Deserializes the object contained in the given input stream. @param in The input stream to deserialize an object from. @param cls The expected class of the deserialized object.
[ "Deserializes", "the", "object", "contained", "in", "the", "given", "input", "stream", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/mp3/decoder/JavaLayerUtils.java#L47-L60
150,941
jtrfp/javamod
src/main/java/de/quippy/mp3/decoder/JavaLayerUtils.java
JavaLayerUtils.getResourceAsStream
static synchronized public InputStream getResourceAsStream(String name) { InputStream is = null; if (hook!=null) { is = hook.getResourceAsStream(name); } else { Class<JavaLayerUtils> cls = JavaLayerUtils.class; is = cls.getResourceAsStream(name); } return is; }
java
static synchronized public InputStream getResourceAsStream(String name) { InputStream is = null; if (hook!=null) { is = hook.getResourceAsStream(name); } else { Class<JavaLayerUtils> cls = JavaLayerUtils.class; is = cls.getResourceAsStream(name); } return is; }
[ "static", "synchronized", "public", "InputStream", "getResourceAsStream", "(", "String", "name", ")", "{", "InputStream", "is", "=", "null", ";", "if", "(", "hook", "!=", "null", ")", "{", "is", "=", "hook", ".", "getResourceAsStream", "(", "name", ")", ";", "}", "else", "{", "Class", "<", "JavaLayerUtils", ">", "cls", "=", "JavaLayerUtils", ".", "class", ";", "is", "=", "cls", ".", "getResourceAsStream", "(", "name", ")", ";", "}", "return", "is", ";", "}" ]
Retrieves an InputStream for a named resource. @param name The name of the resource. This must be a simple name, and not a qualified package name. @return The InputStream for the named resource, or null if the resource has not been found. If a hook has been provided, its getResourceAsStream() method is called to retrieve the resource.
[ "Retrieves", "an", "InputStream", "for", "a", "named", "resource", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/mp3/decoder/JavaLayerUtils.java#L191-L206
150,942
jtgeiger/iptools
src/main/java/com/sibilantsolutions/iptools/net/ReceiveQueue.java
ReceiveQueue.shutdownAndAwaitTermination
private void shutdownAndAwaitTermination( ExecutorService pool, int queueSize ) { log.info( "Shutting down executor service; queue size={}.", queueSize ); pool.shutdown(); // Disable new tasks from being submitted log.info( "Waiting for executor service to finish all queued tasks." ); try { // Wait a while for existing tasks to terminate if ( ! pool.awaitTermination( 60, TimeUnit.SECONDS ) ) { log.info( "Executor service did not terminate before timeout; forcing shutdown." ); List<Runnable> queuedTasks = pool.shutdownNow(); // Cancel currently executing tasks log.info( "Discarded {} tasks that were still queued; still waiting for executor service to terminate." , queuedTasks.size() ); // Wait a while for tasks to respond to being cancelled if ( ! pool.awaitTermination( 60, TimeUnit.SECONDS ) ) { log.error( "Pool did not terminate." ); } else { log.info( "Executor service terminated after forced shutdown." ); } } else { log.info( "Executor service finished all queued tasks and terminated." ); } } catch ( InterruptedException ie ) { log.error( "Interrupted while waiting for pool to terminate; forcing shutdown.", ie ); // (Re-)Cancel if current thread also interrupted List<Runnable> queuedTasks = pool.shutdownNow(); log.info( "Discarded {} tasks that were still queued; no longer waiting for executor service to terminate." , queuedTasks.size() ); // Preserve interrupt status Thread.currentThread().interrupt(); } }
java
private void shutdownAndAwaitTermination( ExecutorService pool, int queueSize ) { log.info( "Shutting down executor service; queue size={}.", queueSize ); pool.shutdown(); // Disable new tasks from being submitted log.info( "Waiting for executor service to finish all queued tasks." ); try { // Wait a while for existing tasks to terminate if ( ! pool.awaitTermination( 60, TimeUnit.SECONDS ) ) { log.info( "Executor service did not terminate before timeout; forcing shutdown." ); List<Runnable> queuedTasks = pool.shutdownNow(); // Cancel currently executing tasks log.info( "Discarded {} tasks that were still queued; still waiting for executor service to terminate." , queuedTasks.size() ); // Wait a while for tasks to respond to being cancelled if ( ! pool.awaitTermination( 60, TimeUnit.SECONDS ) ) { log.error( "Pool did not terminate." ); } else { log.info( "Executor service terminated after forced shutdown." ); } } else { log.info( "Executor service finished all queued tasks and terminated." ); } } catch ( InterruptedException ie ) { log.error( "Interrupted while waiting for pool to terminate; forcing shutdown.", ie ); // (Re-)Cancel if current thread also interrupted List<Runnable> queuedTasks = pool.shutdownNow(); log.info( "Discarded {} tasks that were still queued; no longer waiting for executor service to terminate." , queuedTasks.size() ); // Preserve interrupt status Thread.currentThread().interrupt(); } }
[ "private", "void", "shutdownAndAwaitTermination", "(", "ExecutorService", "pool", ",", "int", "queueSize", ")", "{", "log", ".", "info", "(", "\"Shutting down executor service; queue size={}.\"", ",", "queueSize", ")", ";", "pool", ".", "shutdown", "(", ")", ";", "// Disable new tasks from being submitted", "log", ".", "info", "(", "\"Waiting for executor service to finish all queued tasks.\"", ")", ";", "try", "{", "// Wait a while for existing tasks to terminate", "if", "(", "!", "pool", ".", "awaitTermination", "(", "60", ",", "TimeUnit", ".", "SECONDS", ")", ")", "{", "log", ".", "info", "(", "\"Executor service did not terminate before timeout; forcing shutdown.\"", ")", ";", "List", "<", "Runnable", ">", "queuedTasks", "=", "pool", ".", "shutdownNow", "(", ")", ";", "// Cancel currently executing tasks", "log", ".", "info", "(", "\"Discarded {} tasks that were still queued; still waiting for executor service to terminate.\"", ",", "queuedTasks", ".", "size", "(", ")", ")", ";", "// Wait a while for tasks to respond to being cancelled", "if", "(", "!", "pool", ".", "awaitTermination", "(", "60", ",", "TimeUnit", ".", "SECONDS", ")", ")", "{", "log", ".", "error", "(", "\"Pool did not terminate.\"", ")", ";", "}", "else", "{", "log", ".", "info", "(", "\"Executor service terminated after forced shutdown.\"", ")", ";", "}", "}", "else", "{", "log", ".", "info", "(", "\"Executor service finished all queued tasks and terminated.\"", ")", ";", "}", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "log", ".", "error", "(", "\"Interrupted while waiting for pool to terminate; forcing shutdown.\"", ",", "ie", ")", ";", "// (Re-)Cancel if current thread also interrupted", "List", "<", "Runnable", ">", "queuedTasks", "=", "pool", ".", "shutdownNow", "(", ")", ";", "log", ".", "info", "(", "\"Discarded {} tasks that were still queued; no longer waiting for executor service to terminate.\"", ",", "queuedTasks", ".", "size", "(", ")", ")", ";", "// Preserve interrupt status", "Thread", ".", "currentThread", "(", ")", ".", "interrupt", "(", ")", ";", "}", "}" ]
Adapted from example in javadoc of ExecutorService.
[ "Adapted", "from", "example", "in", "javadoc", "of", "ExecutorService", "." ]
45059bdae220c273e40765438ff811691a34f976
https://github.com/jtgeiger/iptools/blob/45059bdae220c273e40765438ff811691a34f976/src/main/java/com/sibilantsolutions/iptools/net/ReceiveQueue.java#L119-L167
150,943
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/io/IOAsInputStream.java
IOAsInputStream.get
public static InputStream get(IO.Readable io, boolean closeAsync) { if (io instanceof IOFromInputStream) return ((IOFromInputStream)io).getInputStream(); if (io instanceof IO.Readable.Buffered) return new BufferedToInputStream((IO.Readable.Buffered)io, closeAsync); return new IOAsInputStream(io); }
java
public static InputStream get(IO.Readable io, boolean closeAsync) { if (io instanceof IOFromInputStream) return ((IOFromInputStream)io).getInputStream(); if (io instanceof IO.Readable.Buffered) return new BufferedToInputStream((IO.Readable.Buffered)io, closeAsync); return new IOAsInputStream(io); }
[ "public", "static", "InputStream", "get", "(", "IO", ".", "Readable", "io", ",", "boolean", "closeAsync", ")", "{", "if", "(", "io", "instanceof", "IOFromInputStream", ")", "return", "(", "(", "IOFromInputStream", ")", "io", ")", ".", "getInputStream", "(", ")", ";", "if", "(", "io", "instanceof", "IO", ".", "Readable", ".", "Buffered", ")", "return", "new", "BufferedToInputStream", "(", "(", "IO", ".", "Readable", ".", "Buffered", ")", "io", ",", "closeAsync", ")", ";", "return", "new", "IOAsInputStream", "(", "io", ")", ";", "}" ]
Get an instance for the given IO.
[ "Get", "an", "instance", "for", "the", "given", "IO", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/io/IOAsInputStream.java#L17-L23
150,944
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/io/buffering/BufferedReverseIOReading.java
BufferedReverseIOReading.readReverse
public int readReverse() throws IOException { int b; do { canRead.block(0); synchronized (this) { if (error != null) throw error; if (io == null) throw new IOException("IO closed"); // check if we reached the beginning of the file if (bufferPosInFile == 0 && posInBuffer == minInBuffer) return -1; if (posInBuffer == minInBuffer) { // we are reading faster than buffering if (currentRead != null) canRead.restart(); else readBufferBack(); b = -1; } else { b = buffer[--posInBuffer] & 0xFF; if (currentRead == null && posInBuffer < buffer.length / 2 && bufferPosInFile > 0) readBufferBack(); } } } while (b == -1); return b; }
java
public int readReverse() throws IOException { int b; do { canRead.block(0); synchronized (this) { if (error != null) throw error; if (io == null) throw new IOException("IO closed"); // check if we reached the beginning of the file if (bufferPosInFile == 0 && posInBuffer == minInBuffer) return -1; if (posInBuffer == minInBuffer) { // we are reading faster than buffering if (currentRead != null) canRead.restart(); else readBufferBack(); b = -1; } else { b = buffer[--posInBuffer] & 0xFF; if (currentRead == null && posInBuffer < buffer.length / 2 && bufferPosInFile > 0) readBufferBack(); } } } while (b == -1); return b; }
[ "public", "int", "readReverse", "(", ")", "throws", "IOException", "{", "int", "b", ";", "do", "{", "canRead", ".", "block", "(", "0", ")", ";", "synchronized", "(", "this", ")", "{", "if", "(", "error", "!=", "null", ")", "throw", "error", ";", "if", "(", "io", "==", "null", ")", "throw", "new", "IOException", "(", "\"IO closed\"", ")", ";", "// check if we reached the beginning of the file\r", "if", "(", "bufferPosInFile", "==", "0", "&&", "posInBuffer", "==", "minInBuffer", ")", "return", "-", "1", ";", "if", "(", "posInBuffer", "==", "minInBuffer", ")", "{", "// we are reading faster than buffering\r", "if", "(", "currentRead", "!=", "null", ")", "canRead", ".", "restart", "(", ")", ";", "else", "readBufferBack", "(", ")", ";", "b", "=", "-", "1", ";", "}", "else", "{", "b", "=", "buffer", "[", "--", "posInBuffer", "]", "&", "0xFF", ";", "if", "(", "currentRead", "==", "null", "&&", "posInBuffer", "<", "buffer", ".", "length", "/", "2", "&&", "bufferPosInFile", ">", "0", ")", "readBufferBack", "(", ")", ";", "}", "}", "}", "while", "(", "b", "==", "-", "1", ")", ";", "return", "b", ";", "}" ]
Read a byte backward.
[ "Read", "a", "byte", "backward", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/io/buffering/BufferedReverseIOReading.java#L114-L138
150,945
icode/ameba-utils
src/main/java/ameba/captcha/audio/Sample.java
Sample.getSampleCount
public long getSampleCount() { long total = (_audioInputStream.getFrameLength() * getFormat().getFrameSize() * 8) / getFormat().getSampleSizeInBits(); return total / getFormat().getChannels(); }
java
public long getSampleCount() { long total = (_audioInputStream.getFrameLength() * getFormat().getFrameSize() * 8) / getFormat().getSampleSizeInBits(); return total / getFormat().getChannels(); }
[ "public", "long", "getSampleCount", "(", ")", "{", "long", "total", "=", "(", "_audioInputStream", ".", "getFrameLength", "(", ")", "*", "getFormat", "(", ")", ".", "getFrameSize", "(", ")", "*", "8", ")", "/", "getFormat", "(", ")", ".", "getSampleSizeInBits", "(", ")", ";", "return", "total", "/", "getFormat", "(", ")", ".", "getChannels", "(", ")", ";", "}" ]
Return the number of samples of all channels @return The number of samples for all channels
[ "Return", "the", "number", "of", "samples", "of", "all", "channels" ]
1aad5317a22e546c83dfe2dc0c80a1dc1fa0ea35
https://github.com/icode/ameba-utils/blob/1aad5317a22e546c83dfe2dc0c80a1dc1fa0ea35/src/main/java/ameba/captcha/audio/Sample.java#L123-L128
150,946
icode/ameba-utils
src/main/java/ameba/captcha/audio/Sample.java
Sample.getChannelSamples
public void getChannelSamples(int channel, double[] interleavedSamples, double[] channelSamples) { int nbChannels = getFormat().getChannels(); for (int i = 0; i < channelSamples.length; i++) { channelSamples[i] = interleavedSamples[nbChannels * i + channel]; } }
java
public void getChannelSamples(int channel, double[] interleavedSamples, double[] channelSamples) { int nbChannels = getFormat().getChannels(); for (int i = 0; i < channelSamples.length; i++) { channelSamples[i] = interleavedSamples[nbChannels * i + channel]; } }
[ "public", "void", "getChannelSamples", "(", "int", "channel", ",", "double", "[", "]", "interleavedSamples", ",", "double", "[", "]", "channelSamples", ")", "{", "int", "nbChannels", "=", "getFormat", "(", ")", ".", "getChannels", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "channelSamples", ".", "length", ";", "i", "++", ")", "{", "channelSamples", "[", "i", "]", "=", "interleavedSamples", "[", "nbChannels", "*", "i", "+", "channel", "]", ";", "}", "}" ]
Extract samples of a particular channel from interleavedSamples and copy them into channelSamples @param channel channel @param channelSamples channelSamples @param interleavedSamples interleavedSamples @param channelSamples channelSamples
[ "Extract", "samples", "of", "a", "particular", "channel", "from", "interleavedSamples", "and", "copy", "them", "into", "channelSamples" ]
1aad5317a22e546c83dfe2dc0c80a1dc1fa0ea35
https://github.com/icode/ameba-utils/blob/1aad5317a22e546c83dfe2dc0c80a1dc1fa0ea35/src/main/java/ameba/captcha/audio/Sample.java#L188-L194
150,947
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.removeUncheckedPlugins
public Collection<Plugin> removeUncheckedPlugins( Collection<String> uncheckedPlugins, Collection<Plugin> plugins ) throws MojoExecutionException { if ( uncheckedPlugins != null && !uncheckedPlugins.isEmpty() ) { for ( String pluginKey : uncheckedPlugins ) { Plugin plugin = parsePluginString( pluginKey, "UncheckedPlugins" ); plugins.remove( plugin ); } } return plugins; }
java
public Collection<Plugin> removeUncheckedPlugins( Collection<String> uncheckedPlugins, Collection<Plugin> plugins ) throws MojoExecutionException { if ( uncheckedPlugins != null && !uncheckedPlugins.isEmpty() ) { for ( String pluginKey : uncheckedPlugins ) { Plugin plugin = parsePluginString( pluginKey, "UncheckedPlugins" ); plugins.remove( plugin ); } } return plugins; }
[ "public", "Collection", "<", "Plugin", ">", "removeUncheckedPlugins", "(", "Collection", "<", "String", ">", "uncheckedPlugins", ",", "Collection", "<", "Plugin", ">", "plugins", ")", "throws", "MojoExecutionException", "{", "if", "(", "uncheckedPlugins", "!=", "null", "&&", "!", "uncheckedPlugins", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "String", "pluginKey", ":", "uncheckedPlugins", ")", "{", "Plugin", "plugin", "=", "parsePluginString", "(", "pluginKey", ",", "\"UncheckedPlugins\"", ")", ";", "plugins", ".", "remove", "(", "plugin", ")", ";", "}", "}", "return", "plugins", ";", "}" ]
Remove the plugins that the user doesn't want to check. @param uncheckedPlugins @param plugins @throws MojoExecutionException @return
[ "Remove", "the", "plugins", "that", "the", "user", "doesn", "t", "want", "to", "check", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L382-L394
150,948
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.combineUncheckedPlugins
public Collection<String> combineUncheckedPlugins( Collection<String> uncheckedPlugins, String uncheckedPluginsList ) { //if the comma list is empty, then there's nothing to do here. if ( StringUtils.isNotEmpty( uncheckedPluginsList ) ) { //make sure there is a collection to add to. if ( uncheckedPlugins == null ) { uncheckedPlugins = new HashSet<String>(); } else if ( !uncheckedPlugins.isEmpty() && log != null ) { log.warn( "The parameter 'unCheckedPlugins' is deprecated. Use 'unCheckedPluginList' instead" ); } uncheckedPlugins.addAll( Arrays.asList( uncheckedPluginsList.split( "," ) ) ); } return uncheckedPlugins; }
java
public Collection<String> combineUncheckedPlugins( Collection<String> uncheckedPlugins, String uncheckedPluginsList ) { //if the comma list is empty, then there's nothing to do here. if ( StringUtils.isNotEmpty( uncheckedPluginsList ) ) { //make sure there is a collection to add to. if ( uncheckedPlugins == null ) { uncheckedPlugins = new HashSet<String>(); } else if ( !uncheckedPlugins.isEmpty() && log != null ) { log.warn( "The parameter 'unCheckedPlugins' is deprecated. Use 'unCheckedPluginList' instead" ); } uncheckedPlugins.addAll( Arrays.asList( uncheckedPluginsList.split( "," ) ) ); } return uncheckedPlugins; }
[ "public", "Collection", "<", "String", ">", "combineUncheckedPlugins", "(", "Collection", "<", "String", ">", "uncheckedPlugins", ",", "String", "uncheckedPluginsList", ")", "{", "//if the comma list is empty, then there's nothing to do here.", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "uncheckedPluginsList", ")", ")", "{", "//make sure there is a collection to add to.", "if", "(", "uncheckedPlugins", "==", "null", ")", "{", "uncheckedPlugins", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "}", "else", "if", "(", "!", "uncheckedPlugins", ".", "isEmpty", "(", ")", "&&", "log", "!=", "null", ")", "{", "log", ".", "warn", "(", "\"The parameter 'unCheckedPlugins' is deprecated. Use 'unCheckedPluginList' instead\"", ")", ";", "}", "uncheckedPlugins", ".", "addAll", "(", "Arrays", ".", "asList", "(", "uncheckedPluginsList", ".", "split", "(", "\",\"", ")", ")", ")", ";", "}", "return", "uncheckedPlugins", ";", "}" ]
Combines the old Collection with the new comma separated list. @param uncheckedPlugins @param uncheckedPluginsList @return
[ "Combines", "the", "old", "Collection", "with", "the", "new", "comma", "separated", "list", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L402-L420
150,949
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.addAdditionalPlugins
public Set<Plugin> addAdditionalPlugins( Set<Plugin> existing, List<String> additional ) throws MojoExecutionException { if ( additional != null ) { for ( String pluginString : additional ) { Plugin plugin = parsePluginString( pluginString, "AdditionalPlugins" ); if ( existing == null ) { existing = new HashSet<Plugin>(); existing.add( plugin ); } else if ( !existing.contains( plugin ) ) { existing.add( plugin ); } } } return existing; }
java
public Set<Plugin> addAdditionalPlugins( Set<Plugin> existing, List<String> additional ) throws MojoExecutionException { if ( additional != null ) { for ( String pluginString : additional ) { Plugin plugin = parsePluginString( pluginString, "AdditionalPlugins" ); if ( existing == null ) { existing = new HashSet<Plugin>(); existing.add( plugin ); } else if ( !existing.contains( plugin ) ) { existing.add( plugin ); } } } return existing; }
[ "public", "Set", "<", "Plugin", ">", "addAdditionalPlugins", "(", "Set", "<", "Plugin", ">", "existing", ",", "List", "<", "String", ">", "additional", ")", "throws", "MojoExecutionException", "{", "if", "(", "additional", "!=", "null", ")", "{", "for", "(", "String", "pluginString", ":", "additional", ")", "{", "Plugin", "plugin", "=", "parsePluginString", "(", "pluginString", ",", "\"AdditionalPlugins\"", ")", ";", "if", "(", "existing", "==", "null", ")", "{", "existing", "=", "new", "HashSet", "<", "Plugin", ">", "(", ")", ";", "existing", ".", "add", "(", "plugin", ")", ";", "}", "else", "if", "(", "!", "existing", ".", "contains", "(", "plugin", ")", ")", "{", "existing", ".", "add", "(", "plugin", ")", ";", "}", "}", "}", "return", "existing", ";", "}" ]
Add the additional plugins if they don't exist yet. @param existing the existing @param additional the additional @return the sets the @throws MojoExecutionException the mojo execution exception
[ "Add", "the", "additional", "plugins", "if", "they", "don", "t", "exist", "yet", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L430-L451
150,950
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.parsePluginString
protected Plugin parsePluginString( String pluginString, String field ) throws MojoExecutionException { if ( pluginString != null ) { String[] pluginStrings = pluginString.split( ":" ); if ( pluginStrings.length == 2 ) { Plugin plugin = new Plugin(); plugin.setGroupId( StringUtils.strip( pluginStrings[0] ) ); plugin.setArtifactId( StringUtils.strip( pluginStrings[1] ) ); return plugin; } else { throw new MojoExecutionException( "Invalid " + field + " string: " + pluginString ); } } else { throw new MojoExecutionException( "Invalid " + field + " string: " + pluginString ); } }
java
protected Plugin parsePluginString( String pluginString, String field ) throws MojoExecutionException { if ( pluginString != null ) { String[] pluginStrings = pluginString.split( ":" ); if ( pluginStrings.length == 2 ) { Plugin plugin = new Plugin(); plugin.setGroupId( StringUtils.strip( pluginStrings[0] ) ); plugin.setArtifactId( StringUtils.strip( pluginStrings[1] ) ); return plugin; } else { throw new MojoExecutionException( "Invalid " + field + " string: " + pluginString ); } } else { throw new MojoExecutionException( "Invalid " + field + " string: " + pluginString ); } }
[ "protected", "Plugin", "parsePluginString", "(", "String", "pluginString", ",", "String", "field", ")", "throws", "MojoExecutionException", "{", "if", "(", "pluginString", "!=", "null", ")", "{", "String", "[", "]", "pluginStrings", "=", "pluginString", ".", "split", "(", "\":\"", ")", ";", "if", "(", "pluginStrings", ".", "length", "==", "2", ")", "{", "Plugin", "plugin", "=", "new", "Plugin", "(", ")", ";", "plugin", ".", "setGroupId", "(", "StringUtils", ".", "strip", "(", "pluginStrings", "[", "0", "]", ")", ")", ";", "plugin", ".", "setArtifactId", "(", "StringUtils", ".", "strip", "(", "pluginStrings", "[", "1", "]", ")", ")", ";", "return", "plugin", ";", "}", "else", "{", "throw", "new", "MojoExecutionException", "(", "\"Invalid \"", "+", "field", "+", "\" string: \"", "+", "pluginString", ")", ";", "}", "}", "else", "{", "throw", "new", "MojoExecutionException", "(", "\"Invalid \"", "+", "field", "+", "\" string: \"", "+", "pluginString", ")", ";", "}", "}" ]
Helper method to parse and inject a Plugin. @param pluginString @param field @throws MojoExecutionException @return the plugin
[ "Helper", "method", "to", "parse", "and", "inject", "a", "Plugin", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L461-L485
150,951
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.getProfilePlugins
public Set<Plugin> getProfilePlugins( MavenProject project ) { Set<Plugin> result = new HashSet<Plugin>(); @SuppressWarnings( "unchecked" ) List<Profile> profiles = project.getActiveProfiles(); if ( profiles != null && !profiles.isEmpty() ) { for ( Profile p : profiles ) { BuildBase b = p.getBuild(); if ( b != null ) { @SuppressWarnings( "unchecked" ) List<Plugin> plugins = b.getPlugins(); if ( plugins != null ) { result.addAll( plugins ); } } } } return result; }
java
public Set<Plugin> getProfilePlugins( MavenProject project ) { Set<Plugin> result = new HashSet<Plugin>(); @SuppressWarnings( "unchecked" ) List<Profile> profiles = project.getActiveProfiles(); if ( profiles != null && !profiles.isEmpty() ) { for ( Profile p : profiles ) { BuildBase b = p.getBuild(); if ( b != null ) { @SuppressWarnings( "unchecked" ) List<Plugin> plugins = b.getPlugins(); if ( plugins != null ) { result.addAll( plugins ); } } } } return result; }
[ "public", "Set", "<", "Plugin", ">", "getProfilePlugins", "(", "MavenProject", "project", ")", "{", "Set", "<", "Plugin", ">", "result", "=", "new", "HashSet", "<", "Plugin", ">", "(", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "Profile", ">", "profiles", "=", "project", ".", "getActiveProfiles", "(", ")", ";", "if", "(", "profiles", "!=", "null", "&&", "!", "profiles", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "Profile", "p", ":", "profiles", ")", "{", "BuildBase", "b", "=", "p", ".", "getBuild", "(", ")", ";", "if", "(", "b", "!=", "null", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "Plugin", ">", "plugins", "=", "b", ".", "getPlugins", "(", ")", ";", "if", "(", "plugins", "!=", "null", ")", "{", "result", ".", "addAll", "(", "plugins", ")", ";", "}", "}", "}", "}", "return", "result", ";", "}" ]
Finds the plugins that are listed in active profiles. @param project the project @return the profile plugins
[ "Finds", "the", "plugins", "that", "are", "listed", "in", "active", "profiles", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L493-L515
150,952
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.findCurrentPlugin
protected Plugin findCurrentPlugin( Plugin plugin, MavenProject project ) { Plugin found = null; try { Model model = project.getModel(); @SuppressWarnings( "unchecked" ) Map<String, Plugin> plugins = model.getBuild().getPluginsAsMap(); found = plugins.get( plugin.getKey() ); } catch ( NullPointerException e ) { // nothing to do here } if ( found == null ) { found = resolvePlugin( plugin, project ); } return found; }
java
protected Plugin findCurrentPlugin( Plugin plugin, MavenProject project ) { Plugin found = null; try { Model model = project.getModel(); @SuppressWarnings( "unchecked" ) Map<String, Plugin> plugins = model.getBuild().getPluginsAsMap(); found = plugins.get( plugin.getKey() ); } catch ( NullPointerException e ) { // nothing to do here } if ( found == null ) { found = resolvePlugin( plugin, project ); } return found; }
[ "protected", "Plugin", "findCurrentPlugin", "(", "Plugin", "plugin", ",", "MavenProject", "project", ")", "{", "Plugin", "found", "=", "null", ";", "try", "{", "Model", "model", "=", "project", ".", "getModel", "(", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Map", "<", "String", ",", "Plugin", ">", "plugins", "=", "model", ".", "getBuild", "(", ")", ".", "getPluginsAsMap", "(", ")", ";", "found", "=", "plugins", ".", "get", "(", "plugin", ".", "getKey", "(", ")", ")", ";", "}", "catch", "(", "NullPointerException", "e", ")", "{", "// nothing to do here", "}", "if", "(", "found", "==", "null", ")", "{", "found", "=", "resolvePlugin", "(", "plugin", ",", "project", ")", ";", "}", "return", "found", ";", "}" ]
Given a plugin, this will retrieve the matching plugin artifact from the model. @param plugin plugin to lookup @param project project to search @return matching plugin, <code>null</code> if not found.
[ "Given", "a", "plugin", "this", "will", "retrieve", "the", "matching", "plugin", "artifact", "from", "the", "model", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L524-L545
150,953
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.resolvePlugin
protected Plugin resolvePlugin( Plugin plugin, MavenProject project ) { @SuppressWarnings( "unchecked" ) List<ArtifactRepository> pluginRepositories = project.getPluginArtifactRepositories(); Artifact artifact = factory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), VersionRange.createFromVersion( "LATEST" ) ); try { this.resolver.resolve( artifact, pluginRepositories, this.local ); plugin.setVersion( artifact.getVersion() ); } catch ( ArtifactResolutionException e ) { } catch ( ArtifactNotFoundException e ) { } return plugin; }
java
protected Plugin resolvePlugin( Plugin plugin, MavenProject project ) { @SuppressWarnings( "unchecked" ) List<ArtifactRepository> pluginRepositories = project.getPluginArtifactRepositories(); Artifact artifact = factory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), VersionRange.createFromVersion( "LATEST" ) ); try { this.resolver.resolve( artifact, pluginRepositories, this.local ); plugin.setVersion( artifact.getVersion() ); } catch ( ArtifactResolutionException e ) { } catch ( ArtifactNotFoundException e ) { } return plugin; }
[ "protected", "Plugin", "resolvePlugin", "(", "Plugin", "plugin", ",", "MavenProject", "project", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "ArtifactRepository", ">", "pluginRepositories", "=", "project", ".", "getPluginArtifactRepositories", "(", ")", ";", "Artifact", "artifact", "=", "factory", ".", "createPluginArtifact", "(", "plugin", ".", "getGroupId", "(", ")", ",", "plugin", ".", "getArtifactId", "(", ")", ",", "VersionRange", ".", "createFromVersion", "(", "\"LATEST\"", ")", ")", ";", "try", "{", "this", ".", "resolver", ".", "resolve", "(", "artifact", ",", "pluginRepositories", ",", "this", ".", "local", ")", ";", "plugin", ".", "setVersion", "(", "artifact", ".", "getVersion", "(", ")", ")", ";", "}", "catch", "(", "ArtifactResolutionException", "e", ")", "{", "}", "catch", "(", "ArtifactNotFoundException", "e", ")", "{", "}", "return", "plugin", ";", "}" ]
Resolve plugin. @param plugin the plugin @param project the project @return the plugin
[ "Resolve", "plugin", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L554-L576
150,954
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.getBoundPlugins
protected Set<Plugin> getBoundPlugins( LifecycleExecutor life, MavenProject project, String thePhases ) throws PluginNotFoundException, LifecycleExecutionException, IllegalAccessException { Set<Plugin> allPlugins = new HashSet<Plugin>(); // lookup the bindings for all the passed in phases String[] lifecyclePhases = thePhases.split( "," ); for ( int i = 0; i < lifecyclePhases.length; i++ ) { String lifecyclePhase = lifecyclePhases[i]; if ( StringUtils.isNotEmpty( lifecyclePhase ) ) { try { Lifecycle lifecycle = getLifecycleForPhase( lifecyclePhase ); allPlugins.addAll( getAllPlugins( project, lifecycle ) ); } catch ( BuildFailureException e ) { // i'm going to swallow this because the // user may have declared a phase that // doesn't exist for every module. } } } return allPlugins; }
java
protected Set<Plugin> getBoundPlugins( LifecycleExecutor life, MavenProject project, String thePhases ) throws PluginNotFoundException, LifecycleExecutionException, IllegalAccessException { Set<Plugin> allPlugins = new HashSet<Plugin>(); // lookup the bindings for all the passed in phases String[] lifecyclePhases = thePhases.split( "," ); for ( int i = 0; i < lifecyclePhases.length; i++ ) { String lifecyclePhase = lifecyclePhases[i]; if ( StringUtils.isNotEmpty( lifecyclePhase ) ) { try { Lifecycle lifecycle = getLifecycleForPhase( lifecyclePhase ); allPlugins.addAll( getAllPlugins( project, lifecycle ) ); } catch ( BuildFailureException e ) { // i'm going to swallow this because the // user may have declared a phase that // doesn't exist for every module. } } } return allPlugins; }
[ "protected", "Set", "<", "Plugin", ">", "getBoundPlugins", "(", "LifecycleExecutor", "life", ",", "MavenProject", "project", ",", "String", "thePhases", ")", "throws", "PluginNotFoundException", ",", "LifecycleExecutionException", ",", "IllegalAccessException", "{", "Set", "<", "Plugin", ">", "allPlugins", "=", "new", "HashSet", "<", "Plugin", ">", "(", ")", ";", "// lookup the bindings for all the passed in phases", "String", "[", "]", "lifecyclePhases", "=", "thePhases", ".", "split", "(", "\",\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "lifecyclePhases", ".", "length", ";", "i", "++", ")", "{", "String", "lifecyclePhase", "=", "lifecyclePhases", "[", "i", "]", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "lifecyclePhase", ")", ")", "{", "try", "{", "Lifecycle", "lifecycle", "=", "getLifecycleForPhase", "(", "lifecyclePhase", ")", ";", "allPlugins", ".", "addAll", "(", "getAllPlugins", "(", "project", ",", "lifecycle", ")", ")", ";", "}", "catch", "(", "BuildFailureException", "e", ")", "{", "// i'm going to swallow this because the", "// user may have declared a phase that", "// doesn't exist for every module.", "}", "}", "}", "return", "allPlugins", ";", "}" ]
Gets the plugins that are bound to the defined phases. This does not find plugins bound in the pom to a phase later than the plugin is executing. @param life the life @param project the project @param thePhases the the phases @return the bound plugins @throws PluginNotFoundException the plugin not found exception @throws LifecycleExecutionException the lifecycle execution exception @throws IllegalAccessException the illegal access exception
[ "Gets", "the", "plugins", "that", "are", "bound", "to", "the", "defined", "phases", ".", "This", "does", "not", "find", "plugins", "bound", "in", "the", "pom", "to", "a", "phase", "later", "than", "the", "plugin", "is", "executing", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L590-L617
150,955
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.hasValidVersionSpecified
protected boolean hasValidVersionSpecified( EnforcerRuleHelper helper, Plugin source, List<PluginWrapper> pluginWrappers ) { boolean found = false; boolean status = false; for ( PluginWrapper plugin : pluginWrappers ) { // find the matching plugin entry if ( source.getArtifactId().equals( plugin.getArtifactId() ) && source.getGroupId().equals( plugin.getGroupId() ) ) { found = true; // found the entry. now see if the version is specified String version = plugin.getVersion(); try { version = (String) helper.evaluate( version ); } catch ( ExpressionEvaluationException e ) { return false; } if ( StringUtils.isNotEmpty( version ) && !StringUtils.isWhitespace( version ) ) { if ( banRelease && version.equals( "RELEASE" ) ) { return false; } if ( banLatest && version.equals( "LATEST" ) ) { return false; } if ( banSnapshots && isSnapshot( version ) ) { return false; } // the version was specified and not // banned. It's ok. Keep looking through the list to make // sure it's not using a banned version somewhere else. status = true; if ( !banRelease && !banLatest && !banSnapshots ) { // no need to keep looking break; } } } } if ( !found ) { log.debug( "plugin " + source.getGroupId() + ":" + source.getArtifactId() + " not found" ); } return status; }
java
protected boolean hasValidVersionSpecified( EnforcerRuleHelper helper, Plugin source, List<PluginWrapper> pluginWrappers ) { boolean found = false; boolean status = false; for ( PluginWrapper plugin : pluginWrappers ) { // find the matching plugin entry if ( source.getArtifactId().equals( plugin.getArtifactId() ) && source.getGroupId().equals( plugin.getGroupId() ) ) { found = true; // found the entry. now see if the version is specified String version = plugin.getVersion(); try { version = (String) helper.evaluate( version ); } catch ( ExpressionEvaluationException e ) { return false; } if ( StringUtils.isNotEmpty( version ) && !StringUtils.isWhitespace( version ) ) { if ( banRelease && version.equals( "RELEASE" ) ) { return false; } if ( banLatest && version.equals( "LATEST" ) ) { return false; } if ( banSnapshots && isSnapshot( version ) ) { return false; } // the version was specified and not // banned. It's ok. Keep looking through the list to make // sure it's not using a banned version somewhere else. status = true; if ( !banRelease && !banLatest && !banSnapshots ) { // no need to keep looking break; } } } } if ( !found ) { log.debug( "plugin " + source.getGroupId() + ":" + source.getArtifactId() + " not found" ); } return status; }
[ "protected", "boolean", "hasValidVersionSpecified", "(", "EnforcerRuleHelper", "helper", ",", "Plugin", "source", ",", "List", "<", "PluginWrapper", ">", "pluginWrappers", ")", "{", "boolean", "found", "=", "false", ";", "boolean", "status", "=", "false", ";", "for", "(", "PluginWrapper", "plugin", ":", "pluginWrappers", ")", "{", "// find the matching plugin entry", "if", "(", "source", ".", "getArtifactId", "(", ")", ".", "equals", "(", "plugin", ".", "getArtifactId", "(", ")", ")", "&&", "source", ".", "getGroupId", "(", ")", ".", "equals", "(", "plugin", ".", "getGroupId", "(", ")", ")", ")", "{", "found", "=", "true", ";", "// found the entry. now see if the version is specified", "String", "version", "=", "plugin", ".", "getVersion", "(", ")", ";", "try", "{", "version", "=", "(", "String", ")", "helper", ".", "evaluate", "(", "version", ")", ";", "}", "catch", "(", "ExpressionEvaluationException", "e", ")", "{", "return", "false", ";", "}", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "version", ")", "&&", "!", "StringUtils", ".", "isWhitespace", "(", "version", ")", ")", "{", "if", "(", "banRelease", "&&", "version", ".", "equals", "(", "\"RELEASE\"", ")", ")", "{", "return", "false", ";", "}", "if", "(", "banLatest", "&&", "version", ".", "equals", "(", "\"LATEST\"", ")", ")", "{", "return", "false", ";", "}", "if", "(", "banSnapshots", "&&", "isSnapshot", "(", "version", ")", ")", "{", "return", "false", ";", "}", "// the version was specified and not", "// banned. It's ok. Keep looking through the list to make", "// sure it's not using a banned version somewhere else.", "status", "=", "true", ";", "if", "(", "!", "banRelease", "&&", "!", "banLatest", "&&", "!", "banSnapshots", ")", "{", "// no need to keep looking", "break", ";", "}", "}", "}", "}", "if", "(", "!", "found", ")", "{", "log", ".", "debug", "(", "\"plugin \"", "+", "source", ".", "getGroupId", "(", ")", "+", "\":\"", "+", "source", ".", "getArtifactId", "(", ")", "+", "\" not found\"", ")", ";", "}", "return", "status", ";", "}" ]
Checks for valid version specified. @param helper the helper @param source the source @param pluginWrappers the plugins @return true, if successful
[ "Checks", "for", "valid", "version", "specified", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L631-L689
150,956
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.isSnapshot
protected boolean isSnapshot( String baseVersion ) { if ( banTimestamps ) { return Artifact.VERSION_FILE_PATTERN.matcher( baseVersion ).matches() || baseVersion.endsWith( Artifact.SNAPSHOT_VERSION ); } else { return baseVersion.endsWith( Artifact.SNAPSHOT_VERSION ); } }
java
protected boolean isSnapshot( String baseVersion ) { if ( banTimestamps ) { return Artifact.VERSION_FILE_PATTERN.matcher( baseVersion ).matches() || baseVersion.endsWith( Artifact.SNAPSHOT_VERSION ); } else { return baseVersion.endsWith( Artifact.SNAPSHOT_VERSION ); } }
[ "protected", "boolean", "isSnapshot", "(", "String", "baseVersion", ")", "{", "if", "(", "banTimestamps", ")", "{", "return", "Artifact", ".", "VERSION_FILE_PATTERN", ".", "matcher", "(", "baseVersion", ")", ".", "matches", "(", ")", "||", "baseVersion", ".", "endsWith", "(", "Artifact", ".", "SNAPSHOT_VERSION", ")", ";", "}", "else", "{", "return", "baseVersion", ".", "endsWith", "(", "Artifact", ".", "SNAPSHOT_VERSION", ")", ";", "}", "}" ]
Checks if is snapshot. @param baseVersion the base version @return true, if is snapshot
[ "Checks", "if", "is", "snapshot", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L697-L708
150,957
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.getAllPlugins
@SuppressWarnings( "unchecked" ) private Set<Plugin> getAllPlugins( MavenProject project, Lifecycle lifecycle ) throws PluginNotFoundException, LifecycleExecutionException { log.debug( "RequirePluginVersions.getAllPlugins:" ); Set<Plugin> plugins = new HashSet<Plugin>(); // first, bind those associated with the packaging Map mappings = findMappingsForLifecycle( project, lifecycle ); Iterator iter = mappings.entrySet().iterator(); while ( iter.hasNext() ) { Entry entry = (Entry) iter.next(); log.debug( " lifecycleMapping = " + entry.getKey() ); String pluginsForLifecycle = (String) entry.getValue(); log.debug( " plugins = " + pluginsForLifecycle ); if ( StringUtils.isNotEmpty( pluginsForLifecycle ) ) { String pluginList[] = pluginsForLifecycle.split( "," ); for ( String plugin : pluginList ) { plugin = StringUtils.strip( plugin ); log.debug( " plugin = " + plugin ); String tokens[] = plugin.split( ":" ); log.debug( " GAV = " + Arrays.asList( tokens ) ); Plugin p = new Plugin(); p.setGroupId( tokens[0] ); p.setArtifactId( tokens[1] ); plugins.add( p ); } } } List<String> mojos = findOptionalMojosForLifecycle( project, lifecycle ); for ( String value : mojos ) { String tokens[] = value.split( ":" ); Plugin plugin = new Plugin(); plugin.setGroupId( tokens[0] ); plugin.setArtifactId( tokens[1] ); plugins.add( plugin ); } plugins.addAll( project.getBuildPlugins() ); return plugins; }
java
@SuppressWarnings( "unchecked" ) private Set<Plugin> getAllPlugins( MavenProject project, Lifecycle lifecycle ) throws PluginNotFoundException, LifecycleExecutionException { log.debug( "RequirePluginVersions.getAllPlugins:" ); Set<Plugin> plugins = new HashSet<Plugin>(); // first, bind those associated with the packaging Map mappings = findMappingsForLifecycle( project, lifecycle ); Iterator iter = mappings.entrySet().iterator(); while ( iter.hasNext() ) { Entry entry = (Entry) iter.next(); log.debug( " lifecycleMapping = " + entry.getKey() ); String pluginsForLifecycle = (String) entry.getValue(); log.debug( " plugins = " + pluginsForLifecycle ); if ( StringUtils.isNotEmpty( pluginsForLifecycle ) ) { String pluginList[] = pluginsForLifecycle.split( "," ); for ( String plugin : pluginList ) { plugin = StringUtils.strip( plugin ); log.debug( " plugin = " + plugin ); String tokens[] = plugin.split( ":" ); log.debug( " GAV = " + Arrays.asList( tokens ) ); Plugin p = new Plugin(); p.setGroupId( tokens[0] ); p.setArtifactId( tokens[1] ); plugins.add( p ); } } } List<String> mojos = findOptionalMojosForLifecycle( project, lifecycle ); for ( String value : mojos ) { String tokens[] = value.split( ":" ); Plugin plugin = new Plugin(); plugin.setGroupId( tokens[0] ); plugin.setArtifactId( tokens[1] ); plugins.add( plugin ); } plugins.addAll( project.getBuildPlugins() ); return plugins; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "Set", "<", "Plugin", ">", "getAllPlugins", "(", "MavenProject", "project", ",", "Lifecycle", "lifecycle", ")", "throws", "PluginNotFoundException", ",", "LifecycleExecutionException", "{", "log", ".", "debug", "(", "\"RequirePluginVersions.getAllPlugins:\"", ")", ";", "Set", "<", "Plugin", ">", "plugins", "=", "new", "HashSet", "<", "Plugin", ">", "(", ")", ";", "// first, bind those associated with the packaging", "Map", "mappings", "=", "findMappingsForLifecycle", "(", "project", ",", "lifecycle", ")", ";", "Iterator", "iter", "=", "mappings", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "Entry", "entry", "=", "(", "Entry", ")", "iter", ".", "next", "(", ")", ";", "log", ".", "debug", "(", "\" lifecycleMapping = \"", "+", "entry", ".", "getKey", "(", ")", ")", ";", "String", "pluginsForLifecycle", "=", "(", "String", ")", "entry", ".", "getValue", "(", ")", ";", "log", ".", "debug", "(", "\" plugins = \"", "+", "pluginsForLifecycle", ")", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "pluginsForLifecycle", ")", ")", "{", "String", "pluginList", "[", "]", "=", "pluginsForLifecycle", ".", "split", "(", "\",\"", ")", ";", "for", "(", "String", "plugin", ":", "pluginList", ")", "{", "plugin", "=", "StringUtils", ".", "strip", "(", "plugin", ")", ";", "log", ".", "debug", "(", "\" plugin = \"", "+", "plugin", ")", ";", "String", "tokens", "[", "]", "=", "plugin", ".", "split", "(", "\":\"", ")", ";", "log", ".", "debug", "(", "\" GAV = \"", "+", "Arrays", ".", "asList", "(", "tokens", ")", ")", ";", "Plugin", "p", "=", "new", "Plugin", "(", ")", ";", "p", ".", "setGroupId", "(", "tokens", "[", "0", "]", ")", ";", "p", ".", "setArtifactId", "(", "tokens", "[", "1", "]", ")", ";", "plugins", ".", "add", "(", "p", ")", ";", "}", "}", "}", "List", "<", "String", ">", "mojos", "=", "findOptionalMojosForLifecycle", "(", "project", ",", "lifecycle", ")", ";", "for", "(", "String", "value", ":", "mojos", ")", "{", "String", "tokens", "[", "]", "=", "value", ".", "split", "(", "\":\"", ")", ";", "Plugin", "plugin", "=", "new", "Plugin", "(", ")", ";", "plugin", ".", "setGroupId", "(", "tokens", "[", "0", "]", ")", ";", "plugin", ".", "setArtifactId", "(", "tokens", "[", "1", "]", ")", ";", "plugins", ".", "add", "(", "plugin", ")", ";", "}", "plugins", ".", "addAll", "(", "project", ".", "getBuildPlugins", "(", ")", ")", ";", "return", "plugins", ";", "}" ]
Gets the all plugins. @param project the project @param lifecycle the lifecycle @return the all plugins @throws PluginNotFoundException the plugin not found exception @throws LifecycleExecutionException the lifecycle execution exception
[ "Gets", "the", "all", "plugins", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L722-L772
150,958
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.getPhaseToLifecycleMap
public Map<String, Lifecycle> getPhaseToLifecycleMap() throws LifecycleExecutionException { if ( phaseToLifecycleMap == null ) { phaseToLifecycleMap = new HashMap<String, Lifecycle>(); for ( Lifecycle lifecycle : lifecycles ) { @SuppressWarnings( "unchecked" ) List<String> phases = lifecycle.getPhases(); for ( String phase : phases ) { if ( phaseToLifecycleMap.containsKey( phase ) ) { Lifecycle prevLifecycle = (Lifecycle) phaseToLifecycleMap.get( phase ); throw new LifecycleExecutionException( "Phase '" + phase + "' is defined in more than one lifecycle: '" + lifecycle.getId() + "' and '" + prevLifecycle.getId() + "'" ); } else { phaseToLifecycleMap.put( phase, lifecycle ); } } } } return phaseToLifecycleMap; }
java
public Map<String, Lifecycle> getPhaseToLifecycleMap() throws LifecycleExecutionException { if ( phaseToLifecycleMap == null ) { phaseToLifecycleMap = new HashMap<String, Lifecycle>(); for ( Lifecycle lifecycle : lifecycles ) { @SuppressWarnings( "unchecked" ) List<String> phases = lifecycle.getPhases(); for ( String phase : phases ) { if ( phaseToLifecycleMap.containsKey( phase ) ) { Lifecycle prevLifecycle = (Lifecycle) phaseToLifecycleMap.get( phase ); throw new LifecycleExecutionException( "Phase '" + phase + "' is defined in more than one lifecycle: '" + lifecycle.getId() + "' and '" + prevLifecycle.getId() + "'" ); } else { phaseToLifecycleMap.put( phase, lifecycle ); } } } } return phaseToLifecycleMap; }
[ "public", "Map", "<", "String", ",", "Lifecycle", ">", "getPhaseToLifecycleMap", "(", ")", "throws", "LifecycleExecutionException", "{", "if", "(", "phaseToLifecycleMap", "==", "null", ")", "{", "phaseToLifecycleMap", "=", "new", "HashMap", "<", "String", ",", "Lifecycle", ">", "(", ")", ";", "for", "(", "Lifecycle", "lifecycle", ":", "lifecycles", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "String", ">", "phases", "=", "lifecycle", ".", "getPhases", "(", ")", ";", "for", "(", "String", "phase", ":", "phases", ")", "{", "if", "(", "phaseToLifecycleMap", ".", "containsKey", "(", "phase", ")", ")", "{", "Lifecycle", "prevLifecycle", "=", "(", "Lifecycle", ")", "phaseToLifecycleMap", ".", "get", "(", "phase", ")", ";", "throw", "new", "LifecycleExecutionException", "(", "\"Phase '\"", "+", "phase", "+", "\"' is defined in more than one lifecycle: '\"", "+", "lifecycle", ".", "getId", "(", ")", "+", "\"' and '\"", "+", "prevLifecycle", ".", "getId", "(", ")", "+", "\"'\"", ")", ";", "}", "else", "{", "phaseToLifecycleMap", ".", "put", "(", "phase", ",", "lifecycle", ")", ";", "}", "}", "}", "}", "return", "phaseToLifecycleMap", ";", "}" ]
Gets the phase to lifecycle map. @return the phase to lifecycle map @throws LifecycleExecutionException the lifecycle execution exception
[ "Gets", "the", "phase", "to", "lifecycle", "map", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L784-L812
150,959
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.getLifecycleForPhase
private Lifecycle getLifecycleForPhase( String phase ) throws BuildFailureException, LifecycleExecutionException { Lifecycle lifecycle = (Lifecycle) getPhaseToLifecycleMap().get( phase ); if ( lifecycle == null ) { throw new BuildFailureException( "Unable to find lifecycle for phase '" + phase + "'" ); } return lifecycle; }
java
private Lifecycle getLifecycleForPhase( String phase ) throws BuildFailureException, LifecycleExecutionException { Lifecycle lifecycle = (Lifecycle) getPhaseToLifecycleMap().get( phase ); if ( lifecycle == null ) { throw new BuildFailureException( "Unable to find lifecycle for phase '" + phase + "'" ); } return lifecycle; }
[ "private", "Lifecycle", "getLifecycleForPhase", "(", "String", "phase", ")", "throws", "BuildFailureException", ",", "LifecycleExecutionException", "{", "Lifecycle", "lifecycle", "=", "(", "Lifecycle", ")", "getPhaseToLifecycleMap", "(", ")", ".", "get", "(", "phase", ")", ";", "if", "(", "lifecycle", "==", "null", ")", "{", "throw", "new", "BuildFailureException", "(", "\"Unable to find lifecycle for phase '\"", "+", "phase", "+", "\"'\"", ")", ";", "}", "return", "lifecycle", ";", "}" ]
Gets the lifecycle for phase. @param phase the phase @return the lifecycle for phase @throws BuildFailureException the build failure exception @throws LifecycleExecutionException the lifecycle execution exception
[ "Gets", "the", "lifecycle", "for", "phase", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L822-L832
150,960
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.findMappingsForLifecycle
private Map findMappingsForLifecycle( MavenProject project, Lifecycle lifecycle ) throws LifecycleExecutionException, PluginNotFoundException { String packaging = project.getPackaging(); Map mappings = null; LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, session.getSettings(), session.getLocalRepository() ); if ( m != null ) { mappings = m.getPhases( lifecycle.getId() ); } Map defaultMappings = lifecycle.getDefaultPhases(); if ( mappings == null ) { try { m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, packaging ); mappings = m.getPhases( lifecycle.getId() ); } catch ( ComponentLookupException e ) { if ( defaultMappings == null ) { throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: \'" + packaging + "\'.", e ); } } } if ( mappings == null ) { if ( defaultMappings == null ) { throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: \'" + packaging + "\', and there is no default" ); } else { mappings = defaultMappings; } } return mappings; }
java
private Map findMappingsForLifecycle( MavenProject project, Lifecycle lifecycle ) throws LifecycleExecutionException, PluginNotFoundException { String packaging = project.getPackaging(); Map mappings = null; LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, session.getSettings(), session.getLocalRepository() ); if ( m != null ) { mappings = m.getPhases( lifecycle.getId() ); } Map defaultMappings = lifecycle.getDefaultPhases(); if ( mappings == null ) { try { m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, packaging ); mappings = m.getPhases( lifecycle.getId() ); } catch ( ComponentLookupException e ) { if ( defaultMappings == null ) { throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: \'" + packaging + "\'.", e ); } } } if ( mappings == null ) { if ( defaultMappings == null ) { throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: \'" + packaging + "\', and there is no default" ); } else { mappings = defaultMappings; } } return mappings; }
[ "private", "Map", "findMappingsForLifecycle", "(", "MavenProject", "project", ",", "Lifecycle", "lifecycle", ")", "throws", "LifecycleExecutionException", ",", "PluginNotFoundException", "{", "String", "packaging", "=", "project", ".", "getPackaging", "(", ")", ";", "Map", "mappings", "=", "null", ";", "LifecycleMapping", "m", "=", "(", "LifecycleMapping", ")", "findExtension", "(", "project", ",", "LifecycleMapping", ".", "ROLE", ",", "packaging", ",", "session", ".", "getSettings", "(", ")", ",", "session", ".", "getLocalRepository", "(", ")", ")", ";", "if", "(", "m", "!=", "null", ")", "{", "mappings", "=", "m", ".", "getPhases", "(", "lifecycle", ".", "getId", "(", ")", ")", ";", "}", "Map", "defaultMappings", "=", "lifecycle", ".", "getDefaultPhases", "(", ")", ";", "if", "(", "mappings", "==", "null", ")", "{", "try", "{", "m", "=", "(", "LifecycleMapping", ")", "session", ".", "lookup", "(", "LifecycleMapping", ".", "ROLE", ",", "packaging", ")", ";", "mappings", "=", "m", ".", "getPhases", "(", "lifecycle", ".", "getId", "(", ")", ")", ";", "}", "catch", "(", "ComponentLookupException", "e", ")", "{", "if", "(", "defaultMappings", "==", "null", ")", "{", "throw", "new", "LifecycleExecutionException", "(", "\"Cannot find lifecycle mapping for packaging: \\'\"", "+", "packaging", "+", "\"\\'.\"", ",", "e", ")", ";", "}", "}", "}", "if", "(", "mappings", "==", "null", ")", "{", "if", "(", "defaultMappings", "==", "null", ")", "{", "throw", "new", "LifecycleExecutionException", "(", "\"Cannot find lifecycle mapping for packaging: \\'\"", "+", "packaging", "+", "\"\\', and there is no default\"", ")", ";", "}", "else", "{", "mappings", "=", "defaultMappings", ";", "}", "}", "return", "mappings", ";", "}" ]
Find mappings for lifecycle. @param project the project @param lifecycle the lifecycle @return the map @throws LifecycleExecutionException the lifecycle execution exception @throws PluginNotFoundException the plugin not found exception
[ "Find", "mappings", "for", "lifecycle", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L843-L890
150,961
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.findOptionalMojosForLifecycle
@SuppressWarnings( "unchecked" ) private List<String> findOptionalMojosForLifecycle( MavenProject project, Lifecycle lifecycle ) throws LifecycleExecutionException, PluginNotFoundException { String packaging = project.getPackaging(); List<String> optionalMojos = null; LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, session.getSettings(), session.getLocalRepository() ); if ( m != null ) { optionalMojos = m.getOptionalMojos( lifecycle.getId() ); } if ( optionalMojos == null ) { try { m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, packaging ); optionalMojos = m.getOptionalMojos( lifecycle.getId() ); } catch ( ComponentLookupException e ) { log.debug( "Error looking up lifecycle mapping to retrieve optional mojos. Lifecycle ID: " + lifecycle.getId() + ". Error: " + e.getMessage(), e ); } } if ( optionalMojos == null ) { optionalMojos = Collections.emptyList(); } return optionalMojos; }
java
@SuppressWarnings( "unchecked" ) private List<String> findOptionalMojosForLifecycle( MavenProject project, Lifecycle lifecycle ) throws LifecycleExecutionException, PluginNotFoundException { String packaging = project.getPackaging(); List<String> optionalMojos = null; LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, session.getSettings(), session.getLocalRepository() ); if ( m != null ) { optionalMojos = m.getOptionalMojos( lifecycle.getId() ); } if ( optionalMojos == null ) { try { m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, packaging ); optionalMojos = m.getOptionalMojos( lifecycle.getId() ); } catch ( ComponentLookupException e ) { log.debug( "Error looking up lifecycle mapping to retrieve optional mojos. Lifecycle ID: " + lifecycle.getId() + ". Error: " + e.getMessage(), e ); } } if ( optionalMojos == null ) { optionalMojos = Collections.emptyList(); } return optionalMojos; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "List", "<", "String", ">", "findOptionalMojosForLifecycle", "(", "MavenProject", "project", ",", "Lifecycle", "lifecycle", ")", "throws", "LifecycleExecutionException", ",", "PluginNotFoundException", "{", "String", "packaging", "=", "project", ".", "getPackaging", "(", ")", ";", "List", "<", "String", ">", "optionalMojos", "=", "null", ";", "LifecycleMapping", "m", "=", "(", "LifecycleMapping", ")", "findExtension", "(", "project", ",", "LifecycleMapping", ".", "ROLE", ",", "packaging", ",", "session", ".", "getSettings", "(", ")", ",", "session", ".", "getLocalRepository", "(", ")", ")", ";", "if", "(", "m", "!=", "null", ")", "{", "optionalMojos", "=", "m", ".", "getOptionalMojos", "(", "lifecycle", ".", "getId", "(", ")", ")", ";", "}", "if", "(", "optionalMojos", "==", "null", ")", "{", "try", "{", "m", "=", "(", "LifecycleMapping", ")", "session", ".", "lookup", "(", "LifecycleMapping", ".", "ROLE", ",", "packaging", ")", ";", "optionalMojos", "=", "m", ".", "getOptionalMojos", "(", "lifecycle", ".", "getId", "(", ")", ")", ";", "}", "catch", "(", "ComponentLookupException", "e", ")", "{", "log", ".", "debug", "(", "\"Error looking up lifecycle mapping to retrieve optional mojos. Lifecycle ID: \"", "+", "lifecycle", ".", "getId", "(", ")", "+", "\". Error: \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}", "if", "(", "optionalMojos", "==", "null", ")", "{", "optionalMojos", "=", "Collections", ".", "emptyList", "(", ")", ";", "}", "return", "optionalMojos", ";", "}" ]
Find optional mojos for lifecycle. @param project the project @param lifecycle the lifecycle @return the list @throws LifecycleExecutionException the lifecycle execution exception @throws PluginNotFoundException the plugin not found exception
[ "Find", "optional", "mojos", "for", "lifecycle", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L901-L937
150,962
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.findExtension
private Object findExtension( MavenProject project, String role, String roleHint, Settings settings, ArtifactRepository localRepository ) throws LifecycleExecutionException, PluginNotFoundException { Object pluginComponent = null; @SuppressWarnings( "unchecked" ) List<Plugin> buildPlugins = project.getBuildPlugins(); for ( Plugin plugin : buildPlugins ) { if ( plugin.isExtensions() ) { verifyPlugin( plugin, project, settings, localRepository ); // TODO: if moved to the plugin manager we // already have the descriptor from above // and so do can lookup the container // directly try { pluginComponent = pluginManager.getPluginComponent( plugin, role, roleHint ); if ( pluginComponent != null ) { break; } } catch ( ComponentLookupException e ) { log.debug( "Unable to find the lifecycle component in the extension", e ); } catch ( PluginManagerException e ) { throw new LifecycleExecutionException( "Error getting extensions from the plugin '" + plugin.getKey() + "': " + e.getMessage(), e ); } } } return pluginComponent; }
java
private Object findExtension( MavenProject project, String role, String roleHint, Settings settings, ArtifactRepository localRepository ) throws LifecycleExecutionException, PluginNotFoundException { Object pluginComponent = null; @SuppressWarnings( "unchecked" ) List<Plugin> buildPlugins = project.getBuildPlugins(); for ( Plugin plugin : buildPlugins ) { if ( plugin.isExtensions() ) { verifyPlugin( plugin, project, settings, localRepository ); // TODO: if moved to the plugin manager we // already have the descriptor from above // and so do can lookup the container // directly try { pluginComponent = pluginManager.getPluginComponent( plugin, role, roleHint ); if ( pluginComponent != null ) { break; } } catch ( ComponentLookupException e ) { log.debug( "Unable to find the lifecycle component in the extension", e ); } catch ( PluginManagerException e ) { throw new LifecycleExecutionException( "Error getting extensions from the plugin '" + plugin.getKey() + "': " + e.getMessage(), e ); } } } return pluginComponent; }
[ "private", "Object", "findExtension", "(", "MavenProject", "project", ",", "String", "role", ",", "String", "roleHint", ",", "Settings", "settings", ",", "ArtifactRepository", "localRepository", ")", "throws", "LifecycleExecutionException", ",", "PluginNotFoundException", "{", "Object", "pluginComponent", "=", "null", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "Plugin", ">", "buildPlugins", "=", "project", ".", "getBuildPlugins", "(", ")", ";", "for", "(", "Plugin", "plugin", ":", "buildPlugins", ")", "{", "if", "(", "plugin", ".", "isExtensions", "(", ")", ")", "{", "verifyPlugin", "(", "plugin", ",", "project", ",", "settings", ",", "localRepository", ")", ";", "// TODO: if moved to the plugin manager we", "// already have the descriptor from above", "// and so do can lookup the container", "// directly", "try", "{", "pluginComponent", "=", "pluginManager", ".", "getPluginComponent", "(", "plugin", ",", "role", ",", "roleHint", ")", ";", "if", "(", "pluginComponent", "!=", "null", ")", "{", "break", ";", "}", "}", "catch", "(", "ComponentLookupException", "e", ")", "{", "log", ".", "debug", "(", "\"Unable to find the lifecycle component in the extension\"", ",", "e", ")", ";", "}", "catch", "(", "PluginManagerException", "e", ")", "{", "throw", "new", "LifecycleExecutionException", "(", "\"Error getting extensions from the plugin '\"", "+", "plugin", ".", "getKey", "(", ")", "+", "\"': \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}", "}", "return", "pluginComponent", ";", "}" ]
Find extension. @param project the project @param role the role @param roleHint the role hint @param settings the settings @param localRepository the local repository @return the object @throws LifecycleExecutionException the lifecycle execution exception @throws PluginNotFoundException the plugin not found exception
[ "Find", "extension", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L951-L990
150,963
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.verifyPlugin
private PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings, ArtifactRepository localRepository ) throws LifecycleExecutionException, PluginNotFoundException { PluginDescriptor pluginDescriptor; try { pluginDescriptor = pluginManager.verifyPlugin( plugin, project, settings, localRepository ); } catch ( PluginManagerException e ) { throw new LifecycleExecutionException( "Internal error in the plugin manager getting plugin '" + plugin.getKey() + "': " + e.getMessage(), e ); } catch ( PluginVersionResolutionException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( InvalidVersionSpecificationException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( InvalidPluginException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( ArtifactNotFoundException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( ArtifactResolutionException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( PluginVersionNotFoundException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } return pluginDescriptor; }
java
private PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings, ArtifactRepository localRepository ) throws LifecycleExecutionException, PluginNotFoundException { PluginDescriptor pluginDescriptor; try { pluginDescriptor = pluginManager.verifyPlugin( plugin, project, settings, localRepository ); } catch ( PluginManagerException e ) { throw new LifecycleExecutionException( "Internal error in the plugin manager getting plugin '" + plugin.getKey() + "': " + e.getMessage(), e ); } catch ( PluginVersionResolutionException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( InvalidVersionSpecificationException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( InvalidPluginException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( ArtifactNotFoundException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( ArtifactResolutionException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( PluginVersionNotFoundException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } return pluginDescriptor; }
[ "private", "PluginDescriptor", "verifyPlugin", "(", "Plugin", "plugin", ",", "MavenProject", "project", ",", "Settings", "settings", ",", "ArtifactRepository", "localRepository", ")", "throws", "LifecycleExecutionException", ",", "PluginNotFoundException", "{", "PluginDescriptor", "pluginDescriptor", ";", "try", "{", "pluginDescriptor", "=", "pluginManager", ".", "verifyPlugin", "(", "plugin", ",", "project", ",", "settings", ",", "localRepository", ")", ";", "}", "catch", "(", "PluginManagerException", "e", ")", "{", "throw", "new", "LifecycleExecutionException", "(", "\"Internal error in the plugin manager getting plugin '\"", "+", "plugin", ".", "getKey", "(", ")", "+", "\"': \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "PluginVersionResolutionException", "e", ")", "{", "throw", "new", "LifecycleExecutionException", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "InvalidVersionSpecificationException", "e", ")", "{", "throw", "new", "LifecycleExecutionException", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "InvalidPluginException", "e", ")", "{", "throw", "new", "LifecycleExecutionException", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "ArtifactNotFoundException", "e", ")", "{", "throw", "new", "LifecycleExecutionException", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "ArtifactResolutionException", "e", ")", "{", "throw", "new", "LifecycleExecutionException", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "PluginVersionNotFoundException", "e", ")", "{", "throw", "new", "LifecycleExecutionException", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "return", "pluginDescriptor", ";", "}" ]
Verify plugin. @param plugin the plugin @param project the project @param settings the settings @param localRepository the local repository @return the plugin descriptor @throws LifecycleExecutionException the lifecycle execution exception @throws PluginNotFoundException the plugin not found exception
[ "Verify", "plugin", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L1003-L1042
150,964
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
RequirePluginVersions.getAllPluginEntries
protected List<PluginWrapper> getAllPluginEntries( MavenProject project ) throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException { List<PluginWrapper> plugins = new ArrayList<PluginWrapper>(); // get all the pom models String pomName = null; try { pomName = project.getFile().getName(); } catch ( Exception e ) { pomName = "pom.xml"; } List<Model> models = utils.getModelsRecursively( project.getGroupId(), project.getArtifactId(), project.getVersion(), new File( project.getBasedir(), pomName ) ); // now find all the plugin entries, either in // build.plugins or build.pluginManagement.plugins, profiles.plugins and reporting for ( Model model : models ) { try { List<Plugin> modelPlugins = model.getBuild().getPlugins(); plugins.addAll( PluginWrapper.addAll( utils.resolvePlugins( modelPlugins ), model.getId() + ".build.plugins" ) ); } catch ( NullPointerException e ) { // guess there are no plugins here. } try { List<ReportPlugin> modelReportPlugins = model.getReporting().getPlugins(); // add the reporting plugins plugins.addAll( PluginWrapper.addAll( utils.resolveReportPlugins( modelReportPlugins ), model.getId() + ".reporting" ) ); } catch ( NullPointerException e ) { // guess there are no plugins here. } try { List<Plugin> modelPlugins = model.getBuild().getPluginManagement().getPlugins(); plugins.addAll( PluginWrapper.addAll( utils.resolvePlugins( modelPlugins ), model.getId() + ".build.pluginManagement.plugins" ) ); } catch ( NullPointerException e ) { // guess there are no plugins here. } // Add plugins in profiles @SuppressWarnings( "unchecked" ) List<Profile> profiles = model.getProfiles(); for ( Profile profile : profiles ) { try { List<Plugin> modelPlugins = profile.getBuild().getPlugins(); plugins.addAll( PluginWrapper.addAll( utils.resolvePlugins( modelPlugins ), model.getId() + ".profiles.profile[" + profile.getId() + "].build.plugins" ) ); } catch ( NullPointerException e ) { // guess there are no plugins here. } try { List<ReportPlugin> modelReportPlugins = profile.getReporting().getPlugins(); // add the reporting plugins plugins.addAll( PluginWrapper.addAll( utils.resolveReportPlugins( modelReportPlugins ), model.getId() + "profile[" + profile.getId() + "].reporting.plugins" ) ); } catch ( NullPointerException e ) { // guess there are no plugins here. } try { List<Plugin> modelPlugins = profile.getBuild().getPluginManagement().getPlugins(); plugins.addAll( PluginWrapper.addAll( utils.resolvePlugins( modelPlugins ), model.getId() + "profile[" + profile.getId() + "].build.pluginManagement.plugins" ) ); } catch ( NullPointerException e ) { // guess there are no plugins here. } } } return plugins; }
java
protected List<PluginWrapper> getAllPluginEntries( MavenProject project ) throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException { List<PluginWrapper> plugins = new ArrayList<PluginWrapper>(); // get all the pom models String pomName = null; try { pomName = project.getFile().getName(); } catch ( Exception e ) { pomName = "pom.xml"; } List<Model> models = utils.getModelsRecursively( project.getGroupId(), project.getArtifactId(), project.getVersion(), new File( project.getBasedir(), pomName ) ); // now find all the plugin entries, either in // build.plugins or build.pluginManagement.plugins, profiles.plugins and reporting for ( Model model : models ) { try { List<Plugin> modelPlugins = model.getBuild().getPlugins(); plugins.addAll( PluginWrapper.addAll( utils.resolvePlugins( modelPlugins ), model.getId() + ".build.plugins" ) ); } catch ( NullPointerException e ) { // guess there are no plugins here. } try { List<ReportPlugin> modelReportPlugins = model.getReporting().getPlugins(); // add the reporting plugins plugins.addAll( PluginWrapper.addAll( utils.resolveReportPlugins( modelReportPlugins ), model.getId() + ".reporting" ) ); } catch ( NullPointerException e ) { // guess there are no plugins here. } try { List<Plugin> modelPlugins = model.getBuild().getPluginManagement().getPlugins(); plugins.addAll( PluginWrapper.addAll( utils.resolvePlugins( modelPlugins ), model.getId() + ".build.pluginManagement.plugins" ) ); } catch ( NullPointerException e ) { // guess there are no plugins here. } // Add plugins in profiles @SuppressWarnings( "unchecked" ) List<Profile> profiles = model.getProfiles(); for ( Profile profile : profiles ) { try { List<Plugin> modelPlugins = profile.getBuild().getPlugins(); plugins.addAll( PluginWrapper.addAll( utils.resolvePlugins( modelPlugins ), model.getId() + ".profiles.profile[" + profile.getId() + "].build.plugins" ) ); } catch ( NullPointerException e ) { // guess there are no plugins here. } try { List<ReportPlugin> modelReportPlugins = profile.getReporting().getPlugins(); // add the reporting plugins plugins.addAll( PluginWrapper.addAll( utils.resolveReportPlugins( modelReportPlugins ), model.getId() + "profile[" + profile.getId() + "].reporting.plugins" ) ); } catch ( NullPointerException e ) { // guess there are no plugins here. } try { List<Plugin> modelPlugins = profile.getBuild().getPluginManagement().getPlugins(); plugins.addAll( PluginWrapper.addAll( utils.resolvePlugins( modelPlugins ), model.getId() + "profile[" + profile.getId() + "].build.pluginManagement.plugins" ) ); } catch ( NullPointerException e ) { // guess there are no plugins here. } } } return plugins; }
[ "protected", "List", "<", "PluginWrapper", ">", "getAllPluginEntries", "(", "MavenProject", "project", ")", "throws", "ArtifactResolutionException", ",", "ArtifactNotFoundException", ",", "IOException", ",", "XmlPullParserException", "{", "List", "<", "PluginWrapper", ">", "plugins", "=", "new", "ArrayList", "<", "PluginWrapper", ">", "(", ")", ";", "// get all the pom models", "String", "pomName", "=", "null", ";", "try", "{", "pomName", "=", "project", ".", "getFile", "(", ")", ".", "getName", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "pomName", "=", "\"pom.xml\"", ";", "}", "List", "<", "Model", ">", "models", "=", "utils", ".", "getModelsRecursively", "(", "project", ".", "getGroupId", "(", ")", ",", "project", ".", "getArtifactId", "(", ")", ",", "project", ".", "getVersion", "(", ")", ",", "new", "File", "(", "project", ".", "getBasedir", "(", ")", ",", "pomName", ")", ")", ";", "// now find all the plugin entries, either in", "// build.plugins or build.pluginManagement.plugins, profiles.plugins and reporting", "for", "(", "Model", "model", ":", "models", ")", "{", "try", "{", "List", "<", "Plugin", ">", "modelPlugins", "=", "model", ".", "getBuild", "(", ")", ".", "getPlugins", "(", ")", ";", "plugins", ".", "addAll", "(", "PluginWrapper", ".", "addAll", "(", "utils", ".", "resolvePlugins", "(", "modelPlugins", ")", ",", "model", ".", "getId", "(", ")", "+", "\".build.plugins\"", ")", ")", ";", "}", "catch", "(", "NullPointerException", "e", ")", "{", "// guess there are no plugins here.", "}", "try", "{", "List", "<", "ReportPlugin", ">", "modelReportPlugins", "=", "model", ".", "getReporting", "(", ")", ".", "getPlugins", "(", ")", ";", "// add the reporting plugins", "plugins", ".", "addAll", "(", "PluginWrapper", ".", "addAll", "(", "utils", ".", "resolveReportPlugins", "(", "modelReportPlugins", ")", ",", "model", ".", "getId", "(", ")", "+", "\".reporting\"", ")", ")", ";", "}", "catch", "(", "NullPointerException", "e", ")", "{", "// guess there are no plugins here.", "}", "try", "{", "List", "<", "Plugin", ">", "modelPlugins", "=", "model", ".", "getBuild", "(", ")", ".", "getPluginManagement", "(", ")", ".", "getPlugins", "(", ")", ";", "plugins", ".", "addAll", "(", "PluginWrapper", ".", "addAll", "(", "utils", ".", "resolvePlugins", "(", "modelPlugins", ")", ",", "model", ".", "getId", "(", ")", "+", "\".build.pluginManagement.plugins\"", ")", ")", ";", "}", "catch", "(", "NullPointerException", "e", ")", "{", "// guess there are no plugins here.", "}", "// Add plugins in profiles", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "Profile", ">", "profiles", "=", "model", ".", "getProfiles", "(", ")", ";", "for", "(", "Profile", "profile", ":", "profiles", ")", "{", "try", "{", "List", "<", "Plugin", ">", "modelPlugins", "=", "profile", ".", "getBuild", "(", ")", ".", "getPlugins", "(", ")", ";", "plugins", ".", "addAll", "(", "PluginWrapper", ".", "addAll", "(", "utils", ".", "resolvePlugins", "(", "modelPlugins", ")", ",", "model", ".", "getId", "(", ")", "+", "\".profiles.profile[\"", "+", "profile", ".", "getId", "(", ")", "+", "\"].build.plugins\"", ")", ")", ";", "}", "catch", "(", "NullPointerException", "e", ")", "{", "// guess there are no plugins here.", "}", "try", "{", "List", "<", "ReportPlugin", ">", "modelReportPlugins", "=", "profile", ".", "getReporting", "(", ")", ".", "getPlugins", "(", ")", ";", "// add the reporting plugins", "plugins", ".", "addAll", "(", "PluginWrapper", ".", "addAll", "(", "utils", ".", "resolveReportPlugins", "(", "modelReportPlugins", ")", ",", "model", ".", "getId", "(", ")", "+", "\"profile[\"", "+", "profile", ".", "getId", "(", ")", "+", "\"].reporting.plugins\"", ")", ")", ";", "}", "catch", "(", "NullPointerException", "e", ")", "{", "// guess there are no plugins here.", "}", "try", "{", "List", "<", "Plugin", ">", "modelPlugins", "=", "profile", ".", "getBuild", "(", ")", ".", "getPluginManagement", "(", ")", ".", "getPlugins", "(", ")", ";", "plugins", ".", "addAll", "(", "PluginWrapper", ".", "addAll", "(", "utils", ".", "resolvePlugins", "(", "modelPlugins", ")", ",", "model", ".", "getId", "(", ")", "+", "\"profile[\"", "+", "profile", ".", "getId", "(", ")", "+", "\"].build.pluginManagement.plugins\"", ")", ")", ";", "}", "catch", "(", "NullPointerException", "e", ")", "{", "// guess there are no plugins here.", "}", "}", "}", "return", "plugins", ";", "}" ]
Gets all plugin entries in build.plugins, build.pluginManagement.plugins, profile.build.plugins, reporting and profile.reporting in this project and all parents @param project the project @return the all plugin entries wrapped in a PluginWrapper Object @throws ArtifactResolutionException the artifact resolution exception @throws ArtifactNotFoundException the artifact not found exception @throws IOException Signals that an I/O exception has occurred. @throws XmlPullParserException the xml pull parser exception
[ "Gets", "all", "plugin", "entries", "in", "build", ".", "plugins", "build", ".", "pluginManagement", ".", "plugins", "profile", ".", "build", ".", "plugins", "reporting", "and", "profile", ".", "reporting", "in", "this", "project", "and", "all", "parents" ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L1055-L1152
150,965
vdmeer/skb-java-base
src/main/java/de/vandermeer/skb/base/info/AbstractDirectoryInfo.java
AbstractDirectoryInfo.init
protected void init(String directory, InfoLocationOptions option){ if(this.valOption()==null){ this.errors.addError("constructor(init) - no validation option set"); return; } try{ if(directory!=null){ switch(option){ case FILESYSTEM_ONLY: if(this.tryFS(directory)==false){ if(this.tryCP(directory)==false){ this.errors.addError("constructor(init) - could not find directory <" + directory + ">, tried file system"); } } break; case CLASSPATH_ONLY: if(this.tryCP(directory)==false){ if(this.tryCP(directory)==false){ this.errors.addError("constructor(init) - could not find directory <" + directory + ">>, tried using class path"); } } break; case TRY_FS_THEN_CLASSPATH: if(this.tryFS(directory)==false){ this.errors.clearErrorMessages();; if(this.tryCP(directory)==false){ this.errors.addError("constructor(init) - could not find directory <" + directory + ">, tried file system then using class path"); } } break; case TRY_CLASSPATH_THEN_FS: if(this.tryCP(directory)==false){ this.errors.clearErrorMessages();; if(this.tryFS(directory)==false){ this.errors.addError("constructor(init) - could not find directory <" + directory + ">, tried using class path then file system"); } } break; default: this.errors.addError("constructor(init) - unknown location option <" + option + "> for directories"); } } } catch(Exception ex){ this.errors.addError("init() - catched unpredicted exception: " + ex.getMessage()); } }
java
protected void init(String directory, InfoLocationOptions option){ if(this.valOption()==null){ this.errors.addError("constructor(init) - no validation option set"); return; } try{ if(directory!=null){ switch(option){ case FILESYSTEM_ONLY: if(this.tryFS(directory)==false){ if(this.tryCP(directory)==false){ this.errors.addError("constructor(init) - could not find directory <" + directory + ">, tried file system"); } } break; case CLASSPATH_ONLY: if(this.tryCP(directory)==false){ if(this.tryCP(directory)==false){ this.errors.addError("constructor(init) - could not find directory <" + directory + ">>, tried using class path"); } } break; case TRY_FS_THEN_CLASSPATH: if(this.tryFS(directory)==false){ this.errors.clearErrorMessages();; if(this.tryCP(directory)==false){ this.errors.addError("constructor(init) - could not find directory <" + directory + ">, tried file system then using class path"); } } break; case TRY_CLASSPATH_THEN_FS: if(this.tryCP(directory)==false){ this.errors.clearErrorMessages();; if(this.tryFS(directory)==false){ this.errors.addError("constructor(init) - could not find directory <" + directory + ">, tried using class path then file system"); } } break; default: this.errors.addError("constructor(init) - unknown location option <" + option + "> for directories"); } } } catch(Exception ex){ this.errors.addError("init() - catched unpredicted exception: " + ex.getMessage()); } }
[ "protected", "void", "init", "(", "String", "directory", ",", "InfoLocationOptions", "option", ")", "{", "if", "(", "this", ".", "valOption", "(", ")", "==", "null", ")", "{", "this", ".", "errors", ".", "addError", "(", "\"constructor(init) - no validation option set\"", ")", ";", "return", ";", "}", "try", "{", "if", "(", "directory", "!=", "null", ")", "{", "switch", "(", "option", ")", "{", "case", "FILESYSTEM_ONLY", ":", "if", "(", "this", ".", "tryFS", "(", "directory", ")", "==", "false", ")", "{", "if", "(", "this", ".", "tryCP", "(", "directory", ")", "==", "false", ")", "{", "this", ".", "errors", ".", "addError", "(", "\"constructor(init) - could not find directory <\"", "+", "directory", "+", "\">, tried file system\"", ")", ";", "}", "}", "break", ";", "case", "CLASSPATH_ONLY", ":", "if", "(", "this", ".", "tryCP", "(", "directory", ")", "==", "false", ")", "{", "if", "(", "this", ".", "tryCP", "(", "directory", ")", "==", "false", ")", "{", "this", ".", "errors", ".", "addError", "(", "\"constructor(init) - could not find directory <\"", "+", "directory", "+", "\">>, tried using class path\"", ")", ";", "}", "}", "break", ";", "case", "TRY_FS_THEN_CLASSPATH", ":", "if", "(", "this", ".", "tryFS", "(", "directory", ")", "==", "false", ")", "{", "this", ".", "errors", ".", "clearErrorMessages", "(", ")", ";", ";", "if", "(", "this", ".", "tryCP", "(", "directory", ")", "==", "false", ")", "{", "this", ".", "errors", ".", "addError", "(", "\"constructor(init) - could not find directory <\"", "+", "directory", "+", "\">, tried file system then using class path\"", ")", ";", "}", "}", "break", ";", "case", "TRY_CLASSPATH_THEN_FS", ":", "if", "(", "this", ".", "tryCP", "(", "directory", ")", "==", "false", ")", "{", "this", ".", "errors", ".", "clearErrorMessages", "(", ")", ";", ";", "if", "(", "this", ".", "tryFS", "(", "directory", ")", "==", "false", ")", "{", "this", ".", "errors", ".", "addError", "(", "\"constructor(init) - could not find directory <\"", "+", "directory", "+", "\">, tried using class path then file system\"", ")", ";", "}", "}", "break", ";", "default", ":", "this", ".", "errors", ".", "addError", "(", "\"constructor(init) - unknown location option <\"", "+", "option", "+", "\"> for directories\"", ")", ";", "}", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "this", ".", "errors", ".", "addError", "(", "\"init() - catched unpredicted exception: \"", "+", "ex", ".", "getMessage", "(", ")", ")", ";", "}", "}" ]
Initialize the directory info object with any parameters presented by the constructors. @param directory a directory name @param option an option on how to locate the directory
[ "Initialize", "the", "directory", "info", "object", "with", "any", "parameters", "presented", "by", "the", "constructors", "." ]
6d845bcc482aa9344d016e80c0c3455aeae13a13
https://github.com/vdmeer/skb-java-base/blob/6d845bcc482aa9344d016e80c0c3455aeae13a13/src/main/java/de/vandermeer/skb/base/info/AbstractDirectoryInfo.java#L112-L159
150,966
vdmeer/skb-java-base
src/main/java/de/vandermeer/skb/base/info/AbstractDirectoryInfo.java
AbstractDirectoryInfo.tryFS
protected final boolean tryFS(String directory){ String path = directory; File file = new File(path); if(this.testDirectory(file)==true){ //found in file system try{ this.url = file.toURI().toURL(); this.file = file; this.fullDirectoryName = FilenameUtils.getPath(file.getAbsolutePath()); this.setRootPath = directory; return true; } catch (MalformedURLException e) { this.errors.addError("init() - malformed URL for file with name " + this.file.getAbsolutePath() + " and message: " + e.getMessage()); } } return false; }
java
protected final boolean tryFS(String directory){ String path = directory; File file = new File(path); if(this.testDirectory(file)==true){ //found in file system try{ this.url = file.toURI().toURL(); this.file = file; this.fullDirectoryName = FilenameUtils.getPath(file.getAbsolutePath()); this.setRootPath = directory; return true; } catch (MalformedURLException e) { this.errors.addError("init() - malformed URL for file with name " + this.file.getAbsolutePath() + " and message: " + e.getMessage()); } } return false; }
[ "protected", "final", "boolean", "tryFS", "(", "String", "directory", ")", "{", "String", "path", "=", "directory", ";", "File", "file", "=", "new", "File", "(", "path", ")", ";", "if", "(", "this", ".", "testDirectory", "(", "file", ")", "==", "true", ")", "{", "//found in file system", "try", "{", "this", ".", "url", "=", "file", ".", "toURI", "(", ")", ".", "toURL", "(", ")", ";", "this", ".", "file", "=", "file", ";", "this", ".", "fullDirectoryName", "=", "FilenameUtils", ".", "getPath", "(", "file", ".", "getAbsolutePath", "(", ")", ")", ";", "this", ".", "setRootPath", "=", "directory", ";", "return", "true", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "this", ".", "errors", ".", "addError", "(", "\"init() - malformed URL for file with name \"", "+", "this", ".", "file", ".", "getAbsolutePath", "(", ")", "+", "\" and message: \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "return", "false", ";", "}" ]
Try to locate a directory in the file system. @param directory the directory to locate @return true if the directory was found, false otherwise
[ "Try", "to", "locate", "a", "directory", "in", "the", "file", "system", "." ]
6d845bcc482aa9344d016e80c0c3455aeae13a13
https://github.com/vdmeer/skb-java-base/blob/6d845bcc482aa9344d016e80c0c3455aeae13a13/src/main/java/de/vandermeer/skb/base/info/AbstractDirectoryInfo.java#L166-L183
150,967
vdmeer/skb-java-base
src/main/java/de/vandermeer/skb/base/info/AbstractDirectoryInfo.java
AbstractDirectoryInfo.tryCP
protected final boolean tryCP(String directory){ String[] cp = StringUtils.split(System.getProperty("java.class.path"), File.pathSeparatorChar); for(String s : cp){ if(!StringUtils.endsWith(s, ".jar") && !StringUtils.startsWith(s, "/")){ String path = s + File.separator + directory; File file = new File(path); if(this.testDirectory(file)==true){ //found using class path try{ this.url = file.toURI().toURL(); this.file = file; this.fullDirectoryName = FilenameUtils.getPath(file.getAbsolutePath()); this.setRootPath = directory; return true; } catch (MalformedURLException e) { this.errors.addError("init() - malformed URL for file with name " + this.file.getAbsolutePath() + " and message: " + e.getMessage()); } } } } return false; }
java
protected final boolean tryCP(String directory){ String[] cp = StringUtils.split(System.getProperty("java.class.path"), File.pathSeparatorChar); for(String s : cp){ if(!StringUtils.endsWith(s, ".jar") && !StringUtils.startsWith(s, "/")){ String path = s + File.separator + directory; File file = new File(path); if(this.testDirectory(file)==true){ //found using class path try{ this.url = file.toURI().toURL(); this.file = file; this.fullDirectoryName = FilenameUtils.getPath(file.getAbsolutePath()); this.setRootPath = directory; return true; } catch (MalformedURLException e) { this.errors.addError("init() - malformed URL for file with name " + this.file.getAbsolutePath() + " and message: " + e.getMessage()); } } } } return false; }
[ "protected", "final", "boolean", "tryCP", "(", "String", "directory", ")", "{", "String", "[", "]", "cp", "=", "StringUtils", ".", "split", "(", "System", ".", "getProperty", "(", "\"java.class.path\"", ")", ",", "File", ".", "pathSeparatorChar", ")", ";", "for", "(", "String", "s", ":", "cp", ")", "{", "if", "(", "!", "StringUtils", ".", "endsWith", "(", "s", ",", "\".jar\"", ")", "&&", "!", "StringUtils", ".", "startsWith", "(", "s", ",", "\"/\"", ")", ")", "{", "String", "path", "=", "s", "+", "File", ".", "separator", "+", "directory", ";", "File", "file", "=", "new", "File", "(", "path", ")", ";", "if", "(", "this", ".", "testDirectory", "(", "file", ")", "==", "true", ")", "{", "//found using class path", "try", "{", "this", ".", "url", "=", "file", ".", "toURI", "(", ")", ".", "toURL", "(", ")", ";", "this", ".", "file", "=", "file", ";", "this", ".", "fullDirectoryName", "=", "FilenameUtils", ".", "getPath", "(", "file", ".", "getAbsolutePath", "(", ")", ")", ";", "this", ".", "setRootPath", "=", "directory", ";", "return", "true", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "this", ".", "errors", ".", "addError", "(", "\"init() - malformed URL for file with name \"", "+", "this", ".", "file", ".", "getAbsolutePath", "(", ")", "+", "\" and message: \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "}", "}", "return", "false", ";", "}" ]
Try to locate a directory using any directory given in the class path as set-root. @param directory the directory to locate @return true if the directory was found, false otherwise
[ "Try", "to", "locate", "a", "directory", "using", "any", "directory", "given", "in", "the", "class", "path", "as", "set", "-", "root", "." ]
6d845bcc482aa9344d016e80c0c3455aeae13a13
https://github.com/vdmeer/skb-java-base/blob/6d845bcc482aa9344d016e80c0c3455aeae13a13/src/main/java/de/vandermeer/skb/base/info/AbstractDirectoryInfo.java#L190-L213
150,968
jpaoletti/java-presentation-manager
modules/jpm-core/src/main/java/jpaoletti/jpm/core/Operations.java
Operations.getOperation
public Operation getOperation(String id) { for (Iterator<Operation> it = operations.iterator(); it.hasNext();) { Operation oper = it.next(); if (oper.getId().compareTo(id) == 0) { return oper; } } return null; }
java
public Operation getOperation(String id) { for (Iterator<Operation> it = operations.iterator(); it.hasNext();) { Operation oper = it.next(); if (oper.getId().compareTo(id) == 0) { return oper; } } return null; }
[ "public", "Operation", "getOperation", "(", "String", "id", ")", "{", "for", "(", "Iterator", "<", "Operation", ">", "it", "=", "operations", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "Operation", "oper", "=", "it", ".", "next", "(", ")", ";", "if", "(", "oper", ".", "getId", "(", ")", ".", "compareTo", "(", "id", ")", "==", "0", ")", "{", "return", "oper", ";", "}", "}", "return", "null", ";", "}" ]
Returns the operation of the given id or a new default operation. If no operation was found, null is returned. @param id The id @return The operation
[ "Returns", "the", "operation", "of", "the", "given", "id", "or", "a", "new", "default", "operation", ".", "If", "no", "operation", "was", "found", "null", "is", "returned", "." ]
d5aab55638383695db244744b4bfe27c5200e04f
https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-core/src/main/java/jpaoletti/jpm/core/Operations.java#L28-L36
150,969
jpaoletti/java-presentation-manager
modules/jpm-core/src/main/java/jpaoletti/jpm/core/Operations.java
Operations.getOperationsFor
public Operations getOperationsFor(final PMContext ctx, Object instance, Operation operation) throws PMException { final Operations result = new Operations(); final List<Operation> r = new ArrayList<Operation>(); if (operation != null) { for (Operation op : getOperations()) { if (op.isDisplayed(operation.getId()) && op.isEnabled() && !op.equals(operation)) { if (op.getCondition() == null || op.getCondition().check(ctx, instance, op, operation.getId())) { if (instance != null || OperationScope.GENERAL.is(op.getScope()) || OperationScope.SELECTED.is(op.getScope())) { r.add(op); } } } } } result.setOperations(r); return result; }
java
public Operations getOperationsFor(final PMContext ctx, Object instance, Operation operation) throws PMException { final Operations result = new Operations(); final List<Operation> r = new ArrayList<Operation>(); if (operation != null) { for (Operation op : getOperations()) { if (op.isDisplayed(operation.getId()) && op.isEnabled() && !op.equals(operation)) { if (op.getCondition() == null || op.getCondition().check(ctx, instance, op, operation.getId())) { if (instance != null || OperationScope.GENERAL.is(op.getScope()) || OperationScope.SELECTED.is(op.getScope())) { r.add(op); } } } } } result.setOperations(r); return result; }
[ "public", "Operations", "getOperationsFor", "(", "final", "PMContext", "ctx", ",", "Object", "instance", ",", "Operation", "operation", ")", "throws", "PMException", "{", "final", "Operations", "result", "=", "new", "Operations", "(", ")", ";", "final", "List", "<", "Operation", ">", "r", "=", "new", "ArrayList", "<", "Operation", ">", "(", ")", ";", "if", "(", "operation", "!=", "null", ")", "{", "for", "(", "Operation", "op", ":", "getOperations", "(", ")", ")", "{", "if", "(", "op", ".", "isDisplayed", "(", "operation", ".", "getId", "(", ")", ")", "&&", "op", ".", "isEnabled", "(", ")", "&&", "!", "op", ".", "equals", "(", "operation", ")", ")", "{", "if", "(", "op", ".", "getCondition", "(", ")", "==", "null", "||", "op", ".", "getCondition", "(", ")", ".", "check", "(", "ctx", ",", "instance", ",", "op", ",", "operation", ".", "getId", "(", ")", ")", ")", "{", "if", "(", "instance", "!=", "null", "||", "OperationScope", ".", "GENERAL", ".", "is", "(", "op", ".", "getScope", "(", ")", ")", "||", "OperationScope", ".", "SELECTED", ".", "is", "(", "op", ".", "getScope", "(", ")", ")", ")", "{", "r", ".", "add", "(", "op", ")", ";", "}", "}", "}", "}", "}", "result", ".", "setOperations", "(", "r", ")", ";", "return", "result", ";", "}" ]
Returns the Operations for a given operation. That is the operations that are different to the given one, enabled and visible in it. @param operation The operation @return The operations
[ "Returns", "the", "Operations", "for", "a", "given", "operation", ".", "That", "is", "the", "operations", "that", "are", "different", "to", "the", "given", "one", "enabled", "and", "visible", "in", "it", "." ]
d5aab55638383695db244744b4bfe27c5200e04f
https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-core/src/main/java/jpaoletti/jpm/core/Operations.java#L45-L61
150,970
jpaoletti/java-presentation-manager
modules/jpm-core/src/main/java/jpaoletti/jpm/core/Operations.java
Operations.getOperationsForScope
public Operations getOperationsForScope(OperationScope... scopes) { final Operations result = new Operations(); final List<Operation> r = new ArrayList<Operation>(); if (getOperations() != null) { for (Operation op : getOperations()) { if (op.getScope() != null) { String s = op.getScope().trim(); for (int i = 0; i < scopes.length; i++) { OperationScope scope = scopes[i]; if (scope.is(s)) { r.add(op); break; } } } } result.setOperations(r); } return result; }
java
public Operations getOperationsForScope(OperationScope... scopes) { final Operations result = new Operations(); final List<Operation> r = new ArrayList<Operation>(); if (getOperations() != null) { for (Operation op : getOperations()) { if (op.getScope() != null) { String s = op.getScope().trim(); for (int i = 0; i < scopes.length; i++) { OperationScope scope = scopes[i]; if (scope.is(s)) { r.add(op); break; } } } } result.setOperations(r); } return result; }
[ "public", "Operations", "getOperationsForScope", "(", "OperationScope", "...", "scopes", ")", "{", "final", "Operations", "result", "=", "new", "Operations", "(", ")", ";", "final", "List", "<", "Operation", ">", "r", "=", "new", "ArrayList", "<", "Operation", ">", "(", ")", ";", "if", "(", "getOperations", "(", ")", "!=", "null", ")", "{", "for", "(", "Operation", "op", ":", "getOperations", "(", ")", ")", "{", "if", "(", "op", ".", "getScope", "(", ")", "!=", "null", ")", "{", "String", "s", "=", "op", ".", "getScope", "(", ")", ".", "trim", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "scopes", ".", "length", ";", "i", "++", ")", "{", "OperationScope", "scope", "=", "scopes", "[", "i", "]", ";", "if", "(", "scope", ".", "is", "(", "s", ")", ")", "{", "r", ".", "add", "(", "op", ")", ";", "break", ";", "}", "}", "}", "}", "result", ".", "setOperations", "(", "r", ")", ";", "}", "return", "result", ";", "}" ]
Returns an Operations object for the given scope @param scopes The scopes @return The Operations
[ "Returns", "an", "Operations", "object", "for", "the", "given", "scope" ]
d5aab55638383695db244744b4bfe27c5200e04f
https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-core/src/main/java/jpaoletti/jpm/core/Operations.java#L77-L96
150,971
ksclarke/solr-iso639-filter
src/main/java/info/freelibrary/solr/ISO639ConversionFilter.java
ISO639ConversionFilter.incrementToken
@Override public boolean incrementToken() throws IOException { if (!input.incrementToken()) { return false; } final String t = myTermAttribute.toString(); if (t != null && t.length() != 0) { try { myTermAttribute.setEmpty().append(ISO639Converter.convert(t)); } catch (final IllegalArgumentException details) { if (LOGGER.isWarnEnabled()) { LOGGER.warn(details.getMessage(), details); } } } return true; }
java
@Override public boolean incrementToken() throws IOException { if (!input.incrementToken()) { return false; } final String t = myTermAttribute.toString(); if (t != null && t.length() != 0) { try { myTermAttribute.setEmpty().append(ISO639Converter.convert(t)); } catch (final IllegalArgumentException details) { if (LOGGER.isWarnEnabled()) { LOGGER.warn(details.getMessage(), details); } } } return true; }
[ "@", "Override", "public", "boolean", "incrementToken", "(", ")", "throws", "IOException", "{", "if", "(", "!", "input", ".", "incrementToken", "(", ")", ")", "{", "return", "false", ";", "}", "final", "String", "t", "=", "myTermAttribute", ".", "toString", "(", ")", ";", "if", "(", "t", "!=", "null", "&&", "t", ".", "length", "(", ")", "!=", "0", ")", "{", "try", "{", "myTermAttribute", ".", "setEmpty", "(", ")", ".", "append", "(", "ISO639Converter", ".", "convert", "(", "t", ")", ")", ";", "}", "catch", "(", "final", "IllegalArgumentException", "details", ")", "{", "if", "(", "LOGGER", ".", "isWarnEnabled", "(", ")", ")", "{", "LOGGER", ".", "warn", "(", "details", ".", "getMessage", "(", ")", ",", "details", ")", ";", "}", "}", "}", "return", "true", ";", "}" ]
Increments and processes tokens in the ISO-639 code stream. @return True if a value is still available for processing in the token stream; otherwise, false
[ "Increments", "and", "processes", "tokens", "in", "the", "ISO", "-", "639", "code", "stream", "." ]
edcb3d898cfc153b5d089949b4b6609e7e7f082d
https://github.com/ksclarke/solr-iso639-filter/blob/edcb3d898cfc153b5d089949b4b6609e7e7f082d/src/main/java/info/freelibrary/solr/ISO639ConversionFilter.java#L59-L78
150,972
GerdHolz/TOVAL
src/de/invation/code/toval/misc/SetUtils.java
SetUtils.getPowerSet
public static <T> PowerSet<T> getPowerSet(Set<T> hashSet) { Validate.notNull(hashSet); if (hashSet.isEmpty()) throw new IllegalArgumentException("set size 0"); HashList<T> hashList = new HashList<>(hashSet); PowerSet<T> result = new PowerSet<>(hashList.size()); for (int i = 0; i < Math.pow(2, hashList.size()); i++) { int setSize = Integer.bitCount(i); HashSet<T> newList = new HashSet<>(setSize); result.get(setSize).add(newList); for (int j = 0; j < hashList.size(); j++) { if ((i & (1 << j)) != 0) { newList.add(hashList.get(j)); } } } return result; }
java
public static <T> PowerSet<T> getPowerSet(Set<T> hashSet) { Validate.notNull(hashSet); if (hashSet.isEmpty()) throw new IllegalArgumentException("set size 0"); HashList<T> hashList = new HashList<>(hashSet); PowerSet<T> result = new PowerSet<>(hashList.size()); for (int i = 0; i < Math.pow(2, hashList.size()); i++) { int setSize = Integer.bitCount(i); HashSet<T> newList = new HashSet<>(setSize); result.get(setSize).add(newList); for (int j = 0; j < hashList.size(); j++) { if ((i & (1 << j)) != 0) { newList.add(hashList.get(j)); } } } return result; }
[ "public", "static", "<", "T", ">", "PowerSet", "<", "T", ">", "getPowerSet", "(", "Set", "<", "T", ">", "hashSet", ")", "{", "Validate", ".", "notNull", "(", "hashSet", ")", ";", "if", "(", "hashSet", ".", "isEmpty", "(", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"set size 0\"", ")", ";", "HashList", "<", "T", ">", "hashList", "=", "new", "HashList", "<>", "(", "hashSet", ")", ";", "PowerSet", "<", "T", ">", "result", "=", "new", "PowerSet", "<>", "(", "hashList", ".", "size", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "Math", ".", "pow", "(", "2", ",", "hashList", ".", "size", "(", ")", ")", ";", "i", "++", ")", "{", "int", "setSize", "=", "Integer", ".", "bitCount", "(", "i", ")", ";", "HashSet", "<", "T", ">", "newList", "=", "new", "HashSet", "<>", "(", "setSize", ")", ";", "result", ".", "get", "(", "setSize", ")", ".", "add", "(", "newList", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "hashList", ".", "size", "(", ")", ";", "j", "++", ")", "{", "if", "(", "(", "i", "&", "(", "1", "<<", "j", ")", ")", "!=", "0", ")", "{", "newList", ".", "add", "(", "hashList", ".", "get", "(", "j", ")", ")", ";", "}", "}", "}", "return", "result", ";", "}" ]
Generates a new Powerset out of the given set. @param <T> Type of set elements @param hashSet Underlying set of elements @return Powerset of <code>set</code>
[ "Generates", "a", "new", "Powerset", "out", "of", "the", "given", "set", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/misc/SetUtils.java#L101-L118
150,973
GerdHolz/TOVAL
src/de/invation/code/toval/misc/SetUtils.java
SetUtils.union
public static <T> Set<T> union(Collection<Set<T>> sets) { Set<T> result = new HashSet<>(); if (sets.isEmpty()) { return result; } Iterator<Set<T>> iter = sets.iterator(); result.addAll(iter.next()); if (sets.size() == 1) { return result; } while (iter.hasNext()) { result.addAll(iter.next()); } return result; }
java
public static <T> Set<T> union(Collection<Set<T>> sets) { Set<T> result = new HashSet<>(); if (sets.isEmpty()) { return result; } Iterator<Set<T>> iter = sets.iterator(); result.addAll(iter.next()); if (sets.size() == 1) { return result; } while (iter.hasNext()) { result.addAll(iter.next()); } return result; }
[ "public", "static", "<", "T", ">", "Set", "<", "T", ">", "union", "(", "Collection", "<", "Set", "<", "T", ">", ">", "sets", ")", "{", "Set", "<", "T", ">", "result", "=", "new", "HashSet", "<>", "(", ")", ";", "if", "(", "sets", ".", "isEmpty", "(", ")", ")", "{", "return", "result", ";", "}", "Iterator", "<", "Set", "<", "T", ">", ">", "iter", "=", "sets", ".", "iterator", "(", ")", ";", "result", ".", "addAll", "(", "iter", ".", "next", "(", ")", ")", ";", "if", "(", "sets", ".", "size", "(", ")", "==", "1", ")", "{", "return", "result", ";", "}", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "result", ".", "addAll", "(", "iter", ".", "next", "(", ")", ")", ";", "}", "return", "result", ";", "}" ]
Determines the union of a collection of sets. @param <T> @param sets Basic collection of sets. @return The set of distinct elements of all given sets.
[ "Determines", "the", "union", "of", "a", "collection", "of", "sets", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/misc/SetUtils.java#L207-L223
150,974
GerdHolz/TOVAL
src/de/invation/code/toval/misc/SetUtils.java
SetUtils.existPairwiseIntersections
public static boolean existPairwiseIntersections(Collection<Set<String>> sets) { // Determine all possible pairs of sets List<List<Set<String>>> setPairs = ListUtils.getKElementaryLists(new ArrayList<Set<String>>(sets), 2); for (Iterator<List<Set<String>>> iter = setPairs.iterator(); iter.hasNext();) { Set<String> intersection = SetUtils.intersection(iter.next()); if (!intersection.isEmpty()) { return true; } } return false; }
java
public static boolean existPairwiseIntersections(Collection<Set<String>> sets) { // Determine all possible pairs of sets List<List<Set<String>>> setPairs = ListUtils.getKElementaryLists(new ArrayList<Set<String>>(sets), 2); for (Iterator<List<Set<String>>> iter = setPairs.iterator(); iter.hasNext();) { Set<String> intersection = SetUtils.intersection(iter.next()); if (!intersection.isEmpty()) { return true; } } return false; }
[ "public", "static", "boolean", "existPairwiseIntersections", "(", "Collection", "<", "Set", "<", "String", ">", ">", "sets", ")", "{", "// Determine all possible pairs of sets\r", "List", "<", "List", "<", "Set", "<", "String", ">>>", "setPairs", "=", "ListUtils", ".", "getKElementaryLists", "(", "new", "ArrayList", "<", "Set", "<", "String", ">", ">", "(", "sets", ")", ",", "2", ")", ";", "for", "(", "Iterator", "<", "List", "<", "Set", "<", "String", ">", ">", ">", "iter", "=", "setPairs", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "Set", "<", "String", ">", "intersection", "=", "SetUtils", ".", "intersection", "(", "iter", ".", "next", "(", ")", ")", ";", "if", "(", "!", "intersection", ".", "isEmpty", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if any two of the given sets intersect. @param sets Basic collection of sets. @return <code>true</code> if there is an intersection between at least two sets;<br> <code>false</code> otherswise.
[ "Checks", "if", "any", "two", "of", "the", "given", "sets", "intersect", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/misc/SetUtils.java#L277-L287
150,975
PureSolTechnologies/graphs
trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java
RedBlackTree.put
private RedBlackTreeNode<Key, Value> put(RedBlackTreeNode<Key, Value> h, Key key, Value value) { if (h == null) return new RedBlackTreeNode<>(key, value, RED, 1); int cmp = key.compareTo(h.getKey()); if (cmp < 0) h.setLeft(put(h.getLeft(), key, value)); else if (cmp > 0) h.setRight(put(h.getRight(), key, value)); else h.setValue(value); // fix-up any right-leaning links if (isRed(h.getRight()) && !isRed(h.getLeft())) h = rotateLeft(h); if (isRed(h.getLeft()) && isRed(h.getLeft().getLeft())) h = rotateRight(h); if (isRed(h.getLeft()) && isRed(h.getRight())) flipColors(h); h.setSize(size(h.getLeft()) + size(h.getRight()) + 1); return h; }
java
private RedBlackTreeNode<Key, Value> put(RedBlackTreeNode<Key, Value> h, Key key, Value value) { if (h == null) return new RedBlackTreeNode<>(key, value, RED, 1); int cmp = key.compareTo(h.getKey()); if (cmp < 0) h.setLeft(put(h.getLeft(), key, value)); else if (cmp > 0) h.setRight(put(h.getRight(), key, value)); else h.setValue(value); // fix-up any right-leaning links if (isRed(h.getRight()) && !isRed(h.getLeft())) h = rotateLeft(h); if (isRed(h.getLeft()) && isRed(h.getLeft().getLeft())) h = rotateRight(h); if (isRed(h.getLeft()) && isRed(h.getRight())) flipColors(h); h.setSize(size(h.getLeft()) + size(h.getRight()) + 1); return h; }
[ "private", "RedBlackTreeNode", "<", "Key", ",", "Value", ">", "put", "(", "RedBlackTreeNode", "<", "Key", ",", "Value", ">", "h", ",", "Key", "key", ",", "Value", "value", ")", "{", "if", "(", "h", "==", "null", ")", "return", "new", "RedBlackTreeNode", "<>", "(", "key", ",", "value", ",", "RED", ",", "1", ")", ";", "int", "cmp", "=", "key", ".", "compareTo", "(", "h", ".", "getKey", "(", ")", ")", ";", "if", "(", "cmp", "<", "0", ")", "h", ".", "setLeft", "(", "put", "(", "h", ".", "getLeft", "(", ")", ",", "key", ",", "value", ")", ")", ";", "else", "if", "(", "cmp", ">", "0", ")", "h", ".", "setRight", "(", "put", "(", "h", ".", "getRight", "(", ")", ",", "key", ",", "value", ")", ")", ";", "else", "h", ".", "setValue", "(", "value", ")", ";", "// fix-up any right-leaning links", "if", "(", "isRed", "(", "h", ".", "getRight", "(", ")", ")", "&&", "!", "isRed", "(", "h", ".", "getLeft", "(", ")", ")", ")", "h", "=", "rotateLeft", "(", "h", ")", ";", "if", "(", "isRed", "(", "h", ".", "getLeft", "(", ")", ")", "&&", "isRed", "(", "h", ".", "getLeft", "(", ")", ".", "getLeft", "(", ")", ")", ")", "h", "=", "rotateRight", "(", "h", ")", ";", "if", "(", "isRed", "(", "h", ".", "getLeft", "(", ")", ")", "&&", "isRed", "(", "h", ".", "getRight", "(", ")", ")", ")", "flipColors", "(", "h", ")", ";", "h", ".", "setSize", "(", "size", "(", "h", ".", "getLeft", "(", ")", ")", "+", "size", "(", "h", ".", "getRight", "(", ")", ")", "+", "1", ")", ";", "return", "h", ";", "}" ]
insert the key-value pair in the subtree rooted at h
[ "insert", "the", "key", "-", "value", "pair", "in", "the", "subtree", "rooted", "at", "h" ]
35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1
https://github.com/PureSolTechnologies/graphs/blob/35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1/trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java#L80-L102
150,976
PureSolTechnologies/graphs
trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java
RedBlackTree.deleteMax
public void deleteMax() { if (isEmpty()) throw new NoSuchElementException("BST underflow"); // if both children of root are black, set root to red if (!isRed(root.getLeft()) && !isRed(root.getRight())) root.setColor(RED); root = deleteMax(root); if (!isEmpty()) { root.setParent(null); root.setColor(BLACK); } // assert check(); }
java
public void deleteMax() { if (isEmpty()) throw new NoSuchElementException("BST underflow"); // if both children of root are black, set root to red if (!isRed(root.getLeft()) && !isRed(root.getRight())) root.setColor(RED); root = deleteMax(root); if (!isEmpty()) { root.setParent(null); root.setColor(BLACK); } // assert check(); }
[ "public", "void", "deleteMax", "(", ")", "{", "if", "(", "isEmpty", "(", ")", ")", "throw", "new", "NoSuchElementException", "(", "\"BST underflow\"", ")", ";", "// if both children of root are black, set root to red", "if", "(", "!", "isRed", "(", "root", ".", "getLeft", "(", ")", ")", "&&", "!", "isRed", "(", "root", ".", "getRight", "(", ")", ")", ")", "root", ".", "setColor", "(", "RED", ")", ";", "root", "=", "deleteMax", "(", "root", ")", ";", "if", "(", "!", "isEmpty", "(", ")", ")", "{", "root", ".", "setParent", "(", "null", ")", ";", "root", ".", "setColor", "(", "BLACK", ")", ";", "}", "// assert check();", "}" ]
Removes the largest key and associated value from the symbol table. @throws NoSuchElementException if the symbol table is empty
[ "Removes", "the", "largest", "key", "and", "associated", "value", "from", "the", "symbol", "table", "." ]
35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1
https://github.com/PureSolTechnologies/graphs/blob/35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1/trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java#L148-L162
150,977
PureSolTechnologies/graphs
trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java
RedBlackTree.delete
private RedBlackTreeNode<Key, Value> delete(RedBlackTreeNode<Key, Value> h, Key key) { // assert get(h, key) != null; if (key.compareTo(h.getKey()) < 0) { if (!isRed(h.getLeft()) && !isRed(h.getLeft().getLeft())) h = moveRedLeft(h); h.setLeft(delete(h.getLeft(), key)); } else { if (isRed(h.getLeft())) h = rotateRight(h); if (key.compareTo(h.getKey()) == 0 && (h.getRight() == null)) return null; if (!isRed(h.getRight()) && !isRed(h.getRight().getLeft())) h = moveRedRight(h); if (key.compareTo(h.getKey()) == 0) { RedBlackTreeNode<Key, Value> x = min(h.getRight()); h.setKey(x.getKey()); h.setValue(x.getValue()); // h.val = get(h.right, min(h.right).key); // h.key = min(h.right).key; h.setRight(deleteMin(h.getRight())); } else h.setRight(delete(h.getRight(), key)); } return balance(h); }
java
private RedBlackTreeNode<Key, Value> delete(RedBlackTreeNode<Key, Value> h, Key key) { // assert get(h, key) != null; if (key.compareTo(h.getKey()) < 0) { if (!isRed(h.getLeft()) && !isRed(h.getLeft().getLeft())) h = moveRedLeft(h); h.setLeft(delete(h.getLeft(), key)); } else { if (isRed(h.getLeft())) h = rotateRight(h); if (key.compareTo(h.getKey()) == 0 && (h.getRight() == null)) return null; if (!isRed(h.getRight()) && !isRed(h.getRight().getLeft())) h = moveRedRight(h); if (key.compareTo(h.getKey()) == 0) { RedBlackTreeNode<Key, Value> x = min(h.getRight()); h.setKey(x.getKey()); h.setValue(x.getValue()); // h.val = get(h.right, min(h.right).key); // h.key = min(h.right).key; h.setRight(deleteMin(h.getRight())); } else h.setRight(delete(h.getRight(), key)); } return balance(h); }
[ "private", "RedBlackTreeNode", "<", "Key", ",", "Value", ">", "delete", "(", "RedBlackTreeNode", "<", "Key", ",", "Value", ">", "h", ",", "Key", "key", ")", "{", "// assert get(h, key) != null;", "if", "(", "key", ".", "compareTo", "(", "h", ".", "getKey", "(", ")", ")", "<", "0", ")", "{", "if", "(", "!", "isRed", "(", "h", ".", "getLeft", "(", ")", ")", "&&", "!", "isRed", "(", "h", ".", "getLeft", "(", ")", ".", "getLeft", "(", ")", ")", ")", "h", "=", "moveRedLeft", "(", "h", ")", ";", "h", ".", "setLeft", "(", "delete", "(", "h", ".", "getLeft", "(", ")", ",", "key", ")", ")", ";", "}", "else", "{", "if", "(", "isRed", "(", "h", ".", "getLeft", "(", ")", ")", ")", "h", "=", "rotateRight", "(", "h", ")", ";", "if", "(", "key", ".", "compareTo", "(", "h", ".", "getKey", "(", ")", ")", "==", "0", "&&", "(", "h", ".", "getRight", "(", ")", "==", "null", ")", ")", "return", "null", ";", "if", "(", "!", "isRed", "(", "h", ".", "getRight", "(", ")", ")", "&&", "!", "isRed", "(", "h", ".", "getRight", "(", ")", ".", "getLeft", "(", ")", ")", ")", "h", "=", "moveRedRight", "(", "h", ")", ";", "if", "(", "key", ".", "compareTo", "(", "h", ".", "getKey", "(", ")", ")", "==", "0", ")", "{", "RedBlackTreeNode", "<", "Key", ",", "Value", ">", "x", "=", "min", "(", "h", ".", "getRight", "(", ")", ")", ";", "h", ".", "setKey", "(", "x", ".", "getKey", "(", ")", ")", ";", "h", ".", "setValue", "(", "x", ".", "getValue", "(", ")", ")", ";", "// h.val = get(h.right, min(h.right).key);", "// h.key = min(h.right).key;", "h", ".", "setRight", "(", "deleteMin", "(", "h", ".", "getRight", "(", ")", ")", ")", ";", "}", "else", "h", ".", "setRight", "(", "delete", "(", "h", ".", "getRight", "(", ")", ",", "key", ")", ")", ";", "}", "return", "balance", "(", "h", ")", ";", "}" ]
delete the key-value pair with the given key rooted at h
[ "delete", "the", "key", "-", "value", "pair", "with", "the", "given", "key", "rooted", "at", "h" ]
35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1
https://github.com/PureSolTechnologies/graphs/blob/35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1/trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java#L208-L233
150,978
PureSolTechnologies/graphs
trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java
RedBlackTree.max
private RedBlackTreeNode<Key, Value> max(RedBlackTreeNode<Key, Value> x) { // assert x != null; if (x.getRight() == null) return x; else return max(x.getRight()); }
java
private RedBlackTreeNode<Key, Value> max(RedBlackTreeNode<Key, Value> x) { // assert x != null; if (x.getRight() == null) return x; else return max(x.getRight()); }
[ "private", "RedBlackTreeNode", "<", "Key", ",", "Value", ">", "max", "(", "RedBlackTreeNode", "<", "Key", ",", "Value", ">", "x", ")", "{", "// assert x != null;", "if", "(", "x", ".", "getRight", "(", ")", "==", "null", ")", "return", "x", ";", "else", "return", "max", "(", "x", ".", "getRight", "(", ")", ")", ";", "}" ]
the largest key in the subtree rooted at x; null if no such key
[ "the", "largest", "key", "in", "the", "subtree", "rooted", "at", "x", ";", "null", "if", "no", "such", "key" ]
35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1
https://github.com/PureSolTechnologies/graphs/blob/35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1/trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java#L378-L384
150,979
PureSolTechnologies/graphs
trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java
RedBlackTree.select
public Key select(int k) { if (k < 0 || k >= size(root)) throw new IllegalArgumentException(); RedBlackTreeNode<Key, Value> x = select(root, k); return x.getKey(); }
java
public Key select(int k) { if (k < 0 || k >= size(root)) throw new IllegalArgumentException(); RedBlackTreeNode<Key, Value> x = select(root, k); return x.getKey(); }
[ "public", "Key", "select", "(", "int", "k", ")", "{", "if", "(", "k", "<", "0", "||", "k", ">=", "size", "(", "root", ")", ")", "throw", "new", "IllegalArgumentException", "(", ")", ";", "RedBlackTreeNode", "<", "Key", ",", "Value", ">", "x", "=", "select", "(", "root", ",", "k", ")", ";", "return", "x", ".", "getKey", "(", ")", ";", "}" ]
Return the kth smallest key in the symbol table. @param k the order statistic @return the kth smallest key in the symbol table @throws IllegalArgumentException unless <code>k</code> is between 0 and <em>N</em> &minus; 1
[ "Return", "the", "kth", "smallest", "key", "in", "the", "symbol", "table", "." ]
35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1
https://github.com/PureSolTechnologies/graphs/blob/35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1/trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java#L526-L531
150,980
PureSolTechnologies/graphs
trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java
RedBlackTree.select
private RedBlackTreeNode<Key, Value> select(RedBlackTreeNode<Key, Value> x, int k) { // assert x != null; // assert k >= 0 && k < size(x); int t = size(x.getLeft()); if (t > k) return select(x.getLeft(), k); else if (t < k) return select(x.getRight(), k - t - 1); else return x; }
java
private RedBlackTreeNode<Key, Value> select(RedBlackTreeNode<Key, Value> x, int k) { // assert x != null; // assert k >= 0 && k < size(x); int t = size(x.getLeft()); if (t > k) return select(x.getLeft(), k); else if (t < k) return select(x.getRight(), k - t - 1); else return x; }
[ "private", "RedBlackTreeNode", "<", "Key", ",", "Value", ">", "select", "(", "RedBlackTreeNode", "<", "Key", ",", "Value", ">", "x", ",", "int", "k", ")", "{", "// assert x != null;", "// assert k >= 0 && k < size(x);", "int", "t", "=", "size", "(", "x", ".", "getLeft", "(", ")", ")", ";", "if", "(", "t", ">", "k", ")", "return", "select", "(", "x", ".", "getLeft", "(", ")", ",", "k", ")", ";", "else", "if", "(", "t", "<", "k", ")", "return", "select", "(", "x", ".", "getRight", "(", ")", ",", "k", "-", "t", "-", "1", ")", ";", "else", "return", "x", ";", "}" ]
the key of rank k in the subtree rooted at x
[ "the", "key", "of", "rank", "k", "in", "the", "subtree", "rooted", "at", "x" ]
35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1
https://github.com/PureSolTechnologies/graphs/blob/35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1/trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java#L534-L544
150,981
PureSolTechnologies/graphs
trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java
RedBlackTree.rank
private int rank(Key key, RedBlackTreeNode<Key, Value> x) { if (x == null) return 0; int cmp = key.compareTo(x.getKey()); if (cmp < 0) return rank(key, x.getLeft()); else if (cmp > 0) return 1 + size(x.getLeft()) + rank(key, x.getRight()); else return size(x.getLeft()); }
java
private int rank(Key key, RedBlackTreeNode<Key, Value> x) { if (x == null) return 0; int cmp = key.compareTo(x.getKey()); if (cmp < 0) return rank(key, x.getLeft()); else if (cmp > 0) return 1 + size(x.getLeft()) + rank(key, x.getRight()); else return size(x.getLeft()); }
[ "private", "int", "rank", "(", "Key", "key", ",", "RedBlackTreeNode", "<", "Key", ",", "Value", ">", "x", ")", "{", "if", "(", "x", "==", "null", ")", "return", "0", ";", "int", "cmp", "=", "key", ".", "compareTo", "(", "x", ".", "getKey", "(", ")", ")", ";", "if", "(", "cmp", "<", "0", ")", "return", "rank", "(", "key", ",", "x", ".", "getLeft", "(", ")", ")", ";", "else", "if", "(", "cmp", ">", "0", ")", "return", "1", "+", "size", "(", "x", ".", "getLeft", "(", ")", ")", "+", "rank", "(", "key", ",", "x", ".", "getRight", "(", ")", ")", ";", "else", "return", "size", "(", "x", ".", "getLeft", "(", ")", ")", ";", "}" ]
number of keys less than key in the subtree rooted at x
[ "number", "of", "keys", "less", "than", "key", "in", "the", "subtree", "rooted", "at", "x" ]
35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1
https://github.com/PureSolTechnologies/graphs/blob/35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1/trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java#L560-L570
150,982
PureSolTechnologies/graphs
trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java
RedBlackTree.keys
private void keys(RedBlackTreeNode<Key, Value> x, Queue<Key> queue, Key lo, Key hi) { if (x == null) return; int cmplo = lo.compareTo(x.getKey()); int cmphi = hi.compareTo(x.getKey()); if (cmplo < 0) keys(x.getLeft(), queue, lo, hi); if (cmplo <= 0 && cmphi >= 0) queue.offer(x.getKey()); if (cmphi > 0) keys(x.getRight(), queue, lo, hi); }
java
private void keys(RedBlackTreeNode<Key, Value> x, Queue<Key> queue, Key lo, Key hi) { if (x == null) return; int cmplo = lo.compareTo(x.getKey()); int cmphi = hi.compareTo(x.getKey()); if (cmplo < 0) keys(x.getLeft(), queue, lo, hi); if (cmplo <= 0 && cmphi >= 0) queue.offer(x.getKey()); if (cmphi > 0) keys(x.getRight(), queue, lo, hi); }
[ "private", "void", "keys", "(", "RedBlackTreeNode", "<", "Key", ",", "Value", ">", "x", ",", "Queue", "<", "Key", ">", "queue", ",", "Key", "lo", ",", "Key", "hi", ")", "{", "if", "(", "x", "==", "null", ")", "return", ";", "int", "cmplo", "=", "lo", ".", "compareTo", "(", "x", ".", "getKey", "(", ")", ")", ";", "int", "cmphi", "=", "hi", ".", "compareTo", "(", "x", ".", "getKey", "(", ")", ")", ";", "if", "(", "cmplo", "<", "0", ")", "keys", "(", "x", ".", "getLeft", "(", ")", ",", "queue", ",", "lo", ",", "hi", ")", ";", "if", "(", "cmplo", "<=", "0", "&&", "cmphi", ">=", "0", ")", "queue", ".", "offer", "(", "x", ".", "getKey", "(", ")", ")", ";", "if", "(", "cmphi", ">", "0", ")", "keys", "(", "x", ".", "getRight", "(", ")", ",", "queue", ",", "lo", ",", "hi", ")", ";", "}" ]
to the queue
[ "to", "the", "queue" ]
35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1
https://github.com/PureSolTechnologies/graphs/blob/35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1/trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java#L609-L620
150,983
PureSolTechnologies/graphs
trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java
RedBlackTree.size
public int size(Key low, Key high) { if (low.compareTo(high) > 0) return 0; if (contains(high)) return rank(high) - rank(low) + 1; else return rank(high) - rank(low); }
java
public int size(Key low, Key high) { if (low.compareTo(high) > 0) return 0; if (contains(high)) return rank(high) - rank(low) + 1; else return rank(high) - rank(low); }
[ "public", "int", "size", "(", "Key", "low", ",", "Key", "high", ")", "{", "if", "(", "low", ".", "compareTo", "(", "high", ")", ">", "0", ")", "return", "0", ";", "if", "(", "contains", "(", "high", ")", ")", "return", "rank", "(", "high", ")", "-", "rank", "(", "low", ")", "+", "1", ";", "else", "return", "rank", "(", "high", ")", "-", "rank", "(", "low", ")", ";", "}" ]
Returns the number of keys in the symbol table in the given range. @param low is the lower border. @param high is the upper border. @return the number of keys in the symbol table between <code>low</code> (inclusive) and <code>high</code> (exclusive)
[ "Returns", "the", "number", "of", "keys", "in", "the", "symbol", "table", "in", "the", "given", "range", "." ]
35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1
https://github.com/PureSolTechnologies/graphs/blob/35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1/trees/src/main/java/com/puresoltechnologies/graphs/trees/RedBlackTree.java#L632-L639
150,984
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/util/CompositeNamedObject.java
CompositeNamedObject.add
public void add(ILocalizableString name, Object object) { objects.add(new Pair<>(name, object)); }
java
public void add(ILocalizableString name, Object object) { objects.add(new Pair<>(name, object)); }
[ "public", "void", "add", "(", "ILocalizableString", "name", ",", "Object", "object", ")", "{", "objects", ".", "add", "(", "new", "Pair", "<>", "(", "name", ",", "object", ")", ")", ";", "}" ]
Add an object.
[ "Add", "an", "object", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/util/CompositeNamedObject.java#L13-L15
150,985
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/progress/MultiTaskProgress.java
MultiTaskProgress.doneOnSubTasksDone
public void doneOnSubTasksDone() { if (jp != null) return; synchronized (tasks) { jp = new JoinPoint<>(); for (SubTask task : tasks) jp.addToJoinDoNotCancel(task.getProgress().getSynch()); } jp.listenInline(new Runnable() { @Override public void run() { if (jp.hasError()) error(jp.getError()); else done(); } }); jp.start(); }
java
public void doneOnSubTasksDone() { if (jp != null) return; synchronized (tasks) { jp = new JoinPoint<>(); for (SubTask task : tasks) jp.addToJoinDoNotCancel(task.getProgress().getSynch()); } jp.listenInline(new Runnable() { @Override public void run() { if (jp.hasError()) error(jp.getError()); else done(); } }); jp.start(); }
[ "public", "void", "doneOnSubTasksDone", "(", ")", "{", "if", "(", "jp", "!=", "null", ")", "return", ";", "synchronized", "(", "tasks", ")", "{", "jp", "=", "new", "JoinPoint", "<>", "(", ")", ";", "for", "(", "SubTask", "task", ":", "tasks", ")", "jp", ".", "addToJoinDoNotCancel", "(", "task", ".", "getProgress", "(", ")", ".", "getSynch", "(", ")", ")", ";", "}", "jp", ".", "listenInline", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "jp", ".", "hasError", "(", ")", ")", "error", "(", "jp", ".", "getError", "(", ")", ")", ";", "else", "done", "(", ")", ";", "}", "}", ")", ";", "jp", ".", "start", "(", ")", ";", "}" ]
Automatically call the done or error method of this WorkProgress once all current sub-tasks are done.
[ "Automatically", "call", "the", "done", "or", "error", "method", "of", "this", "WorkProgress", "once", "all", "current", "sub", "-", "tasks", "are", "done", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/progress/MultiTaskProgress.java#L60-L74
150,986
rwl/CSparseJ
src/main/java/edu/emory/mathcs/csparsej/tdouble/Dcs_tdfs.java
Dcs_tdfs.cs_tdfs
public static int cs_tdfs(int j, int k, int[] head, int head_offset, int[] next, int next_offset, int[] post, int post_offset, int[] stack, int stack_offset) { int i, p, top = 0; if (head == null || next == null || post == null || stack == null) return (-1); /* check inputs */ stack[stack_offset + 0] = j; /* place j on the stack */ while (top >= 0) /* while (stack is not empty) */ { p = stack[stack_offset + top]; /* p = top of stack */ i = head[head_offset + p]; /* i = youngest child of p */ if (i == -1) { top--; /* p has no unordered children left */ post[post_offset + (k++)] = p; /* node p is the kth postordered node */ } else { head[head_offset + p] = next[next_offset + i]; /* remove i from children of p */ stack[stack_offset + (++top)] = i; /* start dfs on child node i */ } } return (k); }
java
public static int cs_tdfs(int j, int k, int[] head, int head_offset, int[] next, int next_offset, int[] post, int post_offset, int[] stack, int stack_offset) { int i, p, top = 0; if (head == null || next == null || post == null || stack == null) return (-1); /* check inputs */ stack[stack_offset + 0] = j; /* place j on the stack */ while (top >= 0) /* while (stack is not empty) */ { p = stack[stack_offset + top]; /* p = top of stack */ i = head[head_offset + p]; /* i = youngest child of p */ if (i == -1) { top--; /* p has no unordered children left */ post[post_offset + (k++)] = p; /* node p is the kth postordered node */ } else { head[head_offset + p] = next[next_offset + i]; /* remove i from children of p */ stack[stack_offset + (++top)] = i; /* start dfs on child node i */ } } return (k); }
[ "public", "static", "int", "cs_tdfs", "(", "int", "j", ",", "int", "k", ",", "int", "[", "]", "head", ",", "int", "head_offset", ",", "int", "[", "]", "next", ",", "int", "next_offset", ",", "int", "[", "]", "post", ",", "int", "post_offset", ",", "int", "[", "]", "stack", ",", "int", "stack_offset", ")", "{", "int", "i", ",", "p", ",", "top", "=", "0", ";", "if", "(", "head", "==", "null", "||", "next", "==", "null", "||", "post", "==", "null", "||", "stack", "==", "null", ")", "return", "(", "-", "1", ")", ";", "/* check inputs */", "stack", "[", "stack_offset", "+", "0", "]", "=", "j", ";", "/* place j on the stack */", "while", "(", "top", ">=", "0", ")", "/* while (stack is not empty) */", "{", "p", "=", "stack", "[", "stack_offset", "+", "top", "]", ";", "/* p = top of stack */", "i", "=", "head", "[", "head_offset", "+", "p", "]", ";", "/* i = youngest child of p */", "if", "(", "i", "==", "-", "1", ")", "{", "top", "--", ";", "/* p has no unordered children left */", "post", "[", "post_offset", "+", "(", "k", "++", ")", "]", "=", "p", ";", "/* node p is the kth postordered node */", "}", "else", "{", "head", "[", "head_offset", "+", "p", "]", "=", "next", "[", "next_offset", "+", "i", "]", ";", "/* remove i from children of p */", "stack", "[", "stack_offset", "+", "(", "++", "top", ")", "]", "=", "i", ";", "/* start dfs on child node i */", "}", "}", "return", "(", "k", ")", ";", "}" ]
Depth-first search and postorder of a tree rooted at node j @param j postorder of a tree rooted at node j @param k number of nodes ordered so far @param head head[i] is first child of node i; -1 on output @param head_offset the index of the first element in array head @param next next[i] is next sibling of i or -1 if none @param next_offset the index of the first element in array next @param post postordering @param post_offset the index of the first element in array post @param stack size n, work array @param stack_offset the index of the first element in array stack @return new value of k, -1 on error
[ "Depth", "-", "first", "search", "and", "postorder", "of", "a", "tree", "rooted", "at", "node", "j" ]
6a6f66bccce1558156a961494358952603b0ac84
https://github.com/rwl/CSparseJ/blob/6a6f66bccce1558156a961494358952603b0ac84/src/main/java/edu/emory/mathcs/csparsej/tdouble/Dcs_tdfs.java#L60-L79
150,987
GerdHolz/TOVAL
src/de/invation/code/toval/os/OSUtils.java
OSUtils.getExecutionPath
public static File getExecutionPath() throws OSException { try { return new File(OSUtils.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()); } catch (URISyntaxException ex) { throw new OSException(ex); } }
java
public static File getExecutionPath() throws OSException { try { return new File(OSUtils.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()); } catch (URISyntaxException ex) { throw new OSException(ex); } }
[ "public", "static", "File", "getExecutionPath", "(", ")", "throws", "OSException", "{", "try", "{", "return", "new", "File", "(", "OSUtils", ".", "class", ".", "getProtectionDomain", "(", ")", ".", "getCodeSource", "(", ")", ".", "getLocation", "(", ")", ".", "toURI", "(", ")", ".", "getPath", "(", ")", ")", ";", "}", "catch", "(", "URISyntaxException", "ex", ")", "{", "throw", "new", "OSException", "(", "ex", ")", ";", "}", "}" ]
Returns the execution path to the direcory of the current Java application. @return Execution path as {@link File}. @throws OSException If the execution path can't be determined.
[ "Returns", "the", "execution", "path", "to", "the", "direcory", "of", "the", "current", "Java", "application", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/os/OSUtils.java#L65-L71
150,988
GerdHolz/TOVAL
src/de/invation/code/toval/os/OSUtils.java
OSUtils.runCommand
public void runCommand(String[] command, GenericHandler<BufferedReader> inputHandler, GenericHandler<BufferedReader> errorHandler) throws OSException { Validate.notNull(command); try { Process p = Runtime.getRuntime().exec(command); BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream())); if (inputHandler != null) { inputHandler.handle(in); } if (errorHandler != null) { errorHandler.handle(err); } in.close(); p.waitFor(); p.exitValue(); } catch (Exception ex) { throw new OSException(ex.getMessage(), ex); } }
java
public void runCommand(String[] command, GenericHandler<BufferedReader> inputHandler, GenericHandler<BufferedReader> errorHandler) throws OSException { Validate.notNull(command); try { Process p = Runtime.getRuntime().exec(command); BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream())); if (inputHandler != null) { inputHandler.handle(in); } if (errorHandler != null) { errorHandler.handle(err); } in.close(); p.waitFor(); p.exitValue(); } catch (Exception ex) { throw new OSException(ex.getMessage(), ex); } }
[ "public", "void", "runCommand", "(", "String", "[", "]", "command", ",", "GenericHandler", "<", "BufferedReader", ">", "inputHandler", ",", "GenericHandler", "<", "BufferedReader", ">", "errorHandler", ")", "throws", "OSException", "{", "Validate", ".", "notNull", "(", "command", ")", ";", "try", "{", "Process", "p", "=", "Runtime", ".", "getRuntime", "(", ")", ".", "exec", "(", "command", ")", ";", "BufferedReader", "in", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "p", ".", "getInputStream", "(", ")", ")", ")", ";", "BufferedReader", "err", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "p", ".", "getErrorStream", "(", ")", ")", ")", ";", "if", "(", "inputHandler", "!=", "null", ")", "{", "inputHandler", ".", "handle", "(", "in", ")", ";", "}", "if", "(", "errorHandler", "!=", "null", ")", "{", "errorHandler", ".", "handle", "(", "err", ")", ";", "}", "in", ".", "close", "(", ")", ";", "p", ".", "waitFor", "(", ")", ";", "p", ".", "exitValue", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "OSException", "(", "ex", ".", "getMessage", "(", ")", ",", "ex", ")", ";", "}", "}" ]
Runs a command on the operating system. @param command String array of command parts. The parts are concatenated with spaces between the parts. The single command parts should not contain whitespaces. @param inputHandler {@link GenericHandler} to handle the process input stream {@link BufferedReader}. @param errorHandler {@link GenericHandler} to handle the process error output {@link BufferedReader}. @throws OSException
[ "Runs", "a", "command", "on", "the", "operating", "system", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/os/OSUtils.java#L170-L191
150,989
GerdHolz/TOVAL
src/de/invation/code/toval/os/OSUtils.java
OSUtils.sanitizeFileExtension
protected static String sanitizeFileExtension(String fileTypeExtension) throws OSException { // Remove whitespaces String newFileTypeExtension = fileTypeExtension.replaceAll("\\s+", ""); // to lower case newFileTypeExtension = newFileTypeExtension.toLowerCase(); /* * Check if name contains multiple dots and if so, just take the last * part. Also adds a dot before last part. */ String[] splittedFileExtension = newFileTypeExtension.split("\\."); if (newFileTypeExtension.length() == 0 || splittedFileExtension.length == 0) { throw new OSException("The given file extension \"" + fileTypeExtension + "\" is too short."); } newFileTypeExtension = "." + splittedFileExtension[splittedFileExtension.length - 1]; return newFileTypeExtension; }
java
protected static String sanitizeFileExtension(String fileTypeExtension) throws OSException { // Remove whitespaces String newFileTypeExtension = fileTypeExtension.replaceAll("\\s+", ""); // to lower case newFileTypeExtension = newFileTypeExtension.toLowerCase(); /* * Check if name contains multiple dots and if so, just take the last * part. Also adds a dot before last part. */ String[] splittedFileExtension = newFileTypeExtension.split("\\."); if (newFileTypeExtension.length() == 0 || splittedFileExtension.length == 0) { throw new OSException("The given file extension \"" + fileTypeExtension + "\" is too short."); } newFileTypeExtension = "." + splittedFileExtension[splittedFileExtension.length - 1]; return newFileTypeExtension; }
[ "protected", "static", "String", "sanitizeFileExtension", "(", "String", "fileTypeExtension", ")", "throws", "OSException", "{", "// Remove whitespaces", "String", "newFileTypeExtension", "=", "fileTypeExtension", ".", "replaceAll", "(", "\"\\\\s+\"", ",", "\"\"", ")", ";", "// to lower case", "newFileTypeExtension", "=", "newFileTypeExtension", ".", "toLowerCase", "(", ")", ";", "/*\n * Check if name contains multiple dots and if so, just take the last\n * part. Also adds a dot before last part.\n */", "String", "[", "]", "splittedFileExtension", "=", "newFileTypeExtension", ".", "split", "(", "\"\\\\.\"", ")", ";", "if", "(", "newFileTypeExtension", ".", "length", "(", ")", "==", "0", "||", "splittedFileExtension", ".", "length", "==", "0", ")", "{", "throw", "new", "OSException", "(", "\"The given file extension \\\"\"", "+", "fileTypeExtension", "+", "\"\\\" is too short.\"", ")", ";", "}", "newFileTypeExtension", "=", "\".\"", "+", "splittedFileExtension", "[", "splittedFileExtension", ".", "length", "-", "1", "]", ";", "return", "newFileTypeExtension", ";", "}" ]
Sanitizes file extension such that it can be used in the Windows Registry. @param fileTypeExtension Extension to sanitize @return Sanitized file extension @throws OSException If the file extension is malformed
[ "Sanitizes", "file", "extension", "such", "that", "it", "can", "be", "used", "in", "the", "Windows", "Registry", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/os/OSUtils.java#L201-L219
150,990
hawkular/hawkular-inventory
hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/Configuration.java
Configuration.getProperty
public String getProperty(Property property, String defaultValue) { String value = null; List<String> systemProps = property.getSystemPropertyNames(); if (systemProps != null) { for (String sp : systemProps) { value = System.getProperty(sp); if (value != null) { break; } } } if (value == null) { List<String> envVars = property.getEnvironmentVariableNames(); if (envVars != null) { for (String ev : envVars) { value = System.getenv(ev); if (value != null) { break; } } } } if (value == null && property.getPropertyName() != null) { value = implementationConfiguration.get(property.getPropertyName()); } return value == null ? defaultValue : value; }
java
public String getProperty(Property property, String defaultValue) { String value = null; List<String> systemProps = property.getSystemPropertyNames(); if (systemProps != null) { for (String sp : systemProps) { value = System.getProperty(sp); if (value != null) { break; } } } if (value == null) { List<String> envVars = property.getEnvironmentVariableNames(); if (envVars != null) { for (String ev : envVars) { value = System.getenv(ev); if (value != null) { break; } } } } if (value == null && property.getPropertyName() != null) { value = implementationConfiguration.get(property.getPropertyName()); } return value == null ? defaultValue : value; }
[ "public", "String", "getProperty", "(", "Property", "property", ",", "String", "defaultValue", ")", "{", "String", "value", "=", "null", ";", "List", "<", "String", ">", "systemProps", "=", "property", ".", "getSystemPropertyNames", "(", ")", ";", "if", "(", "systemProps", "!=", "null", ")", "{", "for", "(", "String", "sp", ":", "systemProps", ")", "{", "value", "=", "System", ".", "getProperty", "(", "sp", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "break", ";", "}", "}", "}", "if", "(", "value", "==", "null", ")", "{", "List", "<", "String", ">", "envVars", "=", "property", ".", "getEnvironmentVariableNames", "(", ")", ";", "if", "(", "envVars", "!=", "null", ")", "{", "for", "(", "String", "ev", ":", "envVars", ")", "{", "value", "=", "System", ".", "getenv", "(", "ev", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "break", ";", "}", "}", "}", "}", "if", "(", "value", "==", "null", "&&", "property", ".", "getPropertyName", "(", ")", "!=", "null", ")", "{", "value", "=", "implementationConfiguration", ".", "get", "(", "property", ".", "getPropertyName", "(", ")", ")", ";", "}", "return", "value", "==", "null", "?", "defaultValue", ":", "value", ";", "}" ]
Returns the value of the property. <p>If there is a system property with the name from {@link Property#getSystemPropertyNames()} ()}, then its value is returned, otherwise if the property defines an environment variable and that env variable exists, then its value is returned otherwise the value of a property with a name from {@link Property#getPropertyName()} from the values loaded using {@link Builder#withConfiguration(Map)} or {@link Builder#withConfiguration(Properties)} is returned. @param property the property to obtain @return the value or null if none found
[ "Returns", "the", "value", "of", "the", "property", "." ]
f56dc10323dca21777feb5b609a9e9cc70ffaf62
https://github.com/hawkular/hawkular-inventory/blob/f56dc10323dca21777feb5b609a9e9cc70ffaf62/hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/Configuration.java#L73-L105
150,991
hawkular/hawkular-inventory
hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/Configuration.java
Configuration.prefixedWith
public Configuration prefixedWith(String... prefixes) { if (prefixes == null || prefixes.length == 0) { return this; } Map<String, String> filteredConfig = implementationConfiguration.entrySet().stream() .filter(e -> Arrays.stream(prefixes).anyMatch(p -> e.getKey() .startsWith(p))).collect(toMap(Map.Entry::getKey, Map.Entry::getValue)); return new Configuration(feedIdStrategy, resultFilter, filteredConfig); }
java
public Configuration prefixedWith(String... prefixes) { if (prefixes == null || prefixes.length == 0) { return this; } Map<String, String> filteredConfig = implementationConfiguration.entrySet().stream() .filter(e -> Arrays.stream(prefixes).anyMatch(p -> e.getKey() .startsWith(p))).collect(toMap(Map.Entry::getKey, Map.Entry::getValue)); return new Configuration(feedIdStrategy, resultFilter, filteredConfig); }
[ "public", "Configuration", "prefixedWith", "(", "String", "...", "prefixes", ")", "{", "if", "(", "prefixes", "==", "null", "||", "prefixes", ".", "length", "==", "0", ")", "{", "return", "this", ";", "}", "Map", "<", "String", ",", "String", ">", "filteredConfig", "=", "implementationConfiguration", ".", "entrySet", "(", ")", ".", "stream", "(", ")", ".", "filter", "(", "e", "->", "Arrays", ".", "stream", "(", "prefixes", ")", ".", "anyMatch", "(", "p", "->", "e", ".", "getKey", "(", ")", ".", "startsWith", "(", "p", ")", ")", ")", ".", "collect", "(", "toMap", "(", "Map", ".", "Entry", "::", "getKey", ",", "Map", ".", "Entry", "::", "getValue", ")", ")", ";", "return", "new", "Configuration", "(", "feedIdStrategy", ",", "resultFilter", ",", "filteredConfig", ")", ";", "}" ]
Filters out all the configuration entries whose keys don't start with any of the white-listed prefixes @param prefixes @return
[ "Filters", "out", "all", "the", "configuration", "entries", "whose", "keys", "don", "t", "start", "with", "any", "of", "the", "white", "-", "listed", "prefixes" ]
f56dc10323dca21777feb5b609a9e9cc70ffaf62
https://github.com/hawkular/hawkular-inventory/blob/f56dc10323dca21777feb5b609a9e9cc70ffaf62/hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/Configuration.java#L121-L129
150,992
hawkular/hawkular-inventory
hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/Configuration.java
Configuration.getOverriddenImplementationConfiguration
private <T extends Property> Map<String, String> getOverriddenImplementationConfiguration( Collection<T> overridableProperties) { Map<String, String> ret = new HashMap<>(); overridableProperties.forEach(p -> { String val = getProperty(p, null); if (val != null) { ret.put(p.getPropertyName(), val); } }); implementationConfiguration.forEach(ret::putIfAbsent); return ret; }
java
private <T extends Property> Map<String, String> getOverriddenImplementationConfiguration( Collection<T> overridableProperties) { Map<String, String> ret = new HashMap<>(); overridableProperties.forEach(p -> { String val = getProperty(p, null); if (val != null) { ret.put(p.getPropertyName(), val); } }); implementationConfiguration.forEach(ret::putIfAbsent); return ret; }
[ "private", "<", "T", "extends", "Property", ">", "Map", "<", "String", ",", "String", ">", "getOverriddenImplementationConfiguration", "(", "Collection", "<", "T", ">", "overridableProperties", ")", "{", "Map", "<", "String", ",", "String", ">", "ret", "=", "new", "HashMap", "<>", "(", ")", ";", "overridableProperties", ".", "forEach", "(", "p", "->", "{", "String", "val", "=", "getProperty", "(", "p", ",", "null", ")", ";", "if", "(", "val", "!=", "null", ")", "{", "ret", ".", "put", "(", "p", ".", "getPropertyName", "(", ")", ",", "val", ")", ";", "}", "}", ")", ";", "implementationConfiguration", ".", "forEach", "(", "ret", "::", "putIfAbsent", ")", ";", "return", "ret", ";", "}" ]
this hoop is needed so that we can type-check the "T" through the stream manipulations
[ "this", "hoop", "is", "needed", "so", "that", "we", "can", "type", "-", "check", "the", "T", "through", "the", "stream", "manipulations" ]
f56dc10323dca21777feb5b609a9e9cc70ffaf62
https://github.com/hawkular/hawkular-inventory/blob/f56dc10323dca21777feb5b609a9e9cc70ffaf62/hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/Configuration.java#L150-L165
150,993
jtgeiger/iptools
src/main/java/com/sibilantsolutions/iptools/util/CertDuplicator.java
CertDuplicator.duplicate
static public X509Certificate duplicate( X509Certificate cert ) { //log.info( "Duplicating cert={}.", cert ); X500Principal prince = cert.getSubjectX500Principal(); log.info( "Principal={}.", prince.getName() ); KeyPairGenerator kpg; try { kpg = KeyPairGenerator.getInstance( "RSA" ); } catch ( NoSuchAlgorithmException e1 ) { // TODO Auto-generated catch block throw new UnsupportedOperationException( "OGTE TODO!", e1 ); } KeyPair keyPair = kpg.generateKeyPair(); AlgorithmId alg; try { alg = new AlgorithmId( new ObjectIdentifier( cert.getSigAlgOID() ) ); } catch ( IOException e1 ) { // TODO Auto-generated catch block throw new UnsupportedOperationException( "OGTE TODO!", e1 ); } X509CertInfo info = new X509CertInfo(); try { info.set( X509CertInfo.SUBJECT, new CertificateSubjectName( new X500Name( prince.getName() ) ) ); info.set( X509CertInfo.KEY, new CertificateX509Key( keyPair.getPublic() ) ); info.set( X509CertInfo.VALIDITY, new CertificateValidity( cert.getNotBefore(), cert.getNotAfter() ) ); info.set( X509CertInfo.ISSUER, new CertificateIssuerName( new X500Name( prince.getName() ) ) ); info.set( X509CertInfo.ALGORITHM_ID, new CertificateAlgorithmId( alg ) ); info.set( X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber( cert.getSerialNumber() ) ); info.set( X509CertInfo.VERSION, new CertificateVersion( cert.getVersion() - 1 ) ); //info.set( x509CertInfo.EXTENSIONS, cert.get) } catch ( CertificateException | IOException e ) { // TODO Auto-generated catch block throw new UnsupportedOperationException( "OGTE TODO!", e ); } log.info( "Cert info={}.", info ); X509CertImpl newCert = new X509CertImpl( info ); try { newCert.sign( keyPair.getPrivate(), alg.getName() ); } catch ( InvalidKeyException | CertificateException | NoSuchAlgorithmException | NoSuchProviderException | SignatureException e ) { // TODO Auto-generated catch block throw new UnsupportedOperationException( "OGTE TODO!", e ); } log.info( "Returning new cert={}.", newCert ); return newCert; }
java
static public X509Certificate duplicate( X509Certificate cert ) { //log.info( "Duplicating cert={}.", cert ); X500Principal prince = cert.getSubjectX500Principal(); log.info( "Principal={}.", prince.getName() ); KeyPairGenerator kpg; try { kpg = KeyPairGenerator.getInstance( "RSA" ); } catch ( NoSuchAlgorithmException e1 ) { // TODO Auto-generated catch block throw new UnsupportedOperationException( "OGTE TODO!", e1 ); } KeyPair keyPair = kpg.generateKeyPair(); AlgorithmId alg; try { alg = new AlgorithmId( new ObjectIdentifier( cert.getSigAlgOID() ) ); } catch ( IOException e1 ) { // TODO Auto-generated catch block throw new UnsupportedOperationException( "OGTE TODO!", e1 ); } X509CertInfo info = new X509CertInfo(); try { info.set( X509CertInfo.SUBJECT, new CertificateSubjectName( new X500Name( prince.getName() ) ) ); info.set( X509CertInfo.KEY, new CertificateX509Key( keyPair.getPublic() ) ); info.set( X509CertInfo.VALIDITY, new CertificateValidity( cert.getNotBefore(), cert.getNotAfter() ) ); info.set( X509CertInfo.ISSUER, new CertificateIssuerName( new X500Name( prince.getName() ) ) ); info.set( X509CertInfo.ALGORITHM_ID, new CertificateAlgorithmId( alg ) ); info.set( X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber( cert.getSerialNumber() ) ); info.set( X509CertInfo.VERSION, new CertificateVersion( cert.getVersion() - 1 ) ); //info.set( x509CertInfo.EXTENSIONS, cert.get) } catch ( CertificateException | IOException e ) { // TODO Auto-generated catch block throw new UnsupportedOperationException( "OGTE TODO!", e ); } log.info( "Cert info={}.", info ); X509CertImpl newCert = new X509CertImpl( info ); try { newCert.sign( keyPair.getPrivate(), alg.getName() ); } catch ( InvalidKeyException | CertificateException | NoSuchAlgorithmException | NoSuchProviderException | SignatureException e ) { // TODO Auto-generated catch block throw new UnsupportedOperationException( "OGTE TODO!", e ); } log.info( "Returning new cert={}.", newCert ); return newCert; }
[ "static", "public", "X509Certificate", "duplicate", "(", "X509Certificate", "cert", ")", "{", "//log.info( \"Duplicating cert={}.\", cert );", "X500Principal", "prince", "=", "cert", ".", "getSubjectX500Principal", "(", ")", ";", "log", ".", "info", "(", "\"Principal={}.\"", ",", "prince", ".", "getName", "(", ")", ")", ";", "KeyPairGenerator", "kpg", ";", "try", "{", "kpg", "=", "KeyPairGenerator", ".", "getInstance", "(", "\"RSA\"", ")", ";", "}", "catch", "(", "NoSuchAlgorithmException", "e1", ")", "{", "// TODO Auto-generated catch block", "throw", "new", "UnsupportedOperationException", "(", "\"OGTE TODO!\"", ",", "e1", ")", ";", "}", "KeyPair", "keyPair", "=", "kpg", ".", "generateKeyPair", "(", ")", ";", "AlgorithmId", "alg", ";", "try", "{", "alg", "=", "new", "AlgorithmId", "(", "new", "ObjectIdentifier", "(", "cert", ".", "getSigAlgOID", "(", ")", ")", ")", ";", "}", "catch", "(", "IOException", "e1", ")", "{", "// TODO Auto-generated catch block", "throw", "new", "UnsupportedOperationException", "(", "\"OGTE TODO!\"", ",", "e1", ")", ";", "}", "X509CertInfo", "info", "=", "new", "X509CertInfo", "(", ")", ";", "try", "{", "info", ".", "set", "(", "X509CertInfo", ".", "SUBJECT", ",", "new", "CertificateSubjectName", "(", "new", "X500Name", "(", "prince", ".", "getName", "(", ")", ")", ")", ")", ";", "info", ".", "set", "(", "X509CertInfo", ".", "KEY", ",", "new", "CertificateX509Key", "(", "keyPair", ".", "getPublic", "(", ")", ")", ")", ";", "info", ".", "set", "(", "X509CertInfo", ".", "VALIDITY", ",", "new", "CertificateValidity", "(", "cert", ".", "getNotBefore", "(", ")", ",", "cert", ".", "getNotAfter", "(", ")", ")", ")", ";", "info", ".", "set", "(", "X509CertInfo", ".", "ISSUER", ",", "new", "CertificateIssuerName", "(", "new", "X500Name", "(", "prince", ".", "getName", "(", ")", ")", ")", ")", ";", "info", ".", "set", "(", "X509CertInfo", ".", "ALGORITHM_ID", ",", "new", "CertificateAlgorithmId", "(", "alg", ")", ")", ";", "info", ".", "set", "(", "X509CertInfo", ".", "SERIAL_NUMBER", ",", "new", "CertificateSerialNumber", "(", "cert", ".", "getSerialNumber", "(", ")", ")", ")", ";", "info", ".", "set", "(", "X509CertInfo", ".", "VERSION", ",", "new", "CertificateVersion", "(", "cert", ".", "getVersion", "(", ")", "-", "1", ")", ")", ";", "//info.set( x509CertInfo.EXTENSIONS, cert.get)", "}", "catch", "(", "CertificateException", "|", "IOException", "e", ")", "{", "// TODO Auto-generated catch block", "throw", "new", "UnsupportedOperationException", "(", "\"OGTE TODO!\"", ",", "e", ")", ";", "}", "log", ".", "info", "(", "\"Cert info={}.\"", ",", "info", ")", ";", "X509CertImpl", "newCert", "=", "new", "X509CertImpl", "(", "info", ")", ";", "try", "{", "newCert", ".", "sign", "(", "keyPair", ".", "getPrivate", "(", ")", ",", "alg", ".", "getName", "(", ")", ")", ";", "}", "catch", "(", "InvalidKeyException", "|", "CertificateException", "|", "NoSuchAlgorithmException", "|", "NoSuchProviderException", "|", "SignatureException", "e", ")", "{", "// TODO Auto-generated catch block", "throw", "new", "UnsupportedOperationException", "(", "\"OGTE TODO!\"", ",", "e", ")", ";", "}", "log", ".", "info", "(", "\"Returning new cert={}.\"", ",", "newCert", ")", ";", "return", "newCert", ";", "}" ]
Create a self-signed certificate that duplicates as many of the given cert's fields as possible. @param cert Source certificate @return A self-signed X509Certificate certificate, not null
[ "Create", "a", "self", "-", "signed", "certificate", "that", "duplicates", "as", "many", "of", "the", "given", "cert", "s", "fields", "as", "possible", "." ]
45059bdae220c273e40765438ff811691a34f976
https://github.com/jtgeiger/iptools/blob/45059bdae220c273e40765438ff811691a34f976/src/main/java/com/sibilantsolutions/iptools/util/CertDuplicator.java#L45-L116
150,994
jtrfp/javamod
src/main/java/de/quippy/javamod/multimedia/mod/mixer/interpolation/CubicSpline.java
CubicSpline.initialize
private static void initialize() { double lFlen = 1.0f / (double)SPLINE_LUTLEN; double lScale = (double)SPLINE_QUANTSCALE; for(int i=0; i<SPLINE_LUTLEN; i++) { double lX = ((double)i)*lFlen; int lIdx = i<<2; double lCm1 = Math.floor(0.5 + lScale * (-0.5*lX*lX*lX + 1.0 * lX*lX - 0.5 * lX )); double lC0 = Math.floor(0.5 + lScale * ( 1.5*lX*lX*lX - 2.5 * lX*lX + 1.0)); double lC1 = Math.floor(0.5 + lScale * (-1.5*lX*lX*lX + 2.0 * lX*lX + 0.5 * lX )); double lC2 = Math.floor(0.5 + lScale * ( 0.5*lX*lX*lX - 0.5 * lX*lX )); lut[lIdx+0] = (int)((lCm1 < -lScale) ? -lScale : ((lCm1 > lScale) ? lScale : lCm1)); lut[lIdx+1] = (int)((lC0 < -lScale) ? -lScale : ((lC0 > lScale) ? lScale : lC0 )); lut[lIdx+2] = (int)((lC1 < -lScale) ? -lScale : ((lC1 > lScale) ? lScale : lC1 )); lut[lIdx+3] = (int)((lC2 < -lScale) ? -lScale : ((lC2 > lScale) ? lScale : lC2 )); // forces coefs-set to unity gain: int lSum = lut[lIdx+0] + lut[lIdx+1] + lut[lIdx+2] + lut[lIdx+3]; if (lSum != SPLINE_QUANTSCALE) { int lMax = lIdx; if (lut[lIdx+1] > lut[lMax]) lMax = lIdx+1; if (lut[lIdx+2] > lut[lMax]) lMax = lIdx+2; if (lut[lIdx+3] > lut[lMax]) lMax = lIdx+3; lut[lMax] += (SPLINE_QUANTSCALE-lSum); } } }
java
private static void initialize() { double lFlen = 1.0f / (double)SPLINE_LUTLEN; double lScale = (double)SPLINE_QUANTSCALE; for(int i=0; i<SPLINE_LUTLEN; i++) { double lX = ((double)i)*lFlen; int lIdx = i<<2; double lCm1 = Math.floor(0.5 + lScale * (-0.5*lX*lX*lX + 1.0 * lX*lX - 0.5 * lX )); double lC0 = Math.floor(0.5 + lScale * ( 1.5*lX*lX*lX - 2.5 * lX*lX + 1.0)); double lC1 = Math.floor(0.5 + lScale * (-1.5*lX*lX*lX + 2.0 * lX*lX + 0.5 * lX )); double lC2 = Math.floor(0.5 + lScale * ( 0.5*lX*lX*lX - 0.5 * lX*lX )); lut[lIdx+0] = (int)((lCm1 < -lScale) ? -lScale : ((lCm1 > lScale) ? lScale : lCm1)); lut[lIdx+1] = (int)((lC0 < -lScale) ? -lScale : ((lC0 > lScale) ? lScale : lC0 )); lut[lIdx+2] = (int)((lC1 < -lScale) ? -lScale : ((lC1 > lScale) ? lScale : lC1 )); lut[lIdx+3] = (int)((lC2 < -lScale) ? -lScale : ((lC2 > lScale) ? lScale : lC2 )); // forces coefs-set to unity gain: int lSum = lut[lIdx+0] + lut[lIdx+1] + lut[lIdx+2] + lut[lIdx+3]; if (lSum != SPLINE_QUANTSCALE) { int lMax = lIdx; if (lut[lIdx+1] > lut[lMax]) lMax = lIdx+1; if (lut[lIdx+2] > lut[lMax]) lMax = lIdx+2; if (lut[lIdx+3] > lut[lMax]) lMax = lIdx+3; lut[lMax] += (SPLINE_QUANTSCALE-lSum); } } }
[ "private", "static", "void", "initialize", "(", ")", "{", "double", "lFlen", "=", "1.0f", "/", "(", "double", ")", "SPLINE_LUTLEN", ";", "double", "lScale", "=", "(", "double", ")", "SPLINE_QUANTSCALE", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "SPLINE_LUTLEN", ";", "i", "++", ")", "{", "double", "lX", "=", "(", "(", "double", ")", "i", ")", "*", "lFlen", ";", "int", "lIdx", "=", "i", "<<", "2", ";", "double", "lCm1", "=", "Math", ".", "floor", "(", "0.5", "+", "lScale", "*", "(", "-", "0.5", "*", "lX", "*", "lX", "*", "lX", "+", "1.0", "*", "lX", "*", "lX", "-", "0.5", "*", "lX", ")", ")", ";", "double", "lC0", "=", "Math", ".", "floor", "(", "0.5", "+", "lScale", "*", "(", "1.5", "*", "lX", "*", "lX", "*", "lX", "-", "2.5", "*", "lX", "*", "lX", "+", "1.0", ")", ")", ";", "double", "lC1", "=", "Math", ".", "floor", "(", "0.5", "+", "lScale", "*", "(", "-", "1.5", "*", "lX", "*", "lX", "*", "lX", "+", "2.0", "*", "lX", "*", "lX", "+", "0.5", "*", "lX", ")", ")", ";", "double", "lC2", "=", "Math", ".", "floor", "(", "0.5", "+", "lScale", "*", "(", "0.5", "*", "lX", "*", "lX", "*", "lX", "-", "0.5", "*", "lX", "*", "lX", ")", ")", ";", "lut", "[", "lIdx", "+", "0", "]", "=", "(", "int", ")", "(", "(", "lCm1", "<", "-", "lScale", ")", "?", "-", "lScale", ":", "(", "(", "lCm1", ">", "lScale", ")", "?", "lScale", ":", "lCm1", ")", ")", ";", "lut", "[", "lIdx", "+", "1", "]", "=", "(", "int", ")", "(", "(", "lC0", "<", "-", "lScale", ")", "?", "-", "lScale", ":", "(", "(", "lC0", ">", "lScale", ")", "?", "lScale", ":", "lC0", ")", ")", ";", "lut", "[", "lIdx", "+", "2", "]", "=", "(", "int", ")", "(", "(", "lC1", "<", "-", "lScale", ")", "?", "-", "lScale", ":", "(", "(", "lC1", ">", "lScale", ")", "?", "lScale", ":", "lC1", ")", ")", ";", "lut", "[", "lIdx", "+", "3", "]", "=", "(", "int", ")", "(", "(", "lC2", "<", "-", "lScale", ")", "?", "-", "lScale", ":", "(", "(", "lC2", ">", "lScale", ")", "?", "lScale", ":", "lC2", ")", ")", ";", "// forces coefs-set to unity gain:", "int", "lSum", "=", "lut", "[", "lIdx", "+", "0", "]", "+", "lut", "[", "lIdx", "+", "1", "]", "+", "lut", "[", "lIdx", "+", "2", "]", "+", "lut", "[", "lIdx", "+", "3", "]", ";", "if", "(", "lSum", "!=", "SPLINE_QUANTSCALE", ")", "{", "int", "lMax", "=", "lIdx", ";", "if", "(", "lut", "[", "lIdx", "+", "1", "]", ">", "lut", "[", "lMax", "]", ")", "lMax", "=", "lIdx", "+", "1", ";", "if", "(", "lut", "[", "lIdx", "+", "2", "]", ">", "lut", "[", "lMax", "]", ")", "lMax", "=", "lIdx", "+", "2", ";", "if", "(", "lut", "[", "lIdx", "+", "3", "]", ">", "lut", "[", "lMax", "]", ")", "lMax", "=", "lIdx", "+", "3", ";", "lut", "[", "lMax", "]", "+=", "(", "SPLINE_QUANTSCALE", "-", "lSum", ")", ";", "}", "}", "}" ]
Init the static params @since 15.06.2006
[ "Init", "the", "static", "params" ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/javamod/multimedia/mod/mixer/interpolation/CubicSpline.java#L103-L132
150,995
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/memory/ByteArrayCache.java
ByteArrayCache.free
public void free(byte[] array) { int len = array.length; synchronized (arraysBySize) { if (totalSize + len > maxTotalSize) return; Node<ArraysBySize> node = arraysBySize.get(len); if (node == null) { ArraysBySize arrays = new ArraysBySize(); arrays.arrays = new TurnArray<>( len >= 128 * 1024 ? maxBuffersBySizeAbove128KB : maxBuffersBySizeUnder128KB); arrays.arrays.add(array); arrays.lastCachedTime = System.currentTimeMillis(); arraysBySize.add(len, arrays); totalSize += len; return; } ArraysBySize arrays = node.getElement(); arrays.lastCachedTime = System.currentTimeMillis(); if (arrays.arrays.isFull()) return; totalSize += len; arrays.arrays.add(array); } }
java
public void free(byte[] array) { int len = array.length; synchronized (arraysBySize) { if (totalSize + len > maxTotalSize) return; Node<ArraysBySize> node = arraysBySize.get(len); if (node == null) { ArraysBySize arrays = new ArraysBySize(); arrays.arrays = new TurnArray<>( len >= 128 * 1024 ? maxBuffersBySizeAbove128KB : maxBuffersBySizeUnder128KB); arrays.arrays.add(array); arrays.lastCachedTime = System.currentTimeMillis(); arraysBySize.add(len, arrays); totalSize += len; return; } ArraysBySize arrays = node.getElement(); arrays.lastCachedTime = System.currentTimeMillis(); if (arrays.arrays.isFull()) return; totalSize += len; arrays.arrays.add(array); } }
[ "public", "void", "free", "(", "byte", "[", "]", "array", ")", "{", "int", "len", "=", "array", ".", "length", ";", "synchronized", "(", "arraysBySize", ")", "{", "if", "(", "totalSize", "+", "len", ">", "maxTotalSize", ")", "return", ";", "Node", "<", "ArraysBySize", ">", "node", "=", "arraysBySize", ".", "get", "(", "len", ")", ";", "if", "(", "node", "==", "null", ")", "{", "ArraysBySize", "arrays", "=", "new", "ArraysBySize", "(", ")", ";", "arrays", ".", "arrays", "=", "new", "TurnArray", "<>", "(", "len", ">=", "128", "*", "1024", "?", "maxBuffersBySizeAbove128KB", ":", "maxBuffersBySizeUnder128KB", ")", ";", "arrays", ".", "arrays", ".", "add", "(", "array", ")", ";", "arrays", ".", "lastCachedTime", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "arraysBySize", ".", "add", "(", "len", ",", "arrays", ")", ";", "totalSize", "+=", "len", ";", "return", ";", "}", "ArraysBySize", "arrays", "=", "node", ".", "getElement", "(", ")", ";", "arrays", ".", "lastCachedTime", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "if", "(", "arrays", ".", "arrays", ".", "isFull", "(", ")", ")", "return", ";", "totalSize", "+=", "len", ";", "arrays", ".", "arrays", ".", "add", "(", "array", ")", ";", "}", "}" ]
Put an array in the cache.
[ "Put", "an", "array", "in", "the", "cache", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/memory/ByteArrayCache.java#L82-L103
150,996
khennig/lazy-datacontroller
lazy-datacontroller-impl/src/main/java/com/tri/ui/model/ListDataController.java
ListDataController.getIndexOf
int getIndexOf(final V value) { Validate.notNull(value, "Value required"); Validate.validState(getSize() > 0, "No data"); return getData().indexOf(value); }
java
int getIndexOf(final V value) { Validate.notNull(value, "Value required"); Validate.validState(getSize() > 0, "No data"); return getData().indexOf(value); }
[ "int", "getIndexOf", "(", "final", "V", "value", ")", "{", "Validate", ".", "notNull", "(", "value", ",", "\"Value required\"", ")", ";", "Validate", ".", "validState", "(", "getSize", "(", ")", ">", "0", ",", "\"No data\"", ")", ";", "return", "getData", "(", ")", ".", "indexOf", "(", "value", ")", ";", "}" ]
Returns the index of the first occurrence of the specified value in this controller, or -1 if this controller does not contain the value. @param value @return found index, or -1 if value was not found @throws NullPointerException if parameter value is null @throws IllegalStateException if there is no data available
[ "Returns", "the", "index", "of", "the", "first", "occurrence", "of", "the", "specified", "value", "in", "this", "controller", "or", "-", "1", "if", "this", "controller", "does", "not", "contain", "the", "value", "." ]
a72a5fc6ced43d0e06fc839d68bd58cede10ab56
https://github.com/khennig/lazy-datacontroller/blob/a72a5fc6ced43d0e06fc839d68bd58cede10ab56/lazy-datacontroller-impl/src/main/java/com/tri/ui/model/ListDataController.java#L202-L207
150,997
khennig/lazy-datacontroller
lazy-datacontroller-impl/src/main/java/com/tri/ui/model/ListDataController.java
ListDataController.findChachedValueOf
public V findChachedValueOf(K key) { // check selection for (V value : selection) { if (getKeyOf(value).equals(key)) { return value; } } // check data cache for (V value : getData()) { if (getKeyOf(value).equals(key)) { return value; } } return null; }
java
public V findChachedValueOf(K key) { // check selection for (V value : selection) { if (getKeyOf(value).equals(key)) { return value; } } // check data cache for (V value : getData()) { if (getKeyOf(value).equals(key)) { return value; } } return null; }
[ "public", "V", "findChachedValueOf", "(", "K", "key", ")", "{", "// check selection", "for", "(", "V", "value", ":", "selection", ")", "{", "if", "(", "getKeyOf", "(", "value", ")", ".", "equals", "(", "key", ")", ")", "{", "return", "value", ";", "}", "}", "// check data cache", "for", "(", "V", "value", ":", "getData", "(", ")", ")", "{", "if", "(", "getKeyOf", "(", "value", ")", ".", "equals", "(", "key", ")", ")", "{", "return", "value", ";", "}", "}", "return", "null", ";", "}" ]
Find value in cached data. @param key @return found value or null if non was found
[ "Find", "value", "in", "cached", "data", "." ]
a72a5fc6ced43d0e06fc839d68bd58cede10ab56
https://github.com/khennig/lazy-datacontroller/blob/a72a5fc6ced43d0e06fc839d68bd58cede10ab56/lazy-datacontroller-impl/src/main/java/com/tri/ui/model/ListDataController.java#L234-L251
150,998
khennig/lazy-datacontroller
lazy-datacontroller-impl/src/main/java/com/tri/ui/model/ListDataController.java
ListDataController.setSorting
public void setSorting(List<SortProperty> newSorting) { Validate.notNull(newSorting, "Sorting required"); if (!sorting.equals(newSorting)) { sorting.clear(); sorting.addAll(newSorting); selectionIndex = -1; clearCache(); } }
java
public void setSorting(List<SortProperty> newSorting) { Validate.notNull(newSorting, "Sorting required"); if (!sorting.equals(newSorting)) { sorting.clear(); sorting.addAll(newSorting); selectionIndex = -1; clearCache(); } }
[ "public", "void", "setSorting", "(", "List", "<", "SortProperty", ">", "newSorting", ")", "{", "Validate", ".", "notNull", "(", "newSorting", ",", "\"Sorting required\"", ")", ";", "if", "(", "!", "sorting", ".", "equals", "(", "newSorting", ")", ")", "{", "sorting", ".", "clear", "(", ")", ";", "sorting", ".", "addAll", "(", "newSorting", ")", ";", "selectionIndex", "=", "-", "1", ";", "clearCache", "(", ")", ";", "}", "}" ]
Sets sorting, does nothing if sorting will not change. Clears the cache but does not notify observers for data changes. @param newSorting List of SortProperties, replacing
[ "Sets", "sorting", "does", "nothing", "if", "sorting", "will", "not", "change", ".", "Clears", "the", "cache", "but", "does", "not", "notify", "observers", "for", "data", "changes", "." ]
a72a5fc6ced43d0e06fc839d68bd58cede10ab56
https://github.com/khennig/lazy-datacontroller/blob/a72a5fc6ced43d0e06fc839d68bd58cede10ab56/lazy-datacontroller-impl/src/main/java/com/tri/ui/model/ListDataController.java#L316-L325
150,999
isisaddons-legacy/isis-module-publishmq
dom/jdo/src/main/java/org/isisaddons/module/publishmq/dom/jdo/events/PublishedEventRepository.java
PublishedEventRepository.findByTransactionIdAndSequence
@Programmatic public PublishedEvent findByTransactionIdAndSequence(final UUID transactionId, final int sequence) { return repositoryService.uniqueMatch( new QueryDefault<>(PublishedEvent.class, "findByTransactionIdAndSequence", "transactionId", transactionId, "sequence", sequence )); }
java
@Programmatic public PublishedEvent findByTransactionIdAndSequence(final UUID transactionId, final int sequence) { return repositoryService.uniqueMatch( new QueryDefault<>(PublishedEvent.class, "findByTransactionIdAndSequence", "transactionId", transactionId, "sequence", sequence )); }
[ "@", "Programmatic", "public", "PublishedEvent", "findByTransactionIdAndSequence", "(", "final", "UUID", "transactionId", ",", "final", "int", "sequence", ")", "{", "return", "repositoryService", ".", "uniqueMatch", "(", "new", "QueryDefault", "<>", "(", "PublishedEvent", ".", "class", ",", "\"findByTransactionIdAndSequence\"", ",", "\"transactionId\"", ",", "transactionId", ",", "\"sequence\"", ",", "sequence", ")", ")", ";", "}" ]
region > findByTransactionIdAndSequence
[ "region", ">", "findByTransactionIdAndSequence" ]
b1a424f95b26a2a0369aac706c2e30074b7f6e43
https://github.com/isisaddons-legacy/isis-module-publishmq/blob/b1a424f95b26a2a0369aac706c2e30074b7f6e43/dom/jdo/src/main/java/org/isisaddons/module/publishmq/dom/jdo/events/PublishedEventRepository.java#L61-L69