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
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
1,900
opencredo/opencredo-esper
esper-template/src/main/java/org/opencredo/esper/EsperTemplate.java
EsperTemplate.configureEPServiceProvider
private void configureEPServiceProvider() throws EPException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("Configuring the Esper Service Provider with name: " + name); } if (this.configuration != null && this.configuration.exists()) { Configuration esperConfiguration = new Configuration(); esperConfiguration = esperConfiguration.configure(this.configuration.getFile()); epServiceProvider = EPServiceProviderManager.getProvider(name, esperConfiguration); LOG.info("Esper configured with a user-provided configuration", esperConfiguration); } else { epServiceProvider = EPServiceProviderManager.getProvider(name); } if (LOG.isDebugEnabled()) { LOG.debug("Completed configuring the Esper Service Provider with name: " + name); } }
java
private void configureEPServiceProvider() throws EPException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("Configuring the Esper Service Provider with name: " + name); } if (this.configuration != null && this.configuration.exists()) { Configuration esperConfiguration = new Configuration(); esperConfiguration = esperConfiguration.configure(this.configuration.getFile()); epServiceProvider = EPServiceProviderManager.getProvider(name, esperConfiguration); LOG.info("Esper configured with a user-provided configuration", esperConfiguration); } else { epServiceProvider = EPServiceProviderManager.getProvider(name); } if (LOG.isDebugEnabled()) { LOG.debug("Completed configuring the Esper Service Provider with name: " + name); } }
[ "private", "void", "configureEPServiceProvider", "(", ")", "throws", "EPException", ",", "IOException", "{", "if", "(", "LOG", ".", "isDebugEnabled", "(", ")", ")", "{", "LOG", ".", "debug", "(", "\"Configuring the Esper Service Provider with name: \"", "+", "name", ")", ";", "}", "if", "(", "this", ".", "configuration", "!=", "null", "&&", "this", ".", "configuration", ".", "exists", "(", ")", ")", "{", "Configuration", "esperConfiguration", "=", "new", "Configuration", "(", ")", ";", "esperConfiguration", "=", "esperConfiguration", ".", "configure", "(", "this", ".", "configuration", ".", "getFile", "(", ")", ")", ";", "epServiceProvider", "=", "EPServiceProviderManager", ".", "getProvider", "(", "name", ",", "esperConfiguration", ")", ";", "LOG", ".", "info", "(", "\"Esper configured with a user-provided configuration\"", ",", "esperConfiguration", ")", ";", "}", "else", "{", "epServiceProvider", "=", "EPServiceProviderManager", ".", "getProvider", "(", "name", ")", ";", "}", "if", "(", "LOG", ".", "isDebugEnabled", "(", ")", ")", "{", "LOG", ".", "debug", "(", "\"Completed configuring the Esper Service Provider with name: \"", "+", "name", ")", ";", "}", "}" ]
Configure the Esper Service Provider to create the appropriate Esper Runtime. @throws IOException @throws EPException
[ "Configure", "the", "Esper", "Service", "Provider", "to", "create", "the", "appropriate", "Esper", "Runtime", "." ]
a88c9fd0301a4d6962da70d85577c27d50d08825
https://github.com/opencredo/opencredo-esper/blob/a88c9fd0301a4d6962da70d85577c27d50d08825/esper-template/src/main/java/org/opencredo/esper/EsperTemplate.java#L171-L186
1,901
ksclarke/freelib-utils
src/main/java/info/freelibrary/maven/MavenUtils.java
MavenUtils.setLogLevels
public static void setLogLevels(final int aLogLevel, final String[] aLoggerList, final String[] aExcludesList, final String... aIncludesList) { final ArrayList<String> loggerList = new ArrayList<>(Arrays.asList(aLoggerList)); final Class<? extends Logger> simpleLogger = LoggerFactory.getLogger("org.slf4j.impl.SimpleLogger") .getClass(); if (aIncludesList != null) { loggerList.addAll(Arrays.asList(aIncludesList)); } for (final String loggerName : loggerList) { if (aExcludesList != null) { boolean skip = false; for (final String element : aExcludesList) { if (loggerName.equals(element)) { skip = true; break; } } if (skip) { continue; } } final Logger loggerObject = LoggerFactory.getLogger(loggerName); final Class<? extends Logger> loggerClass = loggerObject.getClass(); if (simpleLogger.equals(loggerClass)) { try { final Field field = loggerClass.getDeclaredField("currentLogLevel"); field.setAccessible(true); field.setInt(loggerObject, aLogLevel); if (loggerObject.isDebugEnabled()) { LOGGER.debug(MessageCodes.MVN_012, loggerName, getLevelName(aLogLevel)); } } catch (NoSuchFieldException | IllegalAccessException details) { LOGGER.error(MessageCodes.MVN_011, details); } } else { LOGGER.warn(MessageCodes.MVN_010, loggerName); } } }
java
public static void setLogLevels(final int aLogLevel, final String[] aLoggerList, final String[] aExcludesList, final String... aIncludesList) { final ArrayList<String> loggerList = new ArrayList<>(Arrays.asList(aLoggerList)); final Class<? extends Logger> simpleLogger = LoggerFactory.getLogger("org.slf4j.impl.SimpleLogger") .getClass(); if (aIncludesList != null) { loggerList.addAll(Arrays.asList(aIncludesList)); } for (final String loggerName : loggerList) { if (aExcludesList != null) { boolean skip = false; for (final String element : aExcludesList) { if (loggerName.equals(element)) { skip = true; break; } } if (skip) { continue; } } final Logger loggerObject = LoggerFactory.getLogger(loggerName); final Class<? extends Logger> loggerClass = loggerObject.getClass(); if (simpleLogger.equals(loggerClass)) { try { final Field field = loggerClass.getDeclaredField("currentLogLevel"); field.setAccessible(true); field.setInt(loggerObject, aLogLevel); if (loggerObject.isDebugEnabled()) { LOGGER.debug(MessageCodes.MVN_012, loggerName, getLevelName(aLogLevel)); } } catch (NoSuchFieldException | IllegalAccessException details) { LOGGER.error(MessageCodes.MVN_011, details); } } else { LOGGER.warn(MessageCodes.MVN_010, loggerName); } } }
[ "public", "static", "void", "setLogLevels", "(", "final", "int", "aLogLevel", ",", "final", "String", "[", "]", "aLoggerList", ",", "final", "String", "[", "]", "aExcludesList", ",", "final", "String", "...", "aIncludesList", ")", "{", "final", "ArrayList", "<", "String", ">", "loggerList", "=", "new", "ArrayList", "<>", "(", "Arrays", ".", "asList", "(", "aLoggerList", ")", ")", ";", "final", "Class", "<", "?", "extends", "Logger", ">", "simpleLogger", "=", "LoggerFactory", ".", "getLogger", "(", "\"org.slf4j.impl.SimpleLogger\"", ")", ".", "getClass", "(", ")", ";", "if", "(", "aIncludesList", "!=", "null", ")", "{", "loggerList", ".", "addAll", "(", "Arrays", ".", "asList", "(", "aIncludesList", ")", ")", ";", "}", "for", "(", "final", "String", "loggerName", ":", "loggerList", ")", "{", "if", "(", "aExcludesList", "!=", "null", ")", "{", "boolean", "skip", "=", "false", ";", "for", "(", "final", "String", "element", ":", "aExcludesList", ")", "{", "if", "(", "loggerName", ".", "equals", "(", "element", ")", ")", "{", "skip", "=", "true", ";", "break", ";", "}", "}", "if", "(", "skip", ")", "{", "continue", ";", "}", "}", "final", "Logger", "loggerObject", "=", "LoggerFactory", ".", "getLogger", "(", "loggerName", ")", ";", "final", "Class", "<", "?", "extends", "Logger", ">", "loggerClass", "=", "loggerObject", ".", "getClass", "(", ")", ";", "if", "(", "simpleLogger", ".", "equals", "(", "loggerClass", ")", ")", "{", "try", "{", "final", "Field", "field", "=", "loggerClass", ".", "getDeclaredField", "(", "\"currentLogLevel\"", ")", ";", "field", ".", "setAccessible", "(", "true", ")", ";", "field", ".", "setInt", "(", "loggerObject", ",", "aLogLevel", ")", ";", "if", "(", "loggerObject", ".", "isDebugEnabled", "(", ")", ")", "{", "LOGGER", ".", "debug", "(", "MessageCodes", ".", "MVN_012", ",", "loggerName", ",", "getLevelName", "(", "aLogLevel", ")", ")", ";", "}", "}", "catch", "(", "NoSuchFieldException", "|", "IllegalAccessException", "details", ")", "{", "LOGGER", ".", "error", "(", "MessageCodes", ".", "MVN_011", ",", "details", ")", ";", "}", "}", "else", "{", "LOGGER", ".", "warn", "(", "MessageCodes", ".", "MVN_010", ",", "loggerName", ")", ";", "}", "}", "}" ]
Sets the logging level of the supplied loggers, optionally excluding some and including others. @param aLogLevel A log level to set in the supplied loggers @param aLoggerList A list of names of loggers to have their levels reset @param aExcludesList A list of names of loggers to exclude from the reset @param aIncludesList A list of names of additional loggers to include in the reset
[ "Sets", "the", "logging", "level", "of", "the", "supplied", "loggers", "optionally", "excluding", "some", "and", "including", "others", "." ]
54e822ae4c11b3d74793fd82a1a535ffafffaf45
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/maven/MavenUtils.java#L54-L100
1,902
ksclarke/freelib-utils
src/main/java/info/freelibrary/maven/MavenUtils.java
MavenUtils.getLevelIntCode
public static int getLevelIntCode(final String aLogLevelName) { final String levelName = aLogLevelName.trim().toLowerCase(Locale.US); if ("error".equals(levelName)) { return ERROR_LOG_LEVEL; } else if ("warn".equals(levelName)) { return WARN_LOG_LEVEL; } else if ("info".equals(levelName)) { return INFO_LOG_LEVEL; } else if ("debug".equals(levelName)) { return DEBUG_LOG_LEVEL; } else if ("trace".equals(levelName)) { return TRACE_LOG_LEVEL; } else { return 0; } }
java
public static int getLevelIntCode(final String aLogLevelName) { final String levelName = aLogLevelName.trim().toLowerCase(Locale.US); if ("error".equals(levelName)) { return ERROR_LOG_LEVEL; } else if ("warn".equals(levelName)) { return WARN_LOG_LEVEL; } else if ("info".equals(levelName)) { return INFO_LOG_LEVEL; } else if ("debug".equals(levelName)) { return DEBUG_LOG_LEVEL; } else if ("trace".equals(levelName)) { return TRACE_LOG_LEVEL; } else { return 0; } }
[ "public", "static", "int", "getLevelIntCode", "(", "final", "String", "aLogLevelName", ")", "{", "final", "String", "levelName", "=", "aLogLevelName", ".", "trim", "(", ")", ".", "toLowerCase", "(", "Locale", ".", "US", ")", ";", "if", "(", "\"error\"", ".", "equals", "(", "levelName", ")", ")", "{", "return", "ERROR_LOG_LEVEL", ";", "}", "else", "if", "(", "\"warn\"", ".", "equals", "(", "levelName", ")", ")", "{", "return", "WARN_LOG_LEVEL", ";", "}", "else", "if", "(", "\"info\"", ".", "equals", "(", "levelName", ")", ")", "{", "return", "INFO_LOG_LEVEL", ";", "}", "else", "if", "(", "\"debug\"", ".", "equals", "(", "levelName", ")", ")", "{", "return", "DEBUG_LOG_LEVEL", ";", "}", "else", "if", "(", "\"trace\"", ".", "equals", "(", "levelName", ")", ")", "{", "return", "TRACE_LOG_LEVEL", ";", "}", "else", "{", "return", "0", ";", "}", "}" ]
Returns the int of the supplied log level or zero if the supplied name doesn't match a known log level. @param aLogLevelName The name (error, warn, info, debug, or trace) of a logging level @return The int code of the supplied level or zero if the supplied name doesn't correspond to a known level
[ "Returns", "the", "int", "of", "the", "supplied", "log", "level", "or", "zero", "if", "the", "supplied", "name", "doesn", "t", "match", "a", "known", "log", "level", "." ]
54e822ae4c11b3d74793fd82a1a535ffafffaf45
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/maven/MavenUtils.java#L152-L168
1,903
ksclarke/freelib-utils
src/main/java/info/freelibrary/util/URLUtils.java
URLUtils.decode
public static String decode(final String aURL, final String aEncoding) { String urlString = aURL; String decodedString; try { do { decodedString = urlString; // Java's URLDecoder needs a little help with occurrences of '%' that aren't percent escaped values urlString = URLDecoder.decode(decodedString.replaceAll("%(?![0-9a-fA-F]{2})", PERCENT), aEncoding); } while (!urlString.equals(decodedString)); } catch (final java.io.UnsupportedEncodingException details) { throw new UnsupportedEncodingException(details, aEncoding); } if (LOGGER.isDebugEnabled() && !aURL.equals(decodedString)) { LOGGER.debug(MessageCodes.DBG_002, aURL, decodedString); } return decodedString; }
java
public static String decode(final String aURL, final String aEncoding) { String urlString = aURL; String decodedString; try { do { decodedString = urlString; // Java's URLDecoder needs a little help with occurrences of '%' that aren't percent escaped values urlString = URLDecoder.decode(decodedString.replaceAll("%(?![0-9a-fA-F]{2})", PERCENT), aEncoding); } while (!urlString.equals(decodedString)); } catch (final java.io.UnsupportedEncodingException details) { throw new UnsupportedEncodingException(details, aEncoding); } if (LOGGER.isDebugEnabled() && !aURL.equals(decodedString)) { LOGGER.debug(MessageCodes.DBG_002, aURL, decodedString); } return decodedString; }
[ "public", "static", "String", "decode", "(", "final", "String", "aURL", ",", "final", "String", "aEncoding", ")", "{", "String", "urlString", "=", "aURL", ";", "String", "decodedString", ";", "try", "{", "do", "{", "decodedString", "=", "urlString", ";", "// Java's URLDecoder needs a little help with occurrences of '%' that aren't percent escaped values", "urlString", "=", "URLDecoder", ".", "decode", "(", "decodedString", ".", "replaceAll", "(", "\"%(?![0-9a-fA-F]{2})\"", ",", "PERCENT", ")", ",", "aEncoding", ")", ";", "}", "while", "(", "!", "urlString", ".", "equals", "(", "decodedString", ")", ")", ";", "}", "catch", "(", "final", "java", ".", "io", ".", "UnsupportedEncodingException", "details", ")", "{", "throw", "new", "UnsupportedEncodingException", "(", "details", ",", "aEncoding", ")", ";", "}", "if", "(", "LOGGER", ".", "isDebugEnabled", "(", ")", "&&", "!", "aURL", ".", "equals", "(", "decodedString", ")", ")", "{", "LOGGER", ".", "debug", "(", "MessageCodes", ".", "DBG_002", ",", "aURL", ",", "decodedString", ")", ";", "}", "return", "decodedString", ";", "}" ]
Decodes an encoded path. If it has been doubly encoded, it is doubly decoded. @param aURL An encoded URL String @param aEncoding A character encoding to use for the string decoding @return A decoded URL String
[ "Decodes", "an", "encoded", "path", ".", "If", "it", "has", "been", "doubly", "encoded", "it", "is", "doubly", "decoded", "." ]
54e822ae4c11b3d74793fd82a1a535ffafffaf45
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/URLUtils.java#L125-L145
1,904
ksclarke/freelib-utils
src/main/java/info/freelibrary/util/URLUtils.java
URLUtils.encode
public static String encode(final String aString, final boolean aIgnoreSlashFlag) { final CharacterIterator iterator = new StringCharacterIterator(decode(aString)); final StringBuilder builder = new StringBuilder(); for (char c = iterator.first(); c != CharacterIterator.DONE; c = iterator.next()) { switch (c) { case '%': builder.append(PERCENT); break; case '/': if (aIgnoreSlashFlag) { builder.append(c); } else { builder.append("%2F"); } break; case '?': builder.append("%3F"); break; case '#': builder.append("%23"); break; case '[': builder.append("%5B"); break; case ']': builder.append("%5D"); break; case '@': builder.append("%40"); break; default: builder.append(c); break; } } // Must percent-encode any characters outside the US-ASCII set return URI.create(builder.toString()).toASCIIString(); }
java
public static String encode(final String aString, final boolean aIgnoreSlashFlag) { final CharacterIterator iterator = new StringCharacterIterator(decode(aString)); final StringBuilder builder = new StringBuilder(); for (char c = iterator.first(); c != CharacterIterator.DONE; c = iterator.next()) { switch (c) { case '%': builder.append(PERCENT); break; case '/': if (aIgnoreSlashFlag) { builder.append(c); } else { builder.append("%2F"); } break; case '?': builder.append("%3F"); break; case '#': builder.append("%23"); break; case '[': builder.append("%5B"); break; case ']': builder.append("%5D"); break; case '@': builder.append("%40"); break; default: builder.append(c); break; } } // Must percent-encode any characters outside the US-ASCII set return URI.create(builder.toString()).toASCIIString(); }
[ "public", "static", "String", "encode", "(", "final", "String", "aString", ",", "final", "boolean", "aIgnoreSlashFlag", ")", "{", "final", "CharacterIterator", "iterator", "=", "new", "StringCharacterIterator", "(", "decode", "(", "aString", ")", ")", ";", "final", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "char", "c", "=", "iterator", ".", "first", "(", ")", ";", "c", "!=", "CharacterIterator", ".", "DONE", ";", "c", "=", "iterator", ".", "next", "(", ")", ")", "{", "switch", "(", "c", ")", "{", "case", "'", "'", ":", "builder", ".", "append", "(", "PERCENT", ")", ";", "break", ";", "case", "'", "'", ":", "if", "(", "aIgnoreSlashFlag", ")", "{", "builder", ".", "append", "(", "c", ")", ";", "}", "else", "{", "builder", ".", "append", "(", "\"%2F\"", ")", ";", "}", "break", ";", "case", "'", "'", ":", "builder", ".", "append", "(", "\"%3F\"", ")", ";", "break", ";", "case", "'", "'", ":", "builder", ".", "append", "(", "\"%23\"", ")", ";", "break", ";", "case", "'", "'", ":", "builder", ".", "append", "(", "\"%5B\"", ")", ";", "break", ";", "case", "'", "'", ":", "builder", ".", "append", "(", "\"%5D\"", ")", ";", "break", ";", "case", "'", "'", ":", "builder", ".", "append", "(", "\"%40\"", ")", ";", "break", ";", "default", ":", "builder", ".", "append", "(", "c", ")", ";", "break", ";", "}", "}", "// Must percent-encode any characters outside the US-ASCII set", "return", "URI", ".", "create", "(", "builder", ".", "toString", "(", ")", ")", ".", "toASCIIString", "(", ")", ";", "}" ]
Percent-encodes supplied string but only after decoding it completely first. @param aString The string to encode @param aIgnoreSlashFlag Whether slashes should be encoded or not @return The percent-encoded string
[ "Percent", "-", "encodes", "supplied", "string", "but", "only", "after", "decoding", "it", "completely", "first", "." ]
54e822ae4c11b3d74793fd82a1a535ffafffaf45
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/URLUtils.java#L154-L193
1,905
opencredo/opencredo-esper
esper-template/src/main/java/org/opencredo/esper/EsperStatement.java
EsperStatement.start
public void start() { if (LOG.isInfoEnabled()) { LOG.info("Esper statement [" + epl + "] being started"); } this.epStatement.start(); if (LOG.isInfoEnabled()) { LOG.info("Esper statement [" + epl + "] started"); } }
java
public void start() { if (LOG.isInfoEnabled()) { LOG.info("Esper statement [" + epl + "] being started"); } this.epStatement.start(); if (LOG.isInfoEnabled()) { LOG.info("Esper statement [" + epl + "] started"); } }
[ "public", "void", "start", "(", ")", "{", "if", "(", "LOG", ".", "isInfoEnabled", "(", ")", ")", "{", "LOG", ".", "info", "(", "\"Esper statement [\"", "+", "epl", "+", "\"] being started\"", ")", ";", "}", "this", ".", "epStatement", ".", "start", "(", ")", ";", "if", "(", "LOG", ".", "isInfoEnabled", "(", ")", ")", "{", "LOG", ".", "info", "(", "\"Esper statement [\"", "+", "epl", "+", "\"] started\"", ")", ";", "}", "}" ]
Starts events being collated according to the statement's filter query
[ "Starts", "events", "being", "collated", "according", "to", "the", "statement", "s", "filter", "query" ]
a88c9fd0301a4d6962da70d85577c27d50d08825
https://github.com/opencredo/opencredo-esper/blob/a88c9fd0301a4d6962da70d85577c27d50d08825/esper-template/src/main/java/org/opencredo/esper/EsperStatement.java#L78-L88
1,906
opencredo/opencredo-esper
esper-template/src/main/java/org/opencredo/esper/EsperStatement.java
EsperStatement.stop
public void stop() { if (LOG.isInfoEnabled()) { LOG.info("Esper statement [" + epl + "] being stopped"); } this.epStatement.stop(); if (LOG.isInfoEnabled()) { LOG.info("Esper statement [" + epl + "] stopped"); } }
java
public void stop() { if (LOG.isInfoEnabled()) { LOG.info("Esper statement [" + epl + "] being stopped"); } this.epStatement.stop(); if (LOG.isInfoEnabled()) { LOG.info("Esper statement [" + epl + "] stopped"); } }
[ "public", "void", "stop", "(", ")", "{", "if", "(", "LOG", ".", "isInfoEnabled", "(", ")", ")", "{", "LOG", ".", "info", "(", "\"Esper statement [\"", "+", "epl", "+", "\"] being stopped\"", ")", ";", "}", "this", ".", "epStatement", ".", "stop", "(", ")", ";", "if", "(", "LOG", ".", "isInfoEnabled", "(", ")", ")", "{", "LOG", ".", "info", "(", "\"Esper statement [\"", "+", "epl", "+", "\"] stopped\"", ")", ";", "}", "}" ]
Stops the underlying native statement from applying its filter query.
[ "Stops", "the", "underlying", "native", "statement", "from", "applying", "its", "filter", "query", "." ]
a88c9fd0301a4d6962da70d85577c27d50d08825
https://github.com/opencredo/opencredo-esper/blob/a88c9fd0301a4d6962da70d85577c27d50d08825/esper-template/src/main/java/org/opencredo/esper/EsperStatement.java#L93-L103
1,907
opencredo/opencredo-esper
esper-template/src/main/java/org/opencredo/esper/EsperStatement.java
EsperStatement.addEPStatementListener
private void addEPStatementListener(UpdateListener listener) { if (this.subscriber == null) { if (epStatement != null) { epStatement.addListener(listener); } } }
java
private void addEPStatementListener(UpdateListener listener) { if (this.subscriber == null) { if (epStatement != null) { epStatement.addListener(listener); } } }
[ "private", "void", "addEPStatementListener", "(", "UpdateListener", "listener", ")", "{", "if", "(", "this", ".", "subscriber", "==", "null", ")", "{", "if", "(", "epStatement", "!=", "null", ")", "{", "epStatement", ".", "addListener", "(", "listener", ")", ";", "}", "}", "}" ]
Adds an listener to the underlying native EPStatement. @param listener the listener to add
[ "Adds", "an", "listener", "to", "the", "underlying", "native", "EPStatement", "." ]
a88c9fd0301a4d6962da70d85577c27d50d08825
https://github.com/opencredo/opencredo-esper/blob/a88c9fd0301a4d6962da70d85577c27d50d08825/esper-template/src/main/java/org/opencredo/esper/EsperStatement.java#L170-L176
1,908
opencredo/opencredo-esper
esper-template/src/main/java/org/opencredo/esper/EsperStatement.java
EsperStatement.setEPStatement
void setEPStatement(EPStatement epStatement) { this.epStatement = epStatement; if (this.subscriber != null) { epStatement.setSubscriber(this.subscriber); } else { for (UpdateListener listener : listeners) { epStatement.addListener(listener); } } }
java
void setEPStatement(EPStatement epStatement) { this.epStatement = epStatement; if (this.subscriber != null) { epStatement.setSubscriber(this.subscriber); } else { for (UpdateListener listener : listeners) { epStatement.addListener(listener); } } }
[ "void", "setEPStatement", "(", "EPStatement", "epStatement", ")", "{", "this", ".", "epStatement", "=", "epStatement", ";", "if", "(", "this", ".", "subscriber", "!=", "null", ")", "{", "epStatement", ".", "setSubscriber", "(", "this", ".", "subscriber", ")", ";", "}", "else", "{", "for", "(", "UpdateListener", "listener", ":", "listeners", ")", "{", "epStatement", ".", "addListener", "(", "listener", ")", ";", "}", "}", "}" ]
Sets the native Esper statement. Typically created by an Esper Template. @param epStatement the underlying native Esper statement @see org.opencredo.esper.EsperTemplate
[ "Sets", "the", "native", "Esper", "statement", ".", "Typically", "created", "by", "an", "Esper", "Template", "." ]
a88c9fd0301a4d6962da70d85577c27d50d08825
https://github.com/opencredo/opencredo-esper/blob/a88c9fd0301a4d6962da70d85577c27d50d08825/esper-template/src/main/java/org/opencredo/esper/EsperStatement.java#L185-L194
1,909
ksclarke/freelib-utils
src/main/java/info/freelibrary/util/FileExtFileFilter.java
FileExtFileFilter.filters
public boolean filters(final String aFileExt) { final String normalizedExt = normalizeExt(aFileExt); for (final String extension : myExtensions) { if (extension.equals(normalizedExt)) { return true; } } return false; }
java
public boolean filters(final String aFileExt) { final String normalizedExt = normalizeExt(aFileExt); for (final String extension : myExtensions) { if (extension.equals(normalizedExt)) { return true; } } return false; }
[ "public", "boolean", "filters", "(", "final", "String", "aFileExt", ")", "{", "final", "String", "normalizedExt", "=", "normalizeExt", "(", "aFileExt", ")", ";", "for", "(", "final", "String", "extension", ":", "myExtensions", ")", "{", "if", "(", "extension", ".", "equals", "(", "normalizedExt", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns whether or not the supplied file extension is one that this filter matches. @param aFileExt A file extension like: jpg, gif, jp2, txt, xml, etc. @return True if this filter matches files with the supplied extension
[ "Returns", "whether", "or", "not", "the", "supplied", "file", "extension", "is", "one", "that", "this", "filter", "matches", "." ]
54e822ae4c11b3d74793fd82a1a535ffafffaf45
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/FileExtFileFilter.java#L77-L87
1,910
opencredo/opencredo-esper
esper-template/src/main/java/org/opencredo/esper/config/xml/EsperListenerParser.java
EsperListenerParser.parseListeners
@SuppressWarnings("unchecked") public ManagedSet parseListeners(Element element, ParserContext parserContext) { ManagedSet listeners = new ManagedSet(); NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { Element childElement = (Element) child; String localName = child.getLocalName(); if ("bean".equals(localName)) { BeanDefinitionHolder holder = parserContext.getDelegate().parseBeanDefinitionElement(childElement); parserContext.registerBeanComponent(new BeanComponentDefinition(holder)); listeners.add(new RuntimeBeanReference(holder.getBeanName())); } else if ("ref".equals(localName)) { String ref = childElement.getAttribute("bean"); listeners.add(new RuntimeBeanReference(ref)); } } } return listeners; }
java
@SuppressWarnings("unchecked") public ManagedSet parseListeners(Element element, ParserContext parserContext) { ManagedSet listeners = new ManagedSet(); NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { Element childElement = (Element) child; String localName = child.getLocalName(); if ("bean".equals(localName)) { BeanDefinitionHolder holder = parserContext.getDelegate().parseBeanDefinitionElement(childElement); parserContext.registerBeanComponent(new BeanComponentDefinition(holder)); listeners.add(new RuntimeBeanReference(holder.getBeanName())); } else if ("ref".equals(localName)) { String ref = childElement.getAttribute("bean"); listeners.add(new RuntimeBeanReference(ref)); } } } return listeners; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ManagedSet", "parseListeners", "(", "Element", "element", ",", "ParserContext", "parserContext", ")", "{", "ManagedSet", "listeners", "=", "new", "ManagedSet", "(", ")", ";", "NodeList", "childNodes", "=", "element", ".", "getChildNodes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "childNodes", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "Node", "child", "=", "childNodes", ".", "item", "(", "i", ")", ";", "if", "(", "child", ".", "getNodeType", "(", ")", "==", "Node", ".", "ELEMENT_NODE", ")", "{", "Element", "childElement", "=", "(", "Element", ")", "child", ";", "String", "localName", "=", "child", ".", "getLocalName", "(", ")", ";", "if", "(", "\"bean\"", ".", "equals", "(", "localName", ")", ")", "{", "BeanDefinitionHolder", "holder", "=", "parserContext", ".", "getDelegate", "(", ")", ".", "parseBeanDefinitionElement", "(", "childElement", ")", ";", "parserContext", ".", "registerBeanComponent", "(", "new", "BeanComponentDefinition", "(", "holder", ")", ")", ";", "listeners", ".", "add", "(", "new", "RuntimeBeanReference", "(", "holder", ".", "getBeanName", "(", ")", ")", ")", ";", "}", "else", "if", "(", "\"ref\"", ".", "equals", "(", "localName", ")", ")", "{", "String", "ref", "=", "childElement", ".", "getAttribute", "(", "\"bean\"", ")", ";", "listeners", ".", "add", "(", "new", "RuntimeBeanReference", "(", "ref", ")", ")", ";", "}", "}", "}", "return", "listeners", ";", "}" ]
Parses out a set of configured esper statement listeners. @param element the esper listeners element @param parserContext the parser's current context @return a list of configured esper statement listeners
[ "Parses", "out", "a", "set", "of", "configured", "esper", "statement", "listeners", "." ]
a88c9fd0301a4d6962da70d85577c27d50d08825
https://github.com/opencredo/opencredo-esper/blob/a88c9fd0301a4d6962da70d85577c27d50d08825/esper-template/src/main/java/org/opencredo/esper/config/xml/EsperListenerParser.java#L48-L68
1,911
ksclarke/freelib-utils
src/main/java/info/freelibrary/util/I18nObject.java
I18nObject.getI18n
protected String getI18n(final String aMessageKey, final long aLongDetail) { return StringUtils.normalizeWS(myBundle.get(aMessageKey, Long.toString(aLongDetail))); }
java
protected String getI18n(final String aMessageKey, final long aLongDetail) { return StringUtils.normalizeWS(myBundle.get(aMessageKey, Long.toString(aLongDetail))); }
[ "protected", "String", "getI18n", "(", "final", "String", "aMessageKey", ",", "final", "long", "aLongDetail", ")", "{", "return", "StringUtils", ".", "normalizeWS", "(", "myBundle", ".", "get", "(", "aMessageKey", ",", "Long", ".", "toString", "(", "aLongDetail", ")", ")", ")", ";", "}" ]
Gets the internationalized value for the supplied message key, using a long as additional information. @param aMessageKey A message key @param aLongDetail Additional details for the message @return The internationalized message
[ "Gets", "the", "internationalized", "value", "for", "the", "supplied", "message", "key", "using", "a", "long", "as", "additional", "information", "." ]
54e822ae4c11b3d74793fd82a1a535ffafffaf45
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/I18nObject.java#L57-L59
1,912
ksclarke/freelib-utils
src/main/java/info/freelibrary/util/I18nObject.java
I18nObject.getI18n
protected String getI18n(final String aMessageKey, final int aIntDetail) { return StringUtils.normalizeWS(myBundle.get(aMessageKey, Integer.toString(aIntDetail))); }
java
protected String getI18n(final String aMessageKey, final int aIntDetail) { return StringUtils.normalizeWS(myBundle.get(aMessageKey, Integer.toString(aIntDetail))); }
[ "protected", "String", "getI18n", "(", "final", "String", "aMessageKey", ",", "final", "int", "aIntDetail", ")", "{", "return", "StringUtils", ".", "normalizeWS", "(", "myBundle", ".", "get", "(", "aMessageKey", ",", "Integer", ".", "toString", "(", "aIntDetail", ")", ")", ")", ";", "}" ]
Gets the internationalized value for the supplied message key, using an int as additional information. @param aMessageKey A message key @param aIntDetail Additional details for the message @return The internationalized message
[ "Gets", "the", "internationalized", "value", "for", "the", "supplied", "message", "key", "using", "an", "int", "as", "additional", "information", "." ]
54e822ae4c11b3d74793fd82a1a535ffafffaf45
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/I18nObject.java#L68-L70
1,913
ksclarke/freelib-utils
src/main/java/info/freelibrary/util/I18nObject.java
I18nObject.getI18n
protected String getI18n(final String aMessageKey, final String aDetail) { return StringUtils.normalizeWS(myBundle.get(aMessageKey, aDetail)); }
java
protected String getI18n(final String aMessageKey, final String aDetail) { return StringUtils.normalizeWS(myBundle.get(aMessageKey, aDetail)); }
[ "protected", "String", "getI18n", "(", "final", "String", "aMessageKey", ",", "final", "String", "aDetail", ")", "{", "return", "StringUtils", ".", "normalizeWS", "(", "myBundle", ".", "get", "(", "aMessageKey", ",", "aDetail", ")", ")", ";", "}" ]
Gets the internationalized value for the supplied message key, using a string as additional information. @param aMessageKey A message key @param aDetail Additional details for the message @return The internationalized message
[ "Gets", "the", "internationalized", "value", "for", "the", "supplied", "message", "key", "using", "a", "string", "as", "additional", "information", "." ]
54e822ae4c11b3d74793fd82a1a535ffafffaf45
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/I18nObject.java#L79-L81
1,914
ksclarke/freelib-utils
src/main/java/info/freelibrary/util/I18nObject.java
I18nObject.getI18n
protected String getI18n(final String aMessageKey, final String... aDetailsArray) { return StringUtils.normalizeWS(myBundle.get(aMessageKey, aDetailsArray)); }
java
protected String getI18n(final String aMessageKey, final String... aDetailsArray) { return StringUtils.normalizeWS(myBundle.get(aMessageKey, aDetailsArray)); }
[ "protected", "String", "getI18n", "(", "final", "String", "aMessageKey", ",", "final", "String", "...", "aDetailsArray", ")", "{", "return", "StringUtils", ".", "normalizeWS", "(", "myBundle", ".", "get", "(", "aMessageKey", ",", "aDetailsArray", ")", ")", ";", "}" ]
Gets the internationalized value for the supplied message key, using a string array as additional information. @param aMessageKey A message key @param aDetailsArray Additional details for the message @return The internationalized message
[ "Gets", "the", "internationalized", "value", "for", "the", "supplied", "message", "key", "using", "a", "string", "array", "as", "additional", "information", "." ]
54e822ae4c11b3d74793fd82a1a535ffafffaf45
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/I18nObject.java#L90-L92
1,915
ksclarke/freelib-utils
src/main/java/info/freelibrary/util/I18nObject.java
I18nObject.getI18n
protected String getI18n(final String aMessageKey, final Exception aException) { return StringUtils.normalizeWS(myBundle.get(aMessageKey, aException.getMessage())); }
java
protected String getI18n(final String aMessageKey, final Exception aException) { return StringUtils.normalizeWS(myBundle.get(aMessageKey, aException.getMessage())); }
[ "protected", "String", "getI18n", "(", "final", "String", "aMessageKey", ",", "final", "Exception", "aException", ")", "{", "return", "StringUtils", ".", "normalizeWS", "(", "myBundle", ".", "get", "(", "aMessageKey", ",", "aException", ".", "getMessage", "(", ")", ")", ")", ";", "}" ]
Gets the internationalized value for the supplied message key, using an exception as additional information. @param aMessageKey A message key @param aException Additional details for the message @return The internationalized message
[ "Gets", "the", "internationalized", "value", "for", "the", "supplied", "message", "key", "using", "an", "exception", "as", "additional", "information", "." ]
54e822ae4c11b3d74793fd82a1a535ffafffaf45
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/I18nObject.java#L101-L103
1,916
ksclarke/freelib-utils
src/main/java/info/freelibrary/util/I18nObject.java
I18nObject.getI18n
protected String getI18n(final String aMessageKey, final File aFile) { return StringUtils.normalizeWS(myBundle.get(aMessageKey, aFile.getAbsolutePath())); }
java
protected String getI18n(final String aMessageKey, final File aFile) { return StringUtils.normalizeWS(myBundle.get(aMessageKey, aFile.getAbsolutePath())); }
[ "protected", "String", "getI18n", "(", "final", "String", "aMessageKey", ",", "final", "File", "aFile", ")", "{", "return", "StringUtils", ".", "normalizeWS", "(", "myBundle", ".", "get", "(", "aMessageKey", ",", "aFile", ".", "getAbsolutePath", "(", ")", ")", ")", ";", "}" ]
Gets the internationalized value for the supplied message key, using a file as additional information. @param aMessageKey A message key @param aFile Additional details for the message @return The internationalized message
[ "Gets", "the", "internationalized", "value", "for", "the", "supplied", "message", "key", "using", "a", "file", "as", "additional", "information", "." ]
54e822ae4c11b3d74793fd82a1a535ffafffaf45
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/I18nObject.java#L112-L114
1,917
ksclarke/freelib-utils
src/main/java/info/freelibrary/util/I18nObject.java
I18nObject.getI18n
protected String getI18n(final String aMessageKey, final File... aFileArray) { final String[] fileNames = new String[aFileArray.length]; for (int index = 0; index < fileNames.length; index++) { fileNames[index] = aFileArray[index].getAbsolutePath(); } return StringUtils.normalizeWS(myBundle.get(aMessageKey, fileNames)); }
java
protected String getI18n(final String aMessageKey, final File... aFileArray) { final String[] fileNames = new String[aFileArray.length]; for (int index = 0; index < fileNames.length; index++) { fileNames[index] = aFileArray[index].getAbsolutePath(); } return StringUtils.normalizeWS(myBundle.get(aMessageKey, fileNames)); }
[ "protected", "String", "getI18n", "(", "final", "String", "aMessageKey", ",", "final", "File", "...", "aFileArray", ")", "{", "final", "String", "[", "]", "fileNames", "=", "new", "String", "[", "aFileArray", ".", "length", "]", ";", "for", "(", "int", "index", "=", "0", ";", "index", "<", "fileNames", ".", "length", ";", "index", "++", ")", "{", "fileNames", "[", "index", "]", "=", "aFileArray", "[", "index", "]", ".", "getAbsolutePath", "(", ")", ";", "}", "return", "StringUtils", ".", "normalizeWS", "(", "myBundle", ".", "get", "(", "aMessageKey", ",", "fileNames", ")", ")", ";", "}" ]
Gets the internationalized value for the supplied message key, using a file array as additional information. @param aMessageKey A message key @param aFileArray Additional details for the message @return The internationalized message
[ "Gets", "the", "internationalized", "value", "for", "the", "supplied", "message", "key", "using", "a", "file", "array", "as", "additional", "information", "." ]
54e822ae4c11b3d74793fd82a1a535ffafffaf45
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/I18nObject.java#L123-L131
1,918
ksclarke/freelib-utils
src/main/java/info/freelibrary/util/I18nObject.java
I18nObject.getI18n
protected String getI18n(final String aMessageKey, final Object... aObjArray) { final String[] strings = new String[aObjArray.length]; for (int index = 0; index < aObjArray.length; index++) { if (aObjArray[index] instanceof File) { strings[index] = ((File) aObjArray[index]).getAbsolutePath(); } else { strings[index] = aObjArray[index].toString(); } } return StringUtils.normalizeWS(myBundle.get(aMessageKey, strings)); }
java
protected String getI18n(final String aMessageKey, final Object... aObjArray) { final String[] strings = new String[aObjArray.length]; for (int index = 0; index < aObjArray.length; index++) { if (aObjArray[index] instanceof File) { strings[index] = ((File) aObjArray[index]).getAbsolutePath(); } else { strings[index] = aObjArray[index].toString(); } } return StringUtils.normalizeWS(myBundle.get(aMessageKey, strings)); }
[ "protected", "String", "getI18n", "(", "final", "String", "aMessageKey", ",", "final", "Object", "...", "aObjArray", ")", "{", "final", "String", "[", "]", "strings", "=", "new", "String", "[", "aObjArray", ".", "length", "]", ";", "for", "(", "int", "index", "=", "0", ";", "index", "<", "aObjArray", ".", "length", ";", "index", "++", ")", "{", "if", "(", "aObjArray", "[", "index", "]", "instanceof", "File", ")", "{", "strings", "[", "index", "]", "=", "(", "(", "File", ")", "aObjArray", "[", "index", "]", ")", ".", "getAbsolutePath", "(", ")", ";", "}", "else", "{", "strings", "[", "index", "]", "=", "aObjArray", "[", "index", "]", ".", "toString", "(", ")", ";", "}", "}", "return", "StringUtils", ".", "normalizeWS", "(", "myBundle", ".", "get", "(", "aMessageKey", ",", "strings", ")", ")", ";", "}" ]
Gets the internationalized value for the supplied message key, using an object array as additional information. @param aMessageKey A message key @param aObjArray Additional details for the message @return The internationalized message
[ "Gets", "the", "internationalized", "value", "for", "the", "supplied", "message", "key", "using", "an", "object", "array", "as", "additional", "information", "." ]
54e822ae4c11b3d74793fd82a1a535ffafffaf45
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/I18nObject.java#L140-L152
1,919
ksclarke/freelib-utils
src/main/java/info/freelibrary/util/I18nObject.java
I18nObject.hasI18nKey
protected boolean hasI18nKey(final String aMessageKey) { return myBundle != null && aMessageKey != null && myBundle.containsKey(aMessageKey); }
java
protected boolean hasI18nKey(final String aMessageKey) { return myBundle != null && aMessageKey != null && myBundle.containsKey(aMessageKey); }
[ "protected", "boolean", "hasI18nKey", "(", "final", "String", "aMessageKey", ")", "{", "return", "myBundle", "!=", "null", "&&", "aMessageKey", "!=", "null", "&&", "myBundle", ".", "containsKey", "(", "aMessageKey", ")", ";", "}" ]
Returns true if this I18N object contains the requested I18N key; else, false. @param aMessageKey A key to check to see if it exists @return True if the key exists; else, false
[ "Returns", "true", "if", "this", "I18N", "object", "contains", "the", "requested", "I18N", "key", ";", "else", "false", "." ]
54e822ae4c11b3d74793fd82a1a535ffafffaf45
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/I18nObject.java#L160-L162
1,920
ksclarke/freelib-utils
src/main/java/info/freelibrary/util/ClasspathUtils.java
ClasspathUtils.getDirs
public static String[] getDirs() { final ArrayList<String> list = new ArrayList<>(); for (final String filename : System.getProperty(CLASSPATH).split(DELIMETER)) { final File file = new File(filename); LOGGER.debug(MessageCodes.UTIL_003, file, file.isDirectory() ? YES : NO); if (file.isDirectory()) { list.add(file.getAbsolutePath()); } } return list.toArray(new String[0]); }
java
public static String[] getDirs() { final ArrayList<String> list = new ArrayList<>(); for (final String filename : System.getProperty(CLASSPATH).split(DELIMETER)) { final File file = new File(filename); LOGGER.debug(MessageCodes.UTIL_003, file, file.isDirectory() ? YES : NO); if (file.isDirectory()) { list.add(file.getAbsolutePath()); } } return list.toArray(new String[0]); }
[ "public", "static", "String", "[", "]", "getDirs", "(", ")", "{", "final", "ArrayList", "<", "String", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "final", "String", "filename", ":", "System", ".", "getProperty", "(", "CLASSPATH", ")", ".", "split", "(", "DELIMETER", ")", ")", "{", "final", "File", "file", "=", "new", "File", "(", "filename", ")", ";", "LOGGER", ".", "debug", "(", "MessageCodes", ".", "UTIL_003", ",", "file", ",", "file", ".", "isDirectory", "(", ")", "?", "YES", ":", "NO", ")", ";", "if", "(", "file", ".", "isDirectory", "(", ")", ")", "{", "list", ".", "add", "(", "file", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "}", "return", "list", ".", "toArray", "(", "new", "String", "[", "0", "]", ")", ";", "}" ]
Returns an String array of all the directory names in the system classpath @return The names of directories from the system classpath
[ "Returns", "an", "String", "array", "of", "all", "the", "directory", "names", "in", "the", "system", "classpath" ]
54e822ae4c11b3d74793fd82a1a535ffafffaf45
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/ClasspathUtils.java#L39-L53
1,921
ksclarke/freelib-utils
src/main/java/info/freelibrary/util/ClasspathUtils.java
ClasspathUtils.getJars
public static String[] getJars() { final ArrayList<String> list = new ArrayList<>(); final FileExtFileFilter filter = new FileExtFileFilter(JAR_EXT); for (final String part : System.getProperty(CLASSPATH).split(File.pathSeparator)) { final File file = new File(part); if (filter.accept(file.getParentFile(), file.getName())) { list.add(file.getAbsolutePath()); } } return list.toArray(new String[0]); }
java
public static String[] getJars() { final ArrayList<String> list = new ArrayList<>(); final FileExtFileFilter filter = new FileExtFileFilter(JAR_EXT); for (final String part : System.getProperty(CLASSPATH).split(File.pathSeparator)) { final File file = new File(part); if (filter.accept(file.getParentFile(), file.getName())) { list.add(file.getAbsolutePath()); } } return list.toArray(new String[0]); }
[ "public", "static", "String", "[", "]", "getJars", "(", ")", "{", "final", "ArrayList", "<", "String", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "final", "FileExtFileFilter", "filter", "=", "new", "FileExtFileFilter", "(", "JAR_EXT", ")", ";", "for", "(", "final", "String", "part", ":", "System", ".", "getProperty", "(", "CLASSPATH", ")", ".", "split", "(", "File", ".", "pathSeparator", ")", ")", "{", "final", "File", "file", "=", "new", "File", "(", "part", ")", ";", "if", "(", "filter", ".", "accept", "(", "file", ".", "getParentFile", "(", ")", ",", "file", ".", "getName", "(", ")", ")", ")", "{", "list", ".", "add", "(", "file", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "}", "return", "list", ".", "toArray", "(", "new", "String", "[", "0", "]", ")", ";", "}" ]
Returns an String array of all the names of the jars in the system classpath @return The names of jars from the system classpath
[ "Returns", "an", "String", "array", "of", "all", "the", "names", "of", "the", "jars", "in", "the", "system", "classpath" ]
54e822ae4c11b3d74793fd82a1a535ffafffaf45
https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/ClasspathUtils.java#L126-L139
1,922
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipCall.java
SipCall.initiateOutgoingMessage
public boolean initiateOutgoingMessage(String toUri, String viaNonProxyRoute) { return initiateOutgoingMessage(null, toUri, viaNonProxyRoute, null, null, null); }
java
public boolean initiateOutgoingMessage(String toUri, String viaNonProxyRoute) { return initiateOutgoingMessage(null, toUri, viaNonProxyRoute, null, null, null); }
[ "public", "boolean", "initiateOutgoingMessage", "(", "String", "toUri", ",", "String", "viaNonProxyRoute", ")", "{", "return", "initiateOutgoingMessage", "(", "null", ",", "toUri", ",", "viaNonProxyRoute", ",", "null", ",", "null", ",", "null", ")", ";", "}" ]
This basic method is used to initiate an outgoing MESSAGE. <p> This method returns when the request message has been sent out. Your calling program must subsequently call the waitOutgoingMessageResponse() method (one or more times) to get the result(s). <p> If a DIALOG exists the method will use it to send the MESSAGE @param toUri The URI (sip:[email protected]) to which the message should be directed @param viaNonProxyRoute Indicates whether to route the MESSAGE via Proxy or some other route. If null, route the call to the Proxy that was specified when the SipPhone object was created (SipStack.createSipPhone()). Else route it to the given node, which is specified as "hostaddress:port;parms/transport" i.e. 129.1.22.333:5060;lr/UDP. @return true if the message was successfully sent, false otherwise.
[ "This", "basic", "method", "is", "used", "to", "initiate", "an", "outgoing", "MESSAGE", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipCall.java#L746-L748
1,923
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipCall.java
SipCall.findMostRecentResponse
public SipResponse findMostRecentResponse(int statusCode) { List<SipResponse> responses = getAllReceivedResponses(); ListIterator<SipResponse> i = responses.listIterator(responses.size()); while (i.hasPrevious()) { SipResponse resp = i.previous(); if (resp.getStatusCode() == statusCode) { return resp; } } return null; }
java
public SipResponse findMostRecentResponse(int statusCode) { List<SipResponse> responses = getAllReceivedResponses(); ListIterator<SipResponse> i = responses.listIterator(responses.size()); while (i.hasPrevious()) { SipResponse resp = i.previous(); if (resp.getStatusCode() == statusCode) { return resp; } } return null; }
[ "public", "SipResponse", "findMostRecentResponse", "(", "int", "statusCode", ")", "{", "List", "<", "SipResponse", ">", "responses", "=", "getAllReceivedResponses", "(", ")", ";", "ListIterator", "<", "SipResponse", ">", "i", "=", "responses", ".", "listIterator", "(", "responses", ".", "size", "(", ")", ")", ";", "while", "(", "i", ".", "hasPrevious", "(", ")", ")", "{", "SipResponse", "resp", "=", "i", ".", "previous", "(", ")", ";", "if", "(", "resp", ".", "getStatusCode", "(", ")", "==", "statusCode", ")", "{", "return", "resp", ";", "}", "}", "return", "null", ";", "}" ]
Finds the last received response with status code matching the given parameter. @param statusCode Indicates the type of response to return. @return SipResponse object or null, if not found.
[ "Finds", "the", "last", "received", "response", "with", "status", "code", "matching", "the", "given", "parameter", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipCall.java#L2973-L2985
1,924
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipSession.java
SipSession.generateNewTag
public String generateNewTag() { // This scheme of using random numbers to generate a // unique tag has a small probability of // causing duplicate tags. // TODO at some point, we may want to change it. int r = parent.getRandom().nextInt(); r = (r < 0) ? 0 - r : r; // generate a positive number // incorporate registration/session ID (myRegistrationId) into all tags // from this // client? (for jiplet call identification purposes) return Integer.toString(r); }
java
public String generateNewTag() { // This scheme of using random numbers to generate a // unique tag has a small probability of // causing duplicate tags. // TODO at some point, we may want to change it. int r = parent.getRandom().nextInt(); r = (r < 0) ? 0 - r : r; // generate a positive number // incorporate registration/session ID (myRegistrationId) into all tags // from this // client? (for jiplet call identification purposes) return Integer.toString(r); }
[ "public", "String", "generateNewTag", "(", ")", "{", "// This scheme of using random numbers to generate a", "// unique tag has a small probability of", "// causing duplicate tags.", "// TODO at some point, we may want to change it.", "int", "r", "=", "parent", ".", "getRandom", "(", ")", ".", "nextInt", "(", ")", ";", "r", "=", "(", "r", "<", "0", ")", "?", "0", "-", "r", ":", "r", ";", "// generate a positive number", "// incorporate registration/session ID (myRegistrationId) into all tags", "// from this", "// client? (for jiplet call identification purposes)", "return", "Integer", ".", "toString", "(", "r", ")", ";", "}" ]
Generates a newly generated unique tag ID. @return A String tag ID
[ "Generates", "a", "newly", "generated", "unique", "tag", "ID", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipSession.java#L290-L304
1,925
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipSession.java
SipSession.sendRequestWithTransaction
public SipTransaction sendRequestWithTransaction(String reqMessage, boolean viaProxy, Dialog dialog) throws ParseException { Request request = parent.getMessageFactory().createRequest(reqMessage); return sendRequestWithTransaction(request, viaProxy, dialog); }
java
public SipTransaction sendRequestWithTransaction(String reqMessage, boolean viaProxy, Dialog dialog) throws ParseException { Request request = parent.getMessageFactory().createRequest(reqMessage); return sendRequestWithTransaction(request, viaProxy, dialog); }
[ "public", "SipTransaction", "sendRequestWithTransaction", "(", "String", "reqMessage", ",", "boolean", "viaProxy", ",", "Dialog", "dialog", ")", "throws", "ParseException", "{", "Request", "request", "=", "parent", ".", "getMessageFactory", "(", ")", ".", "createRequest", "(", "reqMessage", ")", ";", "return", "sendRequestWithTransaction", "(", "request", ",", "viaProxy", ",", "dialog", ")", ";", "}" ]
This basic method sends out a request message as part of a transaction. A test program should use this method when a response to a request is expected. A Request object is constructed from the string passed in. <p> This method returns when the request message has been sent out. The calling program must subsequently call the waitResponse() method to wait for the result (response, timeout, etc.). @param reqMessage A request message in the form of a String with everything from the request line and headers to the body. It must be in the proper format per RFC-3261. @param viaProxy If true, send the message to the proxy. In this case the request URI is modified by this method. Else send it to the user specified in the given request URI. In this case, for an INVITE request, a route header must be present for the request routing to complete. This method does NOT add a route header. @param dialog If not null, send the request via the given dialog. Else send it outside of any dialog. @return A SipTransaction object if the message was built and sent successfully, null otherwise. The calling program doesn't need to do anything with the returned SipTransaction other than pass it in to a subsequent call to waitResponse(). @throws ParseException if an error is encountered while parsing the string.
[ "This", "basic", "method", "sends", "out", "a", "request", "message", "as", "part", "of", "a", "transaction", ".", "A", "test", "program", "should", "use", "this", "method", "when", "a", "response", "to", "a", "request", "is", "expected", ".", "A", "Request", "object", "is", "constructed", "from", "the", "string", "passed", "in", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipSession.java#L826-L830
1,926
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipSession.java
SipSession.sendRequestWithTransaction
public SipTransaction sendRequestWithTransaction(Request request, boolean viaProxy, Dialog dialog) { return sendRequestWithTransaction(request, viaProxy, dialog, null); }
java
public SipTransaction sendRequestWithTransaction(Request request, boolean viaProxy, Dialog dialog) { return sendRequestWithTransaction(request, viaProxy, dialog, null); }
[ "public", "SipTransaction", "sendRequestWithTransaction", "(", "Request", "request", ",", "boolean", "viaProxy", ",", "Dialog", "dialog", ")", "{", "return", "sendRequestWithTransaction", "(", "request", ",", "viaProxy", ",", "dialog", ",", "null", ")", ";", "}" ]
This basic method sends out a request message as part of a transaction. A test program should use this method when a response to a request is expected. The Request object passed in must be a fully formed Request with all required content, EXCEPT for the Via header branch parameter, which cannot be filled in until a client transaction is obtained. That happens in this method. If the Via branch value is set in the request parameter passed to this method, it is nulled out by this method so that a new client transaction can be created by the stack. This method returns when the request message has been sent out. The calling program must subsequently call the waitResponse() method to wait for the result (response, timeout, etc.). @param request The request to be sent out. @param viaProxy If true, send the message to the proxy. In this case a Route header is added by this method. Else send the message as is. In this case, for an INVITE request, a route header must have been added by the caller for the request routing to complete. @param dialog If not null, send the request via the given dialog. Else send it outside of any dialog. @return A SipTransaction object if the message was sent successfully, null otherwise. The calling program doesn't need to do anything with the returned SipTransaction other than pass it in to a subsequent call to waitResponse().
[ "This", "basic", "method", "sends", "out", "a", "request", "message", "as", "part", "of", "a", "transaction", ".", "A", "test", "program", "should", "use", "this", "method", "when", "a", "response", "to", "a", "request", "is", "expected", ".", "The", "Request", "object", "passed", "in", "must", "be", "a", "fully", "formed", "Request", "with", "all", "required", "content", "EXCEPT", "for", "the", "Via", "header", "branch", "parameter", "which", "cannot", "be", "filled", "in", "until", "a", "client", "transaction", "is", "obtained", ".", "That", "happens", "in", "this", "method", ".", "If", "the", "Via", "branch", "value", "is", "set", "in", "the", "request", "parameter", "passed", "to", "this", "method", "it", "is", "nulled", "out", "by", "this", "method", "so", "that", "a", "new", "client", "transaction", "can", "be", "created", "by", "the", "stack", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipSession.java#L935-L938
1,927
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipSession.java
SipSession.sendUnidirectionalResponse
public boolean sendUnidirectionalResponse(RequestEvent request, int statusCode, String reasonPhrase, String toTag, Address contact, int expires) { initErrorInfo(); if ((request == null) || (request.getRequest() == null)) { setErrorMessage("Cannot send response, request information is null"); setReturnCode(INVALID_ARGUMENT); return false; } Response response; try { response = parent.getMessageFactory().createResponse(statusCode, request.getRequest()); if (reasonPhrase != null) { response.setReasonPhrase(reasonPhrase); } if (toTag != null) { ((ToHeader) response.getHeader(ToHeader.NAME)).setTag(toTag); } if (contact != null) { response.addHeader(parent.getHeaderFactory().createContactHeader(contact)); } if (expires != -1) { response.addHeader(parent.getHeaderFactory().createExpiresHeader(expires)); } } catch (Exception ex) { setException(ex); setErrorMessage("Exception: " + ex.getClass().getName() + ": " + ex.getMessage()); setReturnCode(EXCEPTION_ENCOUNTERED); return false; } return sendUnidirectionalResponse(response); }
java
public boolean sendUnidirectionalResponse(RequestEvent request, int statusCode, String reasonPhrase, String toTag, Address contact, int expires) { initErrorInfo(); if ((request == null) || (request.getRequest() == null)) { setErrorMessage("Cannot send response, request information is null"); setReturnCode(INVALID_ARGUMENT); return false; } Response response; try { response = parent.getMessageFactory().createResponse(statusCode, request.getRequest()); if (reasonPhrase != null) { response.setReasonPhrase(reasonPhrase); } if (toTag != null) { ((ToHeader) response.getHeader(ToHeader.NAME)).setTag(toTag); } if (contact != null) { response.addHeader(parent.getHeaderFactory().createContactHeader(contact)); } if (expires != -1) { response.addHeader(parent.getHeaderFactory().createExpiresHeader(expires)); } } catch (Exception ex) { setException(ex); setErrorMessage("Exception: " + ex.getClass().getName() + ": " + ex.getMessage()); setReturnCode(EXCEPTION_ENCOUNTERED); return false; } return sendUnidirectionalResponse(response); }
[ "public", "boolean", "sendUnidirectionalResponse", "(", "RequestEvent", "request", ",", "int", "statusCode", ",", "String", "reasonPhrase", ",", "String", "toTag", ",", "Address", "contact", ",", "int", "expires", ")", "{", "initErrorInfo", "(", ")", ";", "if", "(", "(", "request", "==", "null", ")", "||", "(", "request", ".", "getRequest", "(", ")", "==", "null", ")", ")", "{", "setErrorMessage", "(", "\"Cannot send response, request information is null\"", ")", ";", "setReturnCode", "(", "INVALID_ARGUMENT", ")", ";", "return", "false", ";", "}", "Response", "response", ";", "try", "{", "response", "=", "parent", ".", "getMessageFactory", "(", ")", ".", "createResponse", "(", "statusCode", ",", "request", ".", "getRequest", "(", ")", ")", ";", "if", "(", "reasonPhrase", "!=", "null", ")", "{", "response", ".", "setReasonPhrase", "(", "reasonPhrase", ")", ";", "}", "if", "(", "toTag", "!=", "null", ")", "{", "(", "(", "ToHeader", ")", "response", ".", "getHeader", "(", "ToHeader", ".", "NAME", ")", ")", ".", "setTag", "(", "toTag", ")", ";", "}", "if", "(", "contact", "!=", "null", ")", "{", "response", ".", "addHeader", "(", "parent", ".", "getHeaderFactory", "(", ")", ".", "createContactHeader", "(", "contact", ")", ")", ";", "}", "if", "(", "expires", "!=", "-", "1", ")", "{", "response", ".", "addHeader", "(", "parent", ".", "getHeaderFactory", "(", ")", ".", "createExpiresHeader", "(", "expires", ")", ")", ";", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "setException", "(", "ex", ")", ";", "setErrorMessage", "(", "\"Exception: \"", "+", "ex", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\": \"", "+", "ex", ".", "getMessage", "(", ")", ")", ";", "setReturnCode", "(", "EXCEPTION_ENCOUNTERED", ")", ";", "return", "false", ";", "}", "return", "sendUnidirectionalResponse", "(", "response", ")", ";", "}" ]
This method sends out a stateless response to the given request. @param request The RequestEvent object that contains the request we are responding to. @param statusCode The status code of the response to send (may use SipResponse constants). @param reasonPhrase If not null, the reason phrase to send. @param toTag If not null, it will be put into the 'To' header of the response. Required by final responses such as OK. @param contact If not null, it will be used to create a 'Contact' header to be added to the response. @param expires If not -1, an 'Expires' header is added to the response containing this value, which is the time the message is valid, in seconds. @return True if the response was successfully sent, false otherwise.
[ "This", "method", "sends", "out", "a", "stateless", "response", "to", "the", "given", "request", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipSession.java#L1722-L1761
1,928
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipTransaction.java
SipTransaction.getRequest
public Request getRequest() { if (clientTransaction != null) { return clientTransaction.getRequest(); } if (serverTransaction != null) { return serverTransaction.getRequest(); } return null; }
java
public Request getRequest() { if (clientTransaction != null) { return clientTransaction.getRequest(); } if (serverTransaction != null) { return serverTransaction.getRequest(); } return null; }
[ "public", "Request", "getRequest", "(", ")", "{", "if", "(", "clientTransaction", "!=", "null", ")", "{", "return", "clientTransaction", ".", "getRequest", "(", ")", ";", "}", "if", "(", "serverTransaction", "!=", "null", ")", "{", "return", "serverTransaction", ".", "getRequest", "(", ")", ";", "}", "return", "null", ";", "}" ]
The user test program MAY call this method to view the javax.sip.message.Request object that created this transaction. However, knowledge of JAIN SIP API is required to interpret the Request object. @return Returns the javax.sip.message.Request object that created this transaction.
[ "The", "user", "test", "program", "MAY", "call", "this", "method", "to", "view", "the", "javax", ".", "sip", ".", "message", ".", "Request", "object", "that", "created", "this", "transaction", ".", "However", "knowledge", "of", "JAIN", "SIP", "API", "is", "required", "to", "interpret", "the", "Request", "object", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipTransaction.java#L128-L138
1,929
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertLastOperationSuccess
public static void assertLastOperationSuccess(String msg, SipActionObject op) { assertNotNull("Null assert object passed in", op); assertTrue(msg, op.getErrorMessage().length() == 0); }
java
public static void assertLastOperationSuccess(String msg, SipActionObject op) { assertNotNull("Null assert object passed in", op); assertTrue(msg, op.getErrorMessage().length() == 0); }
[ "public", "static", "void", "assertLastOperationSuccess", "(", "String", "msg", ",", "SipActionObject", "op", ")", "{", "assertNotNull", "(", "\"Null assert object passed in\"", ",", "op", ")", ";", "assertTrue", "(", "msg", ",", "op", ".", "getErrorMessage", "(", ")", ".", "length", "(", ")", "==", "0", ")", ";", "}" ]
Asserts that the last SIP operation performed by the given object was successful. Assertion failure output includes the given message text. @param msg message text to output if the assertion fails. @param op the SipUnit object that executed an operation.
[ "Asserts", "that", "the", "last", "SIP", "operation", "performed", "by", "the", "given", "object", "was", "successful", ".", "Assertion", "failure", "output", "includes", "the", "given", "message", "text", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L77-L80
1,930
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertHeaderPresent
public static void assertHeaderPresent(String msg, SipMessage sipMessage, String header) { assertNotNull("Null assert object passed in", sipMessage); assertTrue(msg, sipMessage.getHeaders(header).hasNext()); }
java
public static void assertHeaderPresent(String msg, SipMessage sipMessage, String header) { assertNotNull("Null assert object passed in", sipMessage); assertTrue(msg, sipMessage.getHeaders(header).hasNext()); }
[ "public", "static", "void", "assertHeaderPresent", "(", "String", "msg", ",", "SipMessage", "sipMessage", ",", "String", "header", ")", "{", "assertNotNull", "(", "\"Null assert object passed in\"", ",", "sipMessage", ")", ";", "assertTrue", "(", "msg", ",", "sipMessage", ".", "getHeaders", "(", "header", ")", ".", "hasNext", "(", ")", ")", ";", "}" ]
Asserts that the given SIP message contains at least one occurrence of the specified header. Assertion failure output includes the given message text. @param msg message text to output if the assertion fails. @param sipMessage the SIP message. @param header the string identifying the header as specified in RFC-3261.
[ "Asserts", "that", "the", "given", "SIP", "message", "contains", "at", "least", "one", "occurrence", "of", "the", "specified", "header", ".", "Assertion", "failure", "output", "includes", "the", "given", "message", "text", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L123-L126
1,931
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertHeaderNotPresent
public static void assertHeaderNotPresent(String msg, SipMessage sipMessage, String header) { assertNotNull("Null assert object passed in", sipMessage); assertFalse(msg, sipMessage.getHeaders(header).hasNext()); }
java
public static void assertHeaderNotPresent(String msg, SipMessage sipMessage, String header) { assertNotNull("Null assert object passed in", sipMessage); assertFalse(msg, sipMessage.getHeaders(header).hasNext()); }
[ "public", "static", "void", "assertHeaderNotPresent", "(", "String", "msg", ",", "SipMessage", "sipMessage", ",", "String", "header", ")", "{", "assertNotNull", "(", "\"Null assert object passed in\"", ",", "sipMessage", ")", ";", "assertFalse", "(", "msg", ",", "sipMessage", ".", "getHeaders", "(", "header", ")", ".", "hasNext", "(", ")", ")", ";", "}" ]
Asserts that the given SIP message contains no occurrence of the specified header. Assertion failure output includes the given message text. @param msg message text to output if the assertion fails. @param sipMessage the SIP message. @param header the string identifying the header as specified in RFC-3261.
[ "Asserts", "that", "the", "given", "SIP", "message", "contains", "no", "occurrence", "of", "the", "specified", "header", ".", "Assertion", "failure", "output", "includes", "the", "given", "message", "text", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L146-L149
1,932
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertHeaderContains
public static void assertHeaderContains(SipMessage sipMessage, String header, String value) { assertHeaderContains(null, sipMessage, header, value); // value is case // sensitive? }
java
public static void assertHeaderContains(SipMessage sipMessage, String header, String value) { assertHeaderContains(null, sipMessage, header, value); // value is case // sensitive? }
[ "public", "static", "void", "assertHeaderContains", "(", "SipMessage", "sipMessage", ",", "String", "header", ",", "String", "value", ")", "{", "assertHeaderContains", "(", "null", ",", "sipMessage", ",", "header", ",", "value", ")", ";", "// value is case\r", "// sensitive?\r", "}" ]
Asserts that the given SIP message contains at least one occurrence of the specified header and that at least one occurrence of this header contains the given value. The assertion fails if no occurrence of the header contains the value or if the header is not present in the mesage. @param sipMessage the SIP message. @param header the string identifying the header as specified in RFC-3261. @param value the string value within the header to look for. An exact string match is done against the entire contents of the header. The assertion will pass if any part of the header matches the value given.
[ "Asserts", "that", "the", "given", "SIP", "message", "contains", "at", "least", "one", "occurrence", "of", "the", "specified", "header", "and", "that", "at", "least", "one", "occurrence", "of", "this", "header", "contains", "the", "given", "value", ".", "The", "assertion", "fails", "if", "no", "occurrence", "of", "the", "header", "contains", "the", "value", "or", "if", "the", "header", "is", "not", "present", "in", "the", "mesage", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L162-L165
1,933
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertHeaderContains
public static void assertHeaderContains(String msg, SipMessage sipMessage, String header, String value) { assertNotNull("Null assert object passed in", sipMessage); ListIterator<Header> l = sipMessage.getHeaders(header); while (l.hasNext()) { String h = ((Header) l.next()).toString(); if (h.indexOf(value) != -1) { assertTrue(true); return; } } fail(msg); }
java
public static void assertHeaderContains(String msg, SipMessage sipMessage, String header, String value) { assertNotNull("Null assert object passed in", sipMessage); ListIterator<Header> l = sipMessage.getHeaders(header); while (l.hasNext()) { String h = ((Header) l.next()).toString(); if (h.indexOf(value) != -1) { assertTrue(true); return; } } fail(msg); }
[ "public", "static", "void", "assertHeaderContains", "(", "String", "msg", ",", "SipMessage", "sipMessage", ",", "String", "header", ",", "String", "value", ")", "{", "assertNotNull", "(", "\"Null assert object passed in\"", ",", "sipMessage", ")", ";", "ListIterator", "<", "Header", ">", "l", "=", "sipMessage", ".", "getHeaders", "(", "header", ")", ";", "while", "(", "l", ".", "hasNext", "(", ")", ")", "{", "String", "h", "=", "(", "(", "Header", ")", "l", ".", "next", "(", ")", ")", ".", "toString", "(", ")", ";", "if", "(", "h", ".", "indexOf", "(", "value", ")", "!=", "-", "1", ")", "{", "assertTrue", "(", "true", ")", ";", "return", ";", "}", "}", "fail", "(", "msg", ")", ";", "}" ]
Asserts that the given SIP message contains at least one occurrence of the specified header and that at least one occurrence of this header contains the given value. The assertion fails if no occurrence of the header contains the value or if the header is not present in the mesage. Assertion failure output includes the given message text. @param msg message text to output if the assertion fails. @param sipMessage the SIP message. @param header the string identifying the header as specified in RFC-3261. @param value the string value within the header to look for. An exact string match is done against the entire contents of the header. The assertion will pass if any part of the header matches the value given.
[ "Asserts", "that", "the", "given", "SIP", "message", "contains", "at", "least", "one", "occurrence", "of", "the", "specified", "header", "and", "that", "at", "least", "one", "occurrence", "of", "this", "header", "contains", "the", "given", "value", ".", "The", "assertion", "fails", "if", "no", "occurrence", "of", "the", "header", "contains", "the", "value", "or", "if", "the", "header", "is", "not", "present", "in", "the", "mesage", ".", "Assertion", "failure", "output", "includes", "the", "given", "message", "text", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L180-L194
1,934
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertHeaderNotContains
public static void assertHeaderNotContains(SipMessage sipMessage, String header, String value) { assertHeaderNotContains(null, sipMessage, header, value); }
java
public static void assertHeaderNotContains(SipMessage sipMessage, String header, String value) { assertHeaderNotContains(null, sipMessage, header, value); }
[ "public", "static", "void", "assertHeaderNotContains", "(", "SipMessage", "sipMessage", ",", "String", "header", ",", "String", "value", ")", "{", "assertHeaderNotContains", "(", "null", ",", "sipMessage", ",", "header", ",", "value", ")", ";", "}" ]
Asserts that the given SIP message contains no occurrence of the specified header with the value given, or that there is no occurrence of the header in the message. The assertion fails if any occurrence of the header contains the value. @param sipMessage the SIP message. @param header the string identifying the header as specified in RFC-3261. @param value the string value within the header to look for. An exact string match is done against the entire contents of the header. The assertion will fail if any part of the header matches the value given.
[ "Asserts", "that", "the", "given", "SIP", "message", "contains", "no", "occurrence", "of", "the", "specified", "header", "with", "the", "value", "given", "or", "that", "there", "is", "no", "occurrence", "of", "the", "header", "in", "the", "message", ".", "The", "assertion", "fails", "if", "any", "occurrence", "of", "the", "header", "contains", "the", "value", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L207-L209
1,935
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertResponseReceived
public static void assertResponseReceived(int statusCode, String method, long sequenceNumber, MessageListener obj) { assertResponseReceived(null, statusCode, method, sequenceNumber, obj); }
java
public static void assertResponseReceived(int statusCode, String method, long sequenceNumber, MessageListener obj) { assertResponseReceived(null, statusCode, method, sequenceNumber, obj); }
[ "public", "static", "void", "assertResponseReceived", "(", "int", "statusCode", ",", "String", "method", ",", "long", "sequenceNumber", ",", "MessageListener", "obj", ")", "{", "assertResponseReceived", "(", "null", ",", "statusCode", ",", "method", ",", "sequenceNumber", ",", "obj", ")", ";", "}" ]
Asserts that the given message listener object received a response with the indicated status code, CSeq method and CSeq sequence number. @param statusCode The response status code to check for (eg, SipResponse.RINGING) @param method The CSeq method to look for (SipRequest.INVITE, etc.) @param sequenceNumber The CSeq sequence number to look for @param obj The MessageListener object (ie, SipCall, Subscription, etc.).
[ "Asserts", "that", "the", "given", "message", "listener", "object", "received", "a", "response", "with", "the", "indicated", "status", "code", "CSeq", "method", "and", "CSeq", "sequence", "number", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L259-L262
1,936
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertResponseReceived
public static void assertResponseReceived(String msg, int statusCode, MessageListener obj) { assertNotNull("Null assert object passed in", obj); assertTrue(msg, responseReceived(statusCode, obj)); }
java
public static void assertResponseReceived(String msg, int statusCode, MessageListener obj) { assertNotNull("Null assert object passed in", obj); assertTrue(msg, responseReceived(statusCode, obj)); }
[ "public", "static", "void", "assertResponseReceived", "(", "String", "msg", ",", "int", "statusCode", ",", "MessageListener", "obj", ")", "{", "assertNotNull", "(", "\"Null assert object passed in\"", ",", "obj", ")", ";", "assertTrue", "(", "msg", ",", "responseReceived", "(", "statusCode", ",", "obj", ")", ")", ";", "}" ]
Asserts that the given message listener object received a response with the indicated status code. Assertion failure output includes the given message text. @param msg message text to output if the assertion fails. @param statusCode The response status code to check for (eg, SipResponse.RINGING) @param obj The MessageListener object (ie, SipCall, Subscription, etc.).
[ "Asserts", "that", "the", "given", "message", "listener", "object", "received", "a", "response", "with", "the", "indicated", "status", "code", ".", "Assertion", "failure", "output", "includes", "the", "given", "message", "text", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L272-L275
1,937
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.responseReceived
public static boolean responseReceived(int statusCode, MessageListener messageListener) { ArrayList<SipResponse> responses = messageListener.getAllReceivedResponses(); for (SipResponse r : responses) { if (statusCode == r.getStatusCode()) { return true; } } return false; }
java
public static boolean responseReceived(int statusCode, MessageListener messageListener) { ArrayList<SipResponse> responses = messageListener.getAllReceivedResponses(); for (SipResponse r : responses) { if (statusCode == r.getStatusCode()) { return true; } } return false; }
[ "public", "static", "boolean", "responseReceived", "(", "int", "statusCode", ",", "MessageListener", "messageListener", ")", "{", "ArrayList", "<", "SipResponse", ">", "responses", "=", "messageListener", ".", "getAllReceivedResponses", "(", ")", ";", "for", "(", "SipResponse", "r", ":", "responses", ")", "{", "if", "(", "statusCode", "==", "r", ".", "getStatusCode", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check the given message listener object received a response with the indicated status code. @param statusCode the code we want to find @param messageListener the {@link MessageListener} we want to check @return true if a received response matches the given statusCode
[ "Check", "the", "given", "message", "listener", "object", "received", "a", "response", "with", "the", "indicated", "status", "code", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L303-L313
1,938
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertResponseNotReceived
public static void assertResponseNotReceived(int statusCode, String method, long sequenceNumber, MessageListener obj) { assertResponseNotReceived(null, statusCode, method, sequenceNumber, obj); }
java
public static void assertResponseNotReceived(int statusCode, String method, long sequenceNumber, MessageListener obj) { assertResponseNotReceived(null, statusCode, method, sequenceNumber, obj); }
[ "public", "static", "void", "assertResponseNotReceived", "(", "int", "statusCode", ",", "String", "method", ",", "long", "sequenceNumber", ",", "MessageListener", "obj", ")", "{", "assertResponseNotReceived", "(", "null", ",", "statusCode", ",", "method", ",", "sequenceNumber", ",", "obj", ")", ";", "}" ]
Asserts that the given message listener object has not received a response with the indicated status code, CSeq method and sequence number. @param statusCode The response status code to verify absent (eg, SipResponse.RINGING) @param method The CSeq method to verify absent (SipRequest.INVITE, etc.) @param sequenceNumber The CSeq sequence number to verify absent @param obj The MessageListener object (ie, SipCall, Subscription, etc.).
[ "Asserts", "that", "the", "given", "message", "listener", "object", "has", "not", "received", "a", "response", "with", "the", "indicated", "status", "code", "CSeq", "method", "and", "sequence", "number", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L389-L392
1,939
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertResponseNotReceived
public static void assertResponseNotReceived(String msg, int statusCode, String method, long sequenceNumber, MessageListener obj) { assertNotNull("Null assert object passed in", obj); assertFalse(msg, responseReceived(statusCode, method, sequenceNumber, obj)); }
java
public static void assertResponseNotReceived(String msg, int statusCode, String method, long sequenceNumber, MessageListener obj) { assertNotNull("Null assert object passed in", obj); assertFalse(msg, responseReceived(statusCode, method, sequenceNumber, obj)); }
[ "public", "static", "void", "assertResponseNotReceived", "(", "String", "msg", ",", "int", "statusCode", ",", "String", "method", ",", "long", "sequenceNumber", ",", "MessageListener", "obj", ")", "{", "assertNotNull", "(", "\"Null assert object passed in\"", ",", "obj", ")", ";", "assertFalse", "(", "msg", ",", "responseReceived", "(", "statusCode", ",", "method", ",", "sequenceNumber", ",", "obj", ")", ")", ";", "}" ]
Asserts that the given message listener object has not received a response with the indicated status code, CSeq method and sequence number. Assertion failure output includes the given message text. @param msg message text to output if the assertion fails. @param statusCode The response status code to verify absent (eg, SipResponse.RINGING) @param method The CSeq method to verify absent (SipRequest.INVITE, etc.) @param sequenceNumber The CSeq sequence number to verify absent @param obj The MessageListener object (ie, SipCall, Subscription, etc.).
[ "Asserts", "that", "the", "given", "message", "listener", "object", "has", "not", "received", "a", "response", "with", "the", "indicated", "status", "code", "CSeq", "method", "and", "sequence", "number", ".", "Assertion", "failure", "output", "includes", "the", "given", "message", "text", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L405-L409
1,940
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertRequestReceived
public static void assertRequestReceived(String method, long sequenceNumber, MessageListener obj) { assertRequestReceived(null, method, sequenceNumber, obj); }
java
public static void assertRequestReceived(String method, long sequenceNumber, MessageListener obj) { assertRequestReceived(null, method, sequenceNumber, obj); }
[ "public", "static", "void", "assertRequestReceived", "(", "String", "method", ",", "long", "sequenceNumber", ",", "MessageListener", "obj", ")", "{", "assertRequestReceived", "(", "null", ",", "method", ",", "sequenceNumber", ",", "obj", ")", ";", "}" ]
Asserts that the given message listener object received a request with the indicated CSeq method and CSeq sequence number. @param method The CSeq method to look for (SipRequest.REGISTER, etc.) @param sequenceNumber The CSeq sequence number to look for @param obj The MessageListener object (ie, SipCall, Subscription, etc.).
[ "Asserts", "that", "the", "given", "message", "listener", "object", "received", "a", "request", "with", "the", "indicated", "CSeq", "method", "and", "CSeq", "sequence", "number", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L430-L432
1,941
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertRequestReceived
public static void assertRequestReceived(String msg, String method, MessageListener obj) { assertNotNull("Null assert object passed in", obj); assertTrue(msg, requestReceived(method, obj)); }
java
public static void assertRequestReceived(String msg, String method, MessageListener obj) { assertNotNull("Null assert object passed in", obj); assertTrue(msg, requestReceived(method, obj)); }
[ "public", "static", "void", "assertRequestReceived", "(", "String", "msg", ",", "String", "method", ",", "MessageListener", "obj", ")", "{", "assertNotNull", "(", "\"Null assert object passed in\"", ",", "obj", ")", ";", "assertTrue", "(", "msg", ",", "requestReceived", "(", "method", ",", "obj", ")", ")", ";", "}" ]
Asserts that the given message listener object received a request with the indicated request method. Assertion failure output includes the given message text. @param msg message text to output if the assertion fails. @param method The request method to check for (eg, SipRequest.INVITE) @param obj The MessageListener object (ie, SipCall, Subscription, etc.).
[ "Asserts", "that", "the", "given", "message", "listener", "object", "received", "a", "request", "with", "the", "indicated", "request", "method", ".", "Assertion", "failure", "output", "includes", "the", "given", "message", "text", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L442-L445
1,942
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertRequestNotReceived
public static void assertRequestNotReceived(String msg, String method, MessageListener obj) { assertNotNull("Null assert object passed in", obj); assertFalse(msg, requestReceived(method, obj)); }
java
public static void assertRequestNotReceived(String msg, String method, MessageListener obj) { assertNotNull("Null assert object passed in", obj); assertFalse(msg, requestReceived(method, obj)); }
[ "public", "static", "void", "assertRequestNotReceived", "(", "String", "msg", ",", "String", "method", ",", "MessageListener", "obj", ")", "{", "assertNotNull", "(", "\"Null assert object passed in\"", ",", "obj", ")", ";", "assertFalse", "(", "msg", ",", "requestReceived", "(", "method", ",", "obj", ")", ")", ";", "}" ]
Asserts that the given message listener object has not received a request with the indicated request method. Assertion failure output includes the given message text. @param msg message text to output if the assertion fails. @param method The request method to verify absent (eg, SipRequest.BYE) @param obj The MessageListener object (ie, SipCall, Subscription, etc.).
[ "Asserts", "that", "the", "given", "message", "listener", "object", "has", "not", "received", "a", "request", "with", "the", "indicated", "request", "method", ".", "Assertion", "failure", "output", "includes", "the", "given", "message", "text", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L519-L522
1,943
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertRequestNotReceived
public static void assertRequestNotReceived(String method, long sequenceNumber, MessageListener obj) { assertRequestNotReceived(null, method, sequenceNumber, obj); }
java
public static void assertRequestNotReceived(String method, long sequenceNumber, MessageListener obj) { assertRequestNotReceived(null, method, sequenceNumber, obj); }
[ "public", "static", "void", "assertRequestNotReceived", "(", "String", "method", ",", "long", "sequenceNumber", ",", "MessageListener", "obj", ")", "{", "assertRequestNotReceived", "(", "null", ",", "method", ",", "sequenceNumber", ",", "obj", ")", ";", "}" ]
Asserts that the given message listener object has not received a request with the indicated CSeq method and sequence number. @param method The CSeq method to verify absent (SipRequest.INVITE, etc.) @param sequenceNumber The CSeq sequence number to verify absent @param obj The MessageListener object (ie, SipCall, Subscription, etc.).
[ "Asserts", "that", "the", "given", "message", "listener", "object", "has", "not", "received", "a", "request", "with", "the", "indicated", "CSeq", "method", "and", "sequence", "number", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L533-L536
1,944
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertAnswered
public static void assertAnswered(String msg, SipCall call) { assertNotNull("Null assert object passed in", call); assertTrue(msg, call.isCallAnswered()); }
java
public static void assertAnswered(String msg, SipCall call) { assertNotNull("Null assert object passed in", call); assertTrue(msg, call.isCallAnswered()); }
[ "public", "static", "void", "assertAnswered", "(", "String", "msg", ",", "SipCall", "call", ")", "{", "assertNotNull", "(", "\"Null assert object passed in\"", ",", "call", ")", ";", "assertTrue", "(", "msg", ",", "call", ".", "isCallAnswered", "(", ")", ")", ";", "}" ]
Asserts that the given incoming or outgoing call leg was answered. Assertion failure output includes the given message text. @param msg message text to output if the assertion fails. @param call The incoming or outgoing call leg.
[ "Asserts", "that", "the", "given", "incoming", "or", "outgoing", "call", "leg", "was", "answered", ".", "Assertion", "failure", "output", "includes", "the", "given", "message", "text", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L569-L572
1,945
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.awaitAnswered
public static void awaitAnswered(final String msg, final SipCall call) { await().until(new Runnable() { @Override public void run() { assertAnswered(msg, call); } }); }
java
public static void awaitAnswered(final String msg, final SipCall call) { await().until(new Runnable() { @Override public void run() { assertAnswered(msg, call); } }); }
[ "public", "static", "void", "awaitAnswered", "(", "final", "String", "msg", ",", "final", "SipCall", "call", ")", "{", "await", "(", ")", ".", "until", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "assertAnswered", "(", "msg", ",", "call", ")", ";", "}", "}", ")", ";", "}" ]
Awaits that the given incoming or outgoing call leg was answered. Assertion failure output includes the given message text. @param msg message text to output if the assertion fails. @param call The incoming or outgoing call leg.
[ "Awaits", "that", "the", "given", "incoming", "or", "outgoing", "call", "leg", "was", "answered", ".", "Assertion", "failure", "output", "includes", "the", "given", "message", "text", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L591-L599
1,946
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertNotAnswered
public static void assertNotAnswered(String msg, SipCall call) { assertNotNull("Null assert object passed in", call); assertFalse(msg, call.isCallAnswered()); }
java
public static void assertNotAnswered(String msg, SipCall call) { assertNotNull("Null assert object passed in", call); assertFalse(msg, call.isCallAnswered()); }
[ "public", "static", "void", "assertNotAnswered", "(", "String", "msg", ",", "SipCall", "call", ")", "{", "assertNotNull", "(", "\"Null assert object passed in\"", ",", "call", ")", ";", "assertFalse", "(", "msg", ",", "call", ".", "isCallAnswered", "(", ")", ")", ";", "}" ]
Asserts that the given incoming or outgoing call leg has not been answered. Assertion failure output includes the given message text. @param msg message text to output if the assertion fails. @param call The incoming or outgoing call leg.
[ "Asserts", "that", "the", "given", "incoming", "or", "outgoing", "call", "leg", "has", "not", "been", "answered", ".", "Assertion", "failure", "output", "includes", "the", "given", "message", "text", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L627-L630
1,947
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertBodyPresent
public static void assertBodyPresent(String msg, SipMessage sipMessage) { assertNotNull("Null assert object passed in", sipMessage); assertTrue(msg, sipMessage.getContentLength() > 0); }
java
public static void assertBodyPresent(String msg, SipMessage sipMessage) { assertNotNull("Null assert object passed in", sipMessage); assertTrue(msg, sipMessage.getContentLength() > 0); }
[ "public", "static", "void", "assertBodyPresent", "(", "String", "msg", ",", "SipMessage", "sipMessage", ")", "{", "assertNotNull", "(", "\"Null assert object passed in\"", ",", "sipMessage", ")", ";", "assertTrue", "(", "msg", ",", "sipMessage", ".", "getContentLength", "(", ")", ">", "0", ")", ";", "}" ]
Asserts that the given SIP message contains a body. Assertion failure output includes the given message text. @param msg message text to output if the assertion fails. @param sipMessage the SIP message.
[ "Asserts", "that", "the", "given", "SIP", "message", "contains", "a", "body", ".", "Assertion", "failure", "output", "includes", "the", "given", "message", "text", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L648-L651
1,948
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertBodyNotPresent
public static void assertBodyNotPresent(String msg, SipMessage sipMessage) { assertNotNull("Null assert object passed in", sipMessage); assertFalse(msg, sipMessage.getContentLength() > 0); }
java
public static void assertBodyNotPresent(String msg, SipMessage sipMessage) { assertNotNull("Null assert object passed in", sipMessage); assertFalse(msg, sipMessage.getContentLength() > 0); }
[ "public", "static", "void", "assertBodyNotPresent", "(", "String", "msg", ",", "SipMessage", "sipMessage", ")", "{", "assertNotNull", "(", "\"Null assert object passed in\"", ",", "sipMessage", ")", ";", "assertFalse", "(", "msg", ",", "sipMessage", ".", "getContentLength", "(", ")", ">", "0", ")", ";", "}" ]
Asserts that the given SIP message contains no body. Assertion failure output includes the given message text. @param msg message text to output if the assertion fails. @param sipMessage the SIP message.
[ "Asserts", "that", "the", "given", "SIP", "message", "contains", "no", "body", ".", "Assertion", "failure", "output", "includes", "the", "given", "message", "text", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L669-L672
1,949
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertBodyContains
public static void assertBodyContains(String msg, SipMessage sipMessage, String value) { assertNotNull("Null assert object passed in", sipMessage); assertBodyPresent(msg, sipMessage); String body = new String(sipMessage.getRawContent()); if (body.indexOf(value) != -1) { assertTrue(true); return; } fail(msg); }
java
public static void assertBodyContains(String msg, SipMessage sipMessage, String value) { assertNotNull("Null assert object passed in", sipMessage); assertBodyPresent(msg, sipMessage); String body = new String(sipMessage.getRawContent()); if (body.indexOf(value) != -1) { assertTrue(true); return; } fail(msg); }
[ "public", "static", "void", "assertBodyContains", "(", "String", "msg", ",", "SipMessage", "sipMessage", ",", "String", "value", ")", "{", "assertNotNull", "(", "\"Null assert object passed in\"", ",", "sipMessage", ")", ";", "assertBodyPresent", "(", "msg", ",", "sipMessage", ")", ";", "String", "body", "=", "new", "String", "(", "sipMessage", ".", "getRawContent", "(", ")", ")", ";", "if", "(", "body", ".", "indexOf", "(", "value", ")", "!=", "-", "1", ")", "{", "assertTrue", "(", "true", ")", ";", "return", ";", "}", "fail", "(", "msg", ")", ";", "}" ]
Asserts that the given SIP message contains a body that includes the given value. The assertion fails if a body is not present in the message or is present but doesn't include the value. Assertion failure output includes the given message text. @param msg message text to output if the assertion fails. @param sipMessage the SIP message. @param value the string value to look for in the body. An exact string match is done against the entire contents of the body. The assertion will pass if any part of the body matches the value given.
[ "Asserts", "that", "the", "given", "SIP", "message", "contains", "a", "body", "that", "includes", "the", "given", "value", ".", "The", "assertion", "fails", "if", "a", "body", "is", "not", "present", "in", "the", "message", "or", "is", "present", "but", "doesn", "t", "include", "the", "value", ".", "Assertion", "failure", "output", "includes", "the", "given", "message", "text", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L698-L709
1,950
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipAssert.java
SipAssert.assertBodyNotContains
public static void assertBodyNotContains(String msg, SipMessage sipMessage, String value) { assertNotNull("Null assert object passed in", sipMessage); if (sipMessage.getContentLength() > 0) { String body = new String(sipMessage.getRawContent()); if (body.indexOf(value) != -1) { fail(msg); } } assertTrue(true); }
java
public static void assertBodyNotContains(String msg, SipMessage sipMessage, String value) { assertNotNull("Null assert object passed in", sipMessage); if (sipMessage.getContentLength() > 0) { String body = new String(sipMessage.getRawContent()); if (body.indexOf(value) != -1) { fail(msg); } } assertTrue(true); }
[ "public", "static", "void", "assertBodyNotContains", "(", "String", "msg", ",", "SipMessage", "sipMessage", ",", "String", "value", ")", "{", "assertNotNull", "(", "\"Null assert object passed in\"", ",", "sipMessage", ")", ";", "if", "(", "sipMessage", ".", "getContentLength", "(", ")", ">", "0", ")", "{", "String", "body", "=", "new", "String", "(", "sipMessage", ".", "getRawContent", "(", ")", ")", ";", "if", "(", "body", ".", "indexOf", "(", "value", ")", "!=", "-", "1", ")", "{", "fail", "(", "msg", ")", ";", "}", "}", "assertTrue", "(", "true", ")", ";", "}" ]
Asserts that the body in the given SIP message does not contain the value given, or that there is no body in the message. The assertion fails if the body is present and contains the value. Assertion failure output includes the given message text. @param msg message text to output if the assertion fails. @param sipMessage the SIP message. @param value the string value to look for in the body. An exact string match is done against the entire contents of the body. The assertion will fail if any part of the body matches the value given.
[ "Asserts", "that", "the", "body", "in", "the", "given", "SIP", "message", "does", "not", "contain", "the", "value", "given", "or", "that", "there", "is", "no", "body", "in", "the", "message", ".", "The", "assertion", "fails", "if", "the", "body", "is", "present", "and", "contains", "the", "value", ".", "Assertion", "failure", "output", "includes", "the", "given", "message", "text", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipAssert.java#L735-L746
1,951
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipStack.java
SipStack.dumpMessage
public static void dumpMessage(String informationalHeader, javax.sip.message.Message msg) { LOG.trace(informationalHeader + "{}.......... \n {}", informationalHeader, msg); ListIterator rhdrs = msg.getHeaders(RouteHeader.NAME); while (rhdrs.hasNext()) { RouteHeader rhdr = (RouteHeader) rhdrs.next(); if (rhdr != null) { LOG.trace("RouteHeader address: {}", rhdr.getAddress().toString()); Iterator i = rhdr.getParameterNames(); while (i.hasNext()) { String parm = (String) i.next(); LOG.trace("RouteHeader parameter {}: {}", parm, rhdr.getParameter(parm)); } } } ListIterator rrhdrs = msg.getHeaders(RecordRouteHeader.NAME); while (rrhdrs.hasNext()) { RecordRouteHeader rrhdr = (RecordRouteHeader) rrhdrs.next(); if (rrhdr != null) { LOG.trace("RecordRouteHeader address: {}", rrhdr.getAddress()); Iterator i = rrhdr.getParameterNames(); while (i.hasNext()) { String parm = (String) i.next(); LOG.trace("RecordRouteHeader parameter {}: {}", parm, rrhdr.getParameter(parm)); } } } }
java
public static void dumpMessage(String informationalHeader, javax.sip.message.Message msg) { LOG.trace(informationalHeader + "{}.......... \n {}", informationalHeader, msg); ListIterator rhdrs = msg.getHeaders(RouteHeader.NAME); while (rhdrs.hasNext()) { RouteHeader rhdr = (RouteHeader) rhdrs.next(); if (rhdr != null) { LOG.trace("RouteHeader address: {}", rhdr.getAddress().toString()); Iterator i = rhdr.getParameterNames(); while (i.hasNext()) { String parm = (String) i.next(); LOG.trace("RouteHeader parameter {}: {}", parm, rhdr.getParameter(parm)); } } } ListIterator rrhdrs = msg.getHeaders(RecordRouteHeader.NAME); while (rrhdrs.hasNext()) { RecordRouteHeader rrhdr = (RecordRouteHeader) rrhdrs.next(); if (rrhdr != null) { LOG.trace("RecordRouteHeader address: {}", rrhdr.getAddress()); Iterator i = rrhdr.getParameterNames(); while (i.hasNext()) { String parm = (String) i.next(); LOG.trace("RecordRouteHeader parameter {}: {}", parm, rrhdr.getParameter(parm)); } } } }
[ "public", "static", "void", "dumpMessage", "(", "String", "informationalHeader", ",", "javax", ".", "sip", ".", "message", ".", "Message", "msg", ")", "{", "LOG", ".", "trace", "(", "informationalHeader", "+", "\"{}.......... \\n {}\"", ",", "informationalHeader", ",", "msg", ")", ";", "ListIterator", "rhdrs", "=", "msg", ".", "getHeaders", "(", "RouteHeader", ".", "NAME", ")", ";", "while", "(", "rhdrs", ".", "hasNext", "(", ")", ")", "{", "RouteHeader", "rhdr", "=", "(", "RouteHeader", ")", "rhdrs", ".", "next", "(", ")", ";", "if", "(", "rhdr", "!=", "null", ")", "{", "LOG", ".", "trace", "(", "\"RouteHeader address: {}\"", ",", "rhdr", ".", "getAddress", "(", ")", ".", "toString", "(", ")", ")", ";", "Iterator", "i", "=", "rhdr", ".", "getParameterNames", "(", ")", ";", "while", "(", "i", ".", "hasNext", "(", ")", ")", "{", "String", "parm", "=", "(", "String", ")", "i", ".", "next", "(", ")", ";", "LOG", ".", "trace", "(", "\"RouteHeader parameter {}: {}\"", ",", "parm", ",", "rhdr", ".", "getParameter", "(", "parm", ")", ")", ";", "}", "}", "}", "ListIterator", "rrhdrs", "=", "msg", ".", "getHeaders", "(", "RecordRouteHeader", ".", "NAME", ")", ";", "while", "(", "rrhdrs", ".", "hasNext", "(", ")", ")", "{", "RecordRouteHeader", "rrhdr", "=", "(", "RecordRouteHeader", ")", "rrhdrs", ".", "next", "(", ")", ";", "if", "(", "rrhdr", "!=", "null", ")", "{", "LOG", ".", "trace", "(", "\"RecordRouteHeader address: {}\"", ",", "rrhdr", ".", "getAddress", "(", ")", ")", ";", "Iterator", "i", "=", "rrhdr", ".", "getParameterNames", "(", ")", ";", "while", "(", "i", ".", "hasNext", "(", ")", ")", "{", "String", "parm", "=", "(", "String", ")", "i", ".", "next", "(", ")", ";", "LOG", ".", "trace", "(", "\"RecordRouteHeader parameter {}: {}\"", ",", "parm", ",", "rrhdr", ".", "getParameter", "(", "parm", ")", ")", ";", "}", "}", "}", "}" ]
Outputs to console the provided header string followed by the message. @param informationalHeader @param msg
[ "Outputs", "to", "console", "the", "provided", "header", "string", "followed", "by", "the", "message", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipStack.java#L452-L482
1,952
RestComm/sipunit
src/main/java/org/cafesip/sipunit/EventSubscriber.java
EventSubscriber.createNotifyResponse
protected Response createNotifyResponse(RequestEvent request, int status, String reason, List<Header> additionalHeaders) { // when used internally - WATCH OUT - retcode, errorMessage initialized here initErrorInfo(); if ((request == null) || (request.getRequest() == null)) { setReturnCode(SipSession.INVALID_ARGUMENT); setErrorMessage("Null request given for creating NOTIFY response"); return null; } Request req = request.getRequest(); String cseqStr = "CSEQ " + ((CSeqHeader) req.getHeader(CSeqHeader.NAME)).getSeqNumber(); LOG.trace("Creating NOTIFY {} response with status code {}, reason phrase = {}", cseqStr, status, reason); try { Response response = parent.getMessageFactory().createResponse(status, req); if (reason != null) { response.setReasonPhrase(reason); } ((ToHeader) response.getHeader(ToHeader.NAME)).setTag(myTag); response.addHeader((ContactHeader) parent.getContactInfo().getContactHeader().clone()); if (additionalHeaders != null) { Iterator<Header> i = additionalHeaders.iterator(); while (i.hasNext()) { response.addHeader(i.next()); } } return response; } catch (Exception e) { setReturnCode(SipSession.EXCEPTION_ENCOUNTERED); setException(e); setErrorMessage("Exception: " + e.getClass().getName() + ": " + e.getMessage()); } return null; }
java
protected Response createNotifyResponse(RequestEvent request, int status, String reason, List<Header> additionalHeaders) { // when used internally - WATCH OUT - retcode, errorMessage initialized here initErrorInfo(); if ((request == null) || (request.getRequest() == null)) { setReturnCode(SipSession.INVALID_ARGUMENT); setErrorMessage("Null request given for creating NOTIFY response"); return null; } Request req = request.getRequest(); String cseqStr = "CSEQ " + ((CSeqHeader) req.getHeader(CSeqHeader.NAME)).getSeqNumber(); LOG.trace("Creating NOTIFY {} response with status code {}, reason phrase = {}", cseqStr, status, reason); try { Response response = parent.getMessageFactory().createResponse(status, req); if (reason != null) { response.setReasonPhrase(reason); } ((ToHeader) response.getHeader(ToHeader.NAME)).setTag(myTag); response.addHeader((ContactHeader) parent.getContactInfo().getContactHeader().clone()); if (additionalHeaders != null) { Iterator<Header> i = additionalHeaders.iterator(); while (i.hasNext()) { response.addHeader(i.next()); } } return response; } catch (Exception e) { setReturnCode(SipSession.EXCEPTION_ENCOUNTERED); setException(e); setErrorMessage("Exception: " + e.getClass().getName() + ": " + e.getMessage()); } return null; }
[ "protected", "Response", "createNotifyResponse", "(", "RequestEvent", "request", ",", "int", "status", ",", "String", "reason", ",", "List", "<", "Header", ">", "additionalHeaders", ")", "{", "// when used internally - WATCH OUT - retcode, errorMessage initialized here", "initErrorInfo", "(", ")", ";", "if", "(", "(", "request", "==", "null", ")", "||", "(", "request", ".", "getRequest", "(", ")", "==", "null", ")", ")", "{", "setReturnCode", "(", "SipSession", ".", "INVALID_ARGUMENT", ")", ";", "setErrorMessage", "(", "\"Null request given for creating NOTIFY response\"", ")", ";", "return", "null", ";", "}", "Request", "req", "=", "request", ".", "getRequest", "(", ")", ";", "String", "cseqStr", "=", "\"CSEQ \"", "+", "(", "(", "CSeqHeader", ")", "req", ".", "getHeader", "(", "CSeqHeader", ".", "NAME", ")", ")", ".", "getSeqNumber", "(", ")", ";", "LOG", ".", "trace", "(", "\"Creating NOTIFY {} response with status code {}, reason phrase = {}\"", ",", "cseqStr", ",", "status", ",", "reason", ")", ";", "try", "{", "Response", "response", "=", "parent", ".", "getMessageFactory", "(", ")", ".", "createResponse", "(", "status", ",", "req", ")", ";", "if", "(", "reason", "!=", "null", ")", "{", "response", ".", "setReasonPhrase", "(", "reason", ")", ";", "}", "(", "(", "ToHeader", ")", "response", ".", "getHeader", "(", "ToHeader", ".", "NAME", ")", ")", ".", "setTag", "(", "myTag", ")", ";", "response", ".", "addHeader", "(", "(", "ContactHeader", ")", "parent", ".", "getContactInfo", "(", ")", ".", "getContactHeader", "(", ")", ".", "clone", "(", ")", ")", ";", "if", "(", "additionalHeaders", "!=", "null", ")", "{", "Iterator", "<", "Header", ">", "i", "=", "additionalHeaders", ".", "iterator", "(", ")", ";", "while", "(", "i", ".", "hasNext", "(", ")", ")", "{", "response", ".", "addHeader", "(", "i", ".", "next", "(", ")", ")", ";", "}", "}", "return", "response", ";", "}", "catch", "(", "Exception", "e", ")", "{", "setReturnCode", "(", "SipSession", ".", "EXCEPTION_ENCOUNTERED", ")", ";", "setException", "(", "e", ")", ";", "setErrorMessage", "(", "\"Exception: \"", "+", "e", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\": \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "return", "null", ";", "}" ]
if returns null, returnCode and errorMessage already set
[ "if", "returns", "null", "returnCode", "and", "errorMessage", "already", "set" ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/EventSubscriber.java#L1398-L1440
1,953
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipPhone.java
SipPhone.unregister
public boolean unregister(String contact, long timeout) { initErrorInfo(); // TODO - need to support multiple server(s)/registrations // simultaneously? // then return registration() object to user (w/lastregrequest) and // receive // it here, get rid of lastRegistrationRequest if (lastRegistrationRequest == null) { return true; } Request msg = (Request) lastRegistrationRequest.clone(); try { ExpiresHeader expires = parent.getHeaderFactory().createExpiresHeader(0); msg.setExpires(expires); cseq.setSeqNumber(cseq.getSeqNumber() + 1); cseq.setMethod(Request.REGISTER); msg.setHeader(cseq); // set contact header if (contact != null) { ContactHeader contact_hdr; if (!contact.equals("*")) { URI contact_uri = parent.getAddressFactory().createURI(contact); Address contact_address = parent.getAddressFactory().createAddress(contact_uri); contact_hdr = parent.getHeaderFactory().createContactHeader(contact_address); } else { contact_hdr = parent.getHeaderFactory().createContactHeader(); } msg.setHeader(contact_hdr); } // send the REGISTRATION request and get the response Response response = sendRegistrationMessage(msg, null, null, 30000); if (response == null) { return false; } // clear out authorizations accumulated for this Call-ID clearAuthorizations(myRegistrationId); // should we drop any calls in progress? lastRegistrationRequest = null; return true; } catch (Exception ex) { setReturnCode(EXCEPTION_ENCOUNTERED); setErrorMessage("Exception: " + ex.getClass().getName() + ": " + ex.getMessage()); return false; } }
java
public boolean unregister(String contact, long timeout) { initErrorInfo(); // TODO - need to support multiple server(s)/registrations // simultaneously? // then return registration() object to user (w/lastregrequest) and // receive // it here, get rid of lastRegistrationRequest if (lastRegistrationRequest == null) { return true; } Request msg = (Request) lastRegistrationRequest.clone(); try { ExpiresHeader expires = parent.getHeaderFactory().createExpiresHeader(0); msg.setExpires(expires); cseq.setSeqNumber(cseq.getSeqNumber() + 1); cseq.setMethod(Request.REGISTER); msg.setHeader(cseq); // set contact header if (contact != null) { ContactHeader contact_hdr; if (!contact.equals("*")) { URI contact_uri = parent.getAddressFactory().createURI(contact); Address contact_address = parent.getAddressFactory().createAddress(contact_uri); contact_hdr = parent.getHeaderFactory().createContactHeader(contact_address); } else { contact_hdr = parent.getHeaderFactory().createContactHeader(); } msg.setHeader(contact_hdr); } // send the REGISTRATION request and get the response Response response = sendRegistrationMessage(msg, null, null, 30000); if (response == null) { return false; } // clear out authorizations accumulated for this Call-ID clearAuthorizations(myRegistrationId); // should we drop any calls in progress? lastRegistrationRequest = null; return true; } catch (Exception ex) { setReturnCode(EXCEPTION_ENCOUNTERED); setErrorMessage("Exception: " + ex.getClass().getName() + ": " + ex.getMessage()); return false; } }
[ "public", "boolean", "unregister", "(", "String", "contact", ",", "long", "timeout", ")", "{", "initErrorInfo", "(", ")", ";", "// TODO - need to support multiple server(s)/registrations", "// simultaneously?", "// then return registration() object to user (w/lastregrequest) and", "// receive", "// it here, get rid of lastRegistrationRequest", "if", "(", "lastRegistrationRequest", "==", "null", ")", "{", "return", "true", ";", "}", "Request", "msg", "=", "(", "Request", ")", "lastRegistrationRequest", ".", "clone", "(", ")", ";", "try", "{", "ExpiresHeader", "expires", "=", "parent", ".", "getHeaderFactory", "(", ")", ".", "createExpiresHeader", "(", "0", ")", ";", "msg", ".", "setExpires", "(", "expires", ")", ";", "cseq", ".", "setSeqNumber", "(", "cseq", ".", "getSeqNumber", "(", ")", "+", "1", ")", ";", "cseq", ".", "setMethod", "(", "Request", ".", "REGISTER", ")", ";", "msg", ".", "setHeader", "(", "cseq", ")", ";", "// set contact header", "if", "(", "contact", "!=", "null", ")", "{", "ContactHeader", "contact_hdr", ";", "if", "(", "!", "contact", ".", "equals", "(", "\"*\"", ")", ")", "{", "URI", "contact_uri", "=", "parent", ".", "getAddressFactory", "(", ")", ".", "createURI", "(", "contact", ")", ";", "Address", "contact_address", "=", "parent", ".", "getAddressFactory", "(", ")", ".", "createAddress", "(", "contact_uri", ")", ";", "contact_hdr", "=", "parent", ".", "getHeaderFactory", "(", ")", ".", "createContactHeader", "(", "contact_address", ")", ";", "}", "else", "{", "contact_hdr", "=", "parent", ".", "getHeaderFactory", "(", ")", ".", "createContactHeader", "(", ")", ";", "}", "msg", ".", "setHeader", "(", "contact_hdr", ")", ";", "}", "// send the REGISTRATION request and get the response", "Response", "response", "=", "sendRegistrationMessage", "(", "msg", ",", "null", ",", "null", ",", "30000", ")", ";", "if", "(", "response", "==", "null", ")", "{", "return", "false", ";", "}", "// clear out authorizations accumulated for this Call-ID", "clearAuthorizations", "(", "myRegistrationId", ")", ";", "// should we drop any calls in progress?", "lastRegistrationRequest", "=", "null", ";", "return", "true", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "setReturnCode", "(", "EXCEPTION_ENCOUNTERED", ")", ";", "setErrorMessage", "(", "\"Exception: \"", "+", "ex", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\": \"", "+", "ex", ".", "getMessage", "(", ")", ")", ";", "return", "false", ";", "}", "}" ]
This method performs the SIP unregistration process. It returns true if unregistration was successful or no unregistration was needed, and false otherwise. Any authorization headers required for the last registration are cleared out. If there was no previous registration, this method does not send any messages. <p> If the contact parameter is null, user@hostname is unregistered where hostname is obtained by calling InetAddr.getLocalHost(). Otherwise, the contact parameter value is used in the unregistration message sent to the server. @param contact The contact URI (ex: sip:[email protected]) to unregister or "*". @param timeout The maximum amount of time to wait for a response, in milliseconds. Use a value of 0 to wait indefinitely. @return true if the unregistration succeeded or no unregistration was needed, false otherwise.
[ "This", "method", "performs", "the", "SIP", "unregistration", "process", ".", "It", "returns", "true", "if", "unregistration", "was", "successful", "or", "no", "unregistration", "was", "needed", "and", "false", "otherwise", ".", "Any", "authorization", "headers", "required", "for", "the", "last", "registration", "are", "cleared", "out", ".", "If", "there", "was", "no", "previous", "registration", "this", "method", "does", "not", "send", "any", "messages", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipPhone.java#L384-L443
1,954
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipPhone.java
SipPhone.createSipCall
public SipCall createSipCall() { initErrorInfo(); SipCall call = new SipCall(this, myAddress); callList.add(call); return call; }
java
public SipCall createSipCall() { initErrorInfo(); SipCall call = new SipCall(this, myAddress); callList.add(call); return call; }
[ "public", "SipCall", "createSipCall", "(", ")", "{", "initErrorInfo", "(", ")", ";", "SipCall", "call", "=", "new", "SipCall", "(", "this", ",", "myAddress", ")", ";", "callList", ".", "add", "(", "call", ")", ";", "return", "call", ";", "}" ]
This method is used to create a SipCall object for handling one leg of a call. That is, it represents an outgoing call leg or an incoming call leg. In a telephone call, there are two call legs. The outgoing call leg is the connection from the phone making the call to the telephone network. The incoming call leg is a connection from the telephone network to the phone being called. For a SIP call, the outbound leg is the user agent originating the call and the inbound leg is the user agent receiving the call. The test program can use this method to create a SipCall object for handling an incoming call leg or an outgoing call leg. Currently, only one SipCall object is supported per SipPhone. In future, when more than one SipCall per SipPhone is supported, this method can be called multiple times to create multiple call legs on the same SipPhone object. @return A SipCall object unless an error is encountered.
[ "This", "method", "is", "used", "to", "create", "a", "SipCall", "object", "for", "handling", "one", "leg", "of", "a", "call", ".", "That", "is", "it", "represents", "an", "outgoing", "call", "leg", "or", "an", "incoming", "call", "leg", ".", "In", "a", "telephone", "call", "there", "are", "two", "call", "legs", ".", "The", "outgoing", "call", "leg", "is", "the", "connection", "from", "the", "phone", "making", "the", "call", "to", "the", "telephone", "network", ".", "The", "incoming", "call", "leg", "is", "a", "connection", "from", "the", "telephone", "network", "to", "the", "phone", "being", "called", ".", "For", "a", "SIP", "call", "the", "outbound", "leg", "is", "the", "user", "agent", "originating", "the", "call", "and", "the", "inbound", "leg", "is", "the", "user", "agent", "receiving", "the", "call", ".", "The", "test", "program", "can", "use", "this", "method", "to", "create", "a", "SipCall", "object", "for", "handling", "an", "incoming", "call", "leg", "or", "an", "outgoing", "call", "leg", ".", "Currently", "only", "one", "SipCall", "object", "is", "supported", "per", "SipPhone", ".", "In", "future", "when", "more", "than", "one", "SipCall", "per", "SipPhone", "is", "supported", "this", "method", "can", "be", "called", "multiple", "times", "to", "create", "multiple", "call", "legs", "on", "the", "same", "SipPhone", "object", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipPhone.java#L725-L733
1,955
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipPhone.java
SipPhone.makeCall
public SipCall makeCall(String to, int response, long timeout, String viaNonProxyRoute) { return makeCall(to, response, timeout, viaNonProxyRoute, null, null, null); }
java
public SipCall makeCall(String to, int response, long timeout, String viaNonProxyRoute) { return makeCall(to, response, timeout, viaNonProxyRoute, null, null, null); }
[ "public", "SipCall", "makeCall", "(", "String", "to", ",", "int", "response", ",", "long", "timeout", ",", "String", "viaNonProxyRoute", ")", "{", "return", "makeCall", "(", "to", ",", "response", ",", "timeout", ",", "viaNonProxyRoute", ",", "null", ",", "null", ",", "null", ")", ";", "}" ]
This blocking basic method is used to make an outgoing call. It blocks until the specified INVITE response status code is received. The object returned is a SipCall object representing the outgoing call leg; that is, the UAC originating a call to the network. Then you can take subsequent action on the call by making method calls on the SipCall object. <p> Use this method when (1) you want to establish a call without worrying about the details and (2) your test program doesn't need to do anything else (ie, it can be blocked) until the response code parameter passed to this method is received from the network. <p> In case the first condition above is false: If you need to see the (intermediate/provisional) response messages as they come in, then use SipPhone.createSipCall() and SipCall.initiateOutgoingCall() instead of this method. If your test program can tolerate being blocked until the desired response is received, you can still use this method and later look back at all the received responses by calling SipCall.getAllReceivedResponses(). <p> In case the second condition above is false: If your test code is handling both sides of the call, or it has to do other things while this call establishment is in progress, then this method's blocking gets in the way. In that case, use the other SipPhone.makeCall() method. It returns a SipCall object after the INVITE has been successfully sent. Then, later on you can check back with the SipCall object to see the call progress or block on the call establishment, at a more convenient time. @param to The URI string (ex: sip:[email protected]) to which the call should be directed @param response The SipResponse status code to look for after sending the INVITE. This method returns when that status code is received. @param timeout The maximum amount of time to wait for the response, in milliseconds. Use a value of 0 to wait indefinitely. @param viaNonProxyRoute Indicates whether to route the INVITE via Proxy or some other route. If null, route the call to the Proxy that was specified when the SipPhone object was created (SipStack.createSipPhone()). Else route it to the given node, which is specified as "hostaddress:port/transport" i.e. 129.1.22.333:5060/UDP. @return A SipCall object representing the outgoing call leg, or null if an error was encountered.
[ "This", "blocking", "basic", "method", "is", "used", "to", "make", "an", "outgoing", "call", ".", "It", "blocks", "until", "the", "specified", "INVITE", "response", "status", "code", "is", "received", ".", "The", "object", "returned", "is", "a", "SipCall", "object", "representing", "the", "outgoing", "call", "leg", ";", "that", "is", "the", "UAC", "originating", "a", "call", "to", "the", "network", ".", "Then", "you", "can", "take", "subsequent", "action", "on", "the", "call", "by", "making", "method", "calls", "on", "the", "SipCall", "object", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipPhone.java#L778-L780
1,956
RestComm/sipunit
src/main/java/org/cafesip/sipunit/MessageDigestAlgorithm.java
MessageDigestAlgorithm.calculateResponse
public static String calculateResponse(String algorithm, String username_value, String realm_value, String passwd, String nonce_value, String nc_value, String cnonce_value, String Method, String digest_uri_value, String entity_body, String qop_value) { if (username_value == null || realm_value == null || passwd == null || Method == null || digest_uri_value == null || nonce_value == null) throw new NullPointerException("Null parameter to MessageDigestAlgorithm.calculateResponse()"); // The following follows closely the algorithm for generating a response // digest as specified by rfc2617 String A1 = null; if (algorithm == null || algorithm.trim().length() == 0 || algorithm.trim().equalsIgnoreCase("MD5")) { A1 = username_value + ":" + realm_value + ":" + passwd; } else { if (cnonce_value == null || cnonce_value.length() == 0) throw new NullPointerException("cnonce_value may not be absent for MD5-Sess algorithm."); A1 = H(username_value + ":" + realm_value + ":" + passwd) + ":" + nonce_value + ":" + cnonce_value; } String A2 = null; if (qop_value == null || qop_value.trim().length() == 0 || qop_value.trim().equalsIgnoreCase("auth")) { A2 = Method + ":" + digest_uri_value; } else { if (entity_body == null) entity_body = ""; A2 = Method + ":" + digest_uri_value + ":" + H(entity_body); } String request_digest = null; if (cnonce_value != null && qop_value != null && (qop_value.equals("auth") || (qop_value.equals("auth-int")))) { request_digest = KD(H(A1), nonce_value + ":" + nc_value + ":" + cnonce_value + ":" + qop_value + ":" + H(A2)); } else { request_digest = KD(H(A1), nonce_value + ":" + H(A2)); } return request_digest; }
java
public static String calculateResponse(String algorithm, String username_value, String realm_value, String passwd, String nonce_value, String nc_value, String cnonce_value, String Method, String digest_uri_value, String entity_body, String qop_value) { if (username_value == null || realm_value == null || passwd == null || Method == null || digest_uri_value == null || nonce_value == null) throw new NullPointerException("Null parameter to MessageDigestAlgorithm.calculateResponse()"); // The following follows closely the algorithm for generating a response // digest as specified by rfc2617 String A1 = null; if (algorithm == null || algorithm.trim().length() == 0 || algorithm.trim().equalsIgnoreCase("MD5")) { A1 = username_value + ":" + realm_value + ":" + passwd; } else { if (cnonce_value == null || cnonce_value.length() == 0) throw new NullPointerException("cnonce_value may not be absent for MD5-Sess algorithm."); A1 = H(username_value + ":" + realm_value + ":" + passwd) + ":" + nonce_value + ":" + cnonce_value; } String A2 = null; if (qop_value == null || qop_value.trim().length() == 0 || qop_value.trim().equalsIgnoreCase("auth")) { A2 = Method + ":" + digest_uri_value; } else { if (entity_body == null) entity_body = ""; A2 = Method + ":" + digest_uri_value + ":" + H(entity_body); } String request_digest = null; if (cnonce_value != null && qop_value != null && (qop_value.equals("auth") || (qop_value.equals("auth-int")))) { request_digest = KD(H(A1), nonce_value + ":" + nc_value + ":" + cnonce_value + ":" + qop_value + ":" + H(A2)); } else { request_digest = KD(H(A1), nonce_value + ":" + H(A2)); } return request_digest; }
[ "public", "static", "String", "calculateResponse", "(", "String", "algorithm", ",", "String", "username_value", ",", "String", "realm_value", ",", "String", "passwd", ",", "String", "nonce_value", ",", "String", "nc_value", ",", "String", "cnonce_value", ",", "String", "Method", ",", "String", "digest_uri_value", ",", "String", "entity_body", ",", "String", "qop_value", ")", "{", "if", "(", "username_value", "==", "null", "||", "realm_value", "==", "null", "||", "passwd", "==", "null", "||", "Method", "==", "null", "||", "digest_uri_value", "==", "null", "||", "nonce_value", "==", "null", ")", "throw", "new", "NullPointerException", "(", "\"Null parameter to MessageDigestAlgorithm.calculateResponse()\"", ")", ";", "// The following follows closely the algorithm for generating a response", "// digest as specified by rfc2617", "String", "A1", "=", "null", ";", "if", "(", "algorithm", "==", "null", "||", "algorithm", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", "||", "algorithm", ".", "trim", "(", ")", ".", "equalsIgnoreCase", "(", "\"MD5\"", ")", ")", "{", "A1", "=", "username_value", "+", "\":\"", "+", "realm_value", "+", "\":\"", "+", "passwd", ";", "}", "else", "{", "if", "(", "cnonce_value", "==", "null", "||", "cnonce_value", ".", "length", "(", ")", "==", "0", ")", "throw", "new", "NullPointerException", "(", "\"cnonce_value may not be absent for MD5-Sess algorithm.\"", ")", ";", "A1", "=", "H", "(", "username_value", "+", "\":\"", "+", "realm_value", "+", "\":\"", "+", "passwd", ")", "+", "\":\"", "+", "nonce_value", "+", "\":\"", "+", "cnonce_value", ";", "}", "String", "A2", "=", "null", ";", "if", "(", "qop_value", "==", "null", "||", "qop_value", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", "||", "qop_value", ".", "trim", "(", ")", ".", "equalsIgnoreCase", "(", "\"auth\"", ")", ")", "{", "A2", "=", "Method", "+", "\":\"", "+", "digest_uri_value", ";", "}", "else", "{", "if", "(", "entity_body", "==", "null", ")", "entity_body", "=", "\"\"", ";", "A2", "=", "Method", "+", "\":\"", "+", "digest_uri_value", "+", "\":\"", "+", "H", "(", "entity_body", ")", ";", "}", "String", "request_digest", "=", "null", ";", "if", "(", "cnonce_value", "!=", "null", "&&", "qop_value", "!=", "null", "&&", "(", "qop_value", ".", "equals", "(", "\"auth\"", ")", "||", "(", "qop_value", ".", "equals", "(", "\"auth-int\"", ")", ")", ")", ")", "{", "request_digest", "=", "KD", "(", "H", "(", "A1", ")", ",", "nonce_value", "+", "\":\"", "+", "nc_value", "+", "\":\"", "+", "cnonce_value", "+", "\":\"", "+", "qop_value", "+", "\":\"", "+", "H", "(", "A2", ")", ")", ";", "}", "else", "{", "request_digest", "=", "KD", "(", "H", "(", "A1", ")", ",", "nonce_value", "+", "\":\"", "+", "H", "(", "A2", ")", ")", ";", "}", "return", "request_digest", ";", "}" ]
Calculates a response an http authentication response in accordance with rfc2617. <p> This method was copied from the Sip Communicator project (package net.java.sip.communicator.sip.security, its author is Emil Ivov) and slightly modified here (to remove console/log messages). Thanks for making it publicly available. It is licensed under the Apache Software License, Version 1.1 Copyright (c) 2000. @param algorithm MD5 or MD5-sess) @param username_value username_value (see rfc2617) @param realm_value realm_value @param passwd passwd @param nonce_value nonce_value @param cnonce_value cnonce_value @param Method method @param digest_uri_value uri_value @param entity_body entity_body @param qop_value qop @return a digest response as defined in rfc2617 @throws NullPointerException in case of incorrectly null parameters.
[ "Calculates", "a", "response", "an", "http", "authentication", "response", "in", "accordance", "with", "rfc2617", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/MessageDigestAlgorithm.java#L66-L111
1,957
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipRequest.java
SipRequest.getRequestURI
public String getRequestURI() { if ((message == null) || (((Request) message).getRequestURI() == null)) { return ""; } return ((Request) message).getRequestURI().toString(); }
java
public String getRequestURI() { if ((message == null) || (((Request) message).getRequestURI() == null)) { return ""; } return ((Request) message).getRequestURI().toString(); }
[ "public", "String", "getRequestURI", "(", ")", "{", "if", "(", "(", "message", "==", "null", ")", "||", "(", "(", "(", "Request", ")", "message", ")", ".", "getRequestURI", "(", ")", "==", "null", ")", ")", "{", "return", "\"\"", ";", "}", "return", "(", "(", "Request", ")", "message", ")", ".", "getRequestURI", "(", ")", ".", "toString", "(", ")", ";", "}" ]
Returns the request URI line of the request message or an empty string if there isn't one. The request URI indicates the user or service to which this request is addressed. @return the Request URI line as a string or "" if there isn't one
[ "Returns", "the", "request", "URI", "line", "of", "the", "request", "message", "or", "an", "empty", "string", "if", "there", "isn", "t", "one", ".", "The", "request", "URI", "indicates", "the", "user", "or", "service", "to", "which", "this", "request", "is", "addressed", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipRequest.java#L106-L112
1,958
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipRequest.java
SipRequest.isSipURI
public boolean isSipURI() { if ((message == null) || (((Request) message).getRequestURI() == null)) { return false; } return ((Request) message).getRequestURI().isSipURI(); }
java
public boolean isSipURI() { if ((message == null) || (((Request) message).getRequestURI() == null)) { return false; } return ((Request) message).getRequestURI().isSipURI(); }
[ "public", "boolean", "isSipURI", "(", ")", "{", "if", "(", "(", "message", "==", "null", ")", "||", "(", "(", "(", "Request", ")", "message", ")", ".", "getRequestURI", "(", ")", "==", "null", ")", ")", "{", "return", "false", ";", "}", "return", "(", "(", "Request", ")", "message", ")", ".", "getRequestURI", "(", ")", ".", "isSipURI", "(", ")", ";", "}" ]
Indicates if the request URI in the request message is a URI with a scheme of "sip" or "sips". @return true if the request URI scheme is "sip" or "sips", false otherwise.
[ "Indicates", "if", "the", "request", "URI", "in", "the", "request", "message", "is", "a", "URI", "with", "a", "scheme", "of", "sip", "or", "sips", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipRequest.java#L119-L125
1,959
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipRequest.java
SipRequest.isInvite
public boolean isInvite() { if (message == null) { return false; } return (((Request) message).getMethod().equals(Request.INVITE)); }
java
public boolean isInvite() { if (message == null) { return false; } return (((Request) message).getMethod().equals(Request.INVITE)); }
[ "public", "boolean", "isInvite", "(", ")", "{", "if", "(", "message", "==", "null", ")", "{", "return", "false", ";", "}", "return", "(", "(", "(", "Request", ")", "message", ")", ".", "getMethod", "(", ")", ".", "equals", "(", "Request", ".", "INVITE", ")", ")", ";", "}" ]
Indicates if the request method is INVITE or not. @return true if the method is INVITE, false otherwise.
[ "Indicates", "if", "the", "request", "method", "is", "INVITE", "or", "not", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipRequest.java#L132-L138
1,960
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipRequest.java
SipRequest.isAck
public boolean isAck() { if (message == null) { return false; } return (((Request) message).getMethod().equals(Request.ACK)); }
java
public boolean isAck() { if (message == null) { return false; } return (((Request) message).getMethod().equals(Request.ACK)); }
[ "public", "boolean", "isAck", "(", ")", "{", "if", "(", "message", "==", "null", ")", "{", "return", "false", ";", "}", "return", "(", "(", "(", "Request", ")", "message", ")", ".", "getMethod", "(", ")", ".", "equals", "(", "Request", ".", "ACK", ")", ")", ";", "}" ]
Indicates if the request method is ACK or not. @return true if the method is ACK, false otherwise.
[ "Indicates", "if", "the", "request", "method", "is", "ACK", "or", "not", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipRequest.java#L145-L151
1,961
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipRequest.java
SipRequest.isBye
public boolean isBye() { if (message == null) { return false; } return (((Request) message).getMethod().equals(Request.BYE)); }
java
public boolean isBye() { if (message == null) { return false; } return (((Request) message).getMethod().equals(Request.BYE)); }
[ "public", "boolean", "isBye", "(", ")", "{", "if", "(", "message", "==", "null", ")", "{", "return", "false", ";", "}", "return", "(", "(", "(", "Request", ")", "message", ")", ".", "getMethod", "(", ")", ".", "equals", "(", "Request", ".", "BYE", ")", ")", ";", "}" ]
Indicates if the request method is BYE or not. @return true if the method is BYE, false otherwise.
[ "Indicates", "if", "the", "request", "method", "is", "BYE", "or", "not", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipRequest.java#L158-L164
1,962
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipRequest.java
SipRequest.isNotify
public boolean isNotify() { if (message == null) { return false; } return (((Request) message).getMethod().equals(Request.NOTIFY)); }
java
public boolean isNotify() { if (message == null) { return false; } return (((Request) message).getMethod().equals(Request.NOTIFY)); }
[ "public", "boolean", "isNotify", "(", ")", "{", "if", "(", "message", "==", "null", ")", "{", "return", "false", ";", "}", "return", "(", "(", "(", "Request", ")", "message", ")", ".", "getMethod", "(", ")", ".", "equals", "(", "Request", ".", "NOTIFY", ")", ")", ";", "}" ]
Indicates if the request method is NOTIFY or not. @return true if the method is NOTIFY, false otherwise.
[ "Indicates", "if", "the", "request", "method", "is", "NOTIFY", "or", "not", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipRequest.java#L171-L177
1,963
RestComm/sipunit
src/main/java/org/cafesip/sipunit/SipRequest.java
SipRequest.isSubscribe
public boolean isSubscribe() { if (message == null) { return false; } return (((Request) message).getMethod().equals(Request.SUBSCRIBE)); }
java
public boolean isSubscribe() { if (message == null) { return false; } return (((Request) message).getMethod().equals(Request.SUBSCRIBE)); }
[ "public", "boolean", "isSubscribe", "(", ")", "{", "if", "(", "message", "==", "null", ")", "{", "return", "false", ";", "}", "return", "(", "(", "(", "Request", ")", "message", ")", ".", "getMethod", "(", ")", ".", "equals", "(", "Request", ".", "SUBSCRIBE", ")", ")", ";", "}" ]
Indicates if the request method is SUBSCRIBE or not. @return true if the method is SUBSCRIBE, false otherwise.
[ "Indicates", "if", "the", "request", "method", "is", "SUBSCRIBE", "or", "not", "." ]
18a6be2e29be3fbdc14226e8c41b25e2d57378b1
https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipRequest.java#L184-L190
1,964
wmz7year/Thrift-Connection-Pool
src/main/java/com/wmz7year/thrift/pool/TaskEngine.java
TaskEngine.schedule
public void schedule(TimerTask task, Date time) { timer.schedule(new TimerTaskWrapper(task), time); }
java
public void schedule(TimerTask task, Date time) { timer.schedule(new TimerTaskWrapper(task), time); }
[ "public", "void", "schedule", "(", "TimerTask", "task", ",", "Date", "time", ")", "{", "timer", ".", "schedule", "(", "new", "TimerTaskWrapper", "(", "task", ")", ",", "time", ")", ";", "}" ]
Schedules the specified task for execution at the specified time. If the time is in the past, the task is scheduled for immediate execution. @param task task to be scheduled. @param time time at which task is to be executed. @throws IllegalArgumentException if <tt>time.getTime()</tt> is negative. @throws IllegalStateException if task was already scheduled or cancelled, timer was cancelled, or timer thread terminated.
[ "Schedules", "the", "specified", "task", "for", "execution", "at", "the", "specified", "time", ".", "If", "the", "time", "is", "in", "the", "past", "the", "task", "is", "scheduled", "for", "immediate", "execution", "." ]
664df53dab12f87a53442e63dcaef1a7af5a484b
https://github.com/wmz7year/Thrift-Connection-Pool/blob/664df53dab12f87a53442e63dcaef1a7af5a484b/src/main/java/com/wmz7year/thrift/pool/TaskEngine.java#L122-L124
1,965
wmz7year/Thrift-Connection-Pool
src/main/java/com/wmz7year/thrift/pool/TaskEngine.java
TaskEngine.shutdown
public void shutdown() { if (executor != null) { executor.shutdown(); executor = null; } if (timer != null) { timer.cancel(); timer = null; } instance = null; }
java
public void shutdown() { if (executor != null) { executor.shutdown(); executor = null; } if (timer != null) { timer.cancel(); timer = null; } instance = null; }
[ "public", "void", "shutdown", "(", ")", "{", "if", "(", "executor", "!=", "null", ")", "{", "executor", ".", "shutdown", "(", ")", ";", "executor", "=", "null", ";", "}", "if", "(", "timer", "!=", "null", ")", "{", "timer", ".", "cancel", "(", ")", ";", "timer", "=", "null", ";", "}", "instance", "=", "null", ";", "}" ]
Shuts down the task engine service.
[ "Shuts", "down", "the", "task", "engine", "service", "." ]
664df53dab12f87a53442e63dcaef1a7af5a484b
https://github.com/wmz7year/Thrift-Connection-Pool/blob/664df53dab12f87a53442e63dcaef1a7af5a484b/src/main/java/com/wmz7year/thrift/pool/TaskEngine.java#L311-L323
1,966
alexxiyang/jdbctemplatetool
src/main/java/org/crazycake/jdbcTemplateTool/utils/ModelSqlUtils.java
ModelSqlUtils.getColumnNameFromGetter
private static String getColumnNameFromGetter(Method getter,Field f){ String columnName = ""; Column columnAnno = getter.getAnnotation(Column.class); if(columnAnno != null){ //如果是列注解就读取name属性 columnName = columnAnno.name(); } if(columnName == null || "".equals(columnName)){ //如果没有列注解就用命名方式去猜 columnName = IdUtils.toUnderscore(f.getName()); } return columnName; }
java
private static String getColumnNameFromGetter(Method getter,Field f){ String columnName = ""; Column columnAnno = getter.getAnnotation(Column.class); if(columnAnno != null){ //如果是列注解就读取name属性 columnName = columnAnno.name(); } if(columnName == null || "".equals(columnName)){ //如果没有列注解就用命名方式去猜 columnName = IdUtils.toUnderscore(f.getName()); } return columnName; }
[ "private", "static", "String", "getColumnNameFromGetter", "(", "Method", "getter", ",", "Field", "f", ")", "{", "String", "columnName", "=", "\"\"", ";", "Column", "columnAnno", "=", "getter", ".", "getAnnotation", "(", "Column", ".", "class", ")", ";", "if", "(", "columnAnno", "!=", "null", ")", "{", "//如果是列注解就读取name属性", "columnName", "=", "columnAnno", ".", "name", "(", ")", ";", "}", "if", "(", "columnName", "==", "null", "||", "\"\"", ".", "equals", "(", "columnName", ")", ")", "{", "//如果没有列注解就用命名方式去猜", "columnName", "=", "IdUtils", ".", "toUnderscore", "(", "f", ".", "getName", "(", ")", ")", ";", "}", "return", "columnName", ";", "}" ]
use getter to guess column name, if there is annotation then use annotation value, if not then guess from field name @param getter @param f @return @throws NoColumnAnnotationFoundException
[ "use", "getter", "to", "guess", "column", "name", "if", "there", "is", "annotation", "then", "use", "annotation", "value", "if", "not", "then", "guess", "from", "field", "name" ]
8406e0a7eb13677c4b7147a12f5f95caf9498aeb
https://github.com/alexxiyang/jdbctemplatetool/blob/8406e0a7eb13677c4b7147a12f5f95caf9498aeb/src/main/java/org/crazycake/jdbcTemplateTool/utils/ModelSqlUtils.java#L362-L375
1,967
alexxiyang/jdbctemplatetool
src/main/java/org/crazycake/jdbcTemplateTool/utils/InUtils.java
InUtils.handleIn
public static SqlParamsPairs handleIn(String sql, Object[] params){ //split with question mark placeholder String[] sqlPieces = sql.split("\\?"); //question mark placeholder list String[] questionPlaceholders; if(sql.endsWith("?")){ questionPlaceholders = new String[sqlPieces.length]; }else{ questionPlaceholders = new String[sqlPieces.length-1]; } for(int i=0;i<questionPlaceholders.length;i++){ questionPlaceholders[i]="?"; } List<Object> plist = new ArrayList<Object>(); for(int i=0; i<params.length; i++){ Object p = params[i]; if(p.getClass().equals(ArrayList.class)){ //change ? => (?,?,?...) //change list to objects StringBuilder sb = new StringBuilder(); sb.append("("); ArrayList inParams = (ArrayList)p; for(int j=0;j<inParams.size();j++){ if(j!=0){ sb.append(","); } sb.append("?"); //split list to objects plist.add(inParams.get(j)); } sb.append(")"); questionPlaceholders[i] = sb.toString(); }else{ plist.add(p); } } //join sql StringBuilder sqlsb = new StringBuilder(); for(int i=0;i<sqlPieces.length;i++){ sqlsb.append(sqlPieces[i]); if(i<questionPlaceholders.length){ sqlsb.append(questionPlaceholders[i]); } } SqlParamsPairs spPairs = new SqlParamsPairs(sqlsb.toString(),plist.toArray()); return spPairs; }
java
public static SqlParamsPairs handleIn(String sql, Object[] params){ //split with question mark placeholder String[] sqlPieces = sql.split("\\?"); //question mark placeholder list String[] questionPlaceholders; if(sql.endsWith("?")){ questionPlaceholders = new String[sqlPieces.length]; }else{ questionPlaceholders = new String[sqlPieces.length-1]; } for(int i=0;i<questionPlaceholders.length;i++){ questionPlaceholders[i]="?"; } List<Object> plist = new ArrayList<Object>(); for(int i=0; i<params.length; i++){ Object p = params[i]; if(p.getClass().equals(ArrayList.class)){ //change ? => (?,?,?...) //change list to objects StringBuilder sb = new StringBuilder(); sb.append("("); ArrayList inParams = (ArrayList)p; for(int j=0;j<inParams.size();j++){ if(j!=0){ sb.append(","); } sb.append("?"); //split list to objects plist.add(inParams.get(j)); } sb.append(")"); questionPlaceholders[i] = sb.toString(); }else{ plist.add(p); } } //join sql StringBuilder sqlsb = new StringBuilder(); for(int i=0;i<sqlPieces.length;i++){ sqlsb.append(sqlPieces[i]); if(i<questionPlaceholders.length){ sqlsb.append(questionPlaceholders[i]); } } SqlParamsPairs spPairs = new SqlParamsPairs(sqlsb.toString(),plist.toArray()); return spPairs; }
[ "public", "static", "SqlParamsPairs", "handleIn", "(", "String", "sql", ",", "Object", "[", "]", "params", ")", "{", "//split with question mark placeholder", "String", "[", "]", "sqlPieces", "=", "sql", ".", "split", "(", "\"\\\\?\"", ")", ";", "//question mark placeholder list", "String", "[", "]", "questionPlaceholders", ";", "if", "(", "sql", ".", "endsWith", "(", "\"?\"", ")", ")", "{", "questionPlaceholders", "=", "new", "String", "[", "sqlPieces", ".", "length", "]", ";", "}", "else", "{", "questionPlaceholders", "=", "new", "String", "[", "sqlPieces", ".", "length", "-", "1", "]", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "questionPlaceholders", ".", "length", ";", "i", "++", ")", "{", "questionPlaceholders", "[", "i", "]", "=", "\"?\"", ";", "}", "List", "<", "Object", ">", "plist", "=", "new", "ArrayList", "<", "Object", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "params", ".", "length", ";", "i", "++", ")", "{", "Object", "p", "=", "params", "[", "i", "]", ";", "if", "(", "p", ".", "getClass", "(", ")", ".", "equals", "(", "ArrayList", ".", "class", ")", ")", "{", "//change ? => (?,?,?...)", "//change list to objects", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"(\"", ")", ";", "ArrayList", "inParams", "=", "(", "ArrayList", ")", "p", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "inParams", ".", "size", "(", ")", ";", "j", "++", ")", "{", "if", "(", "j", "!=", "0", ")", "{", "sb", ".", "append", "(", "\",\"", ")", ";", "}", "sb", ".", "append", "(", "\"?\"", ")", ";", "//split list to objects", "plist", ".", "add", "(", "inParams", ".", "get", "(", "j", ")", ")", ";", "}", "sb", ".", "append", "(", "\")\"", ")", ";", "questionPlaceholders", "[", "i", "]", "=", "sb", ".", "toString", "(", ")", ";", "}", "else", "{", "plist", ".", "add", "(", "p", ")", ";", "}", "}", "//join sql", "StringBuilder", "sqlsb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "sqlPieces", ".", "length", ";", "i", "++", ")", "{", "sqlsb", ".", "append", "(", "sqlPieces", "[", "i", "]", ")", ";", "if", "(", "i", "<", "questionPlaceholders", ".", "length", ")", "{", "sqlsb", ".", "append", "(", "questionPlaceholders", "[", "i", "]", ")", ";", "}", "}", "SqlParamsPairs", "spPairs", "=", "new", "SqlParamsPairs", "(", "sqlsb", ".", "toString", "(", ")", ",", "plist", ".", "toArray", "(", ")", ")", ";", "return", "spPairs", ";", "}" ]
Change sql if found array in params @param sql @param params @return
[ "Change", "sql", "if", "found", "array", "in", "params" ]
8406e0a7eb13677c4b7147a12f5f95caf9498aeb
https://github.com/alexxiyang/jdbctemplatetool/blob/8406e0a7eb13677c4b7147a12f5f95caf9498aeb/src/main/java/org/crazycake/jdbcTemplateTool/utils/InUtils.java#L21-L77
1,968
alexxiyang/jdbctemplatetool
src/main/java/org/crazycake/jdbcTemplateTool/utils/IdUtils.java
IdUtils.toCamel
public static String toCamel(String name) { return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name); }
java
public static String toCamel(String name) { return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name); }
[ "public", "static", "String", "toCamel", "(", "String", "name", ")", "{", "return", "CaseFormat", ".", "LOWER_UNDERSCORE", ".", "to", "(", "CaseFormat", ".", "LOWER_CAMEL", ",", "name", ")", ";", "}" ]
Convert underscore style to camel style @param name @return
[ "Convert", "underscore", "style", "to", "camel", "style" ]
8406e0a7eb13677c4b7147a12f5f95caf9498aeb
https://github.com/alexxiyang/jdbctemplatetool/blob/8406e0a7eb13677c4b7147a12f5f95caf9498aeb/src/main/java/org/crazycake/jdbcTemplateTool/utils/IdUtils.java#L74-L76
1,969
alexxiyang/jdbctemplatetool
src/main/java/org/crazycake/jdbcTemplateTool/utils/IdUtils.java
IdUtils.toUnderscore
public static String toUnderscore(String name) { return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name); }
java
public static String toUnderscore(String name) { return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name); }
[ "public", "static", "String", "toUnderscore", "(", "String", "name", ")", "{", "return", "CaseFormat", ".", "LOWER_CAMEL", ".", "to", "(", "CaseFormat", ".", "LOWER_UNDERSCORE", ",", "name", ")", ";", "}" ]
Convert camel style to underscore style @param name @return
[ "Convert", "camel", "style", "to", "underscore", "style" ]
8406e0a7eb13677c4b7147a12f5f95caf9498aeb
https://github.com/alexxiyang/jdbctemplatetool/blob/8406e0a7eb13677c4b7147a12f5f95caf9498aeb/src/main/java/org/crazycake/jdbcTemplateTool/utils/IdUtils.java#L83-L85
1,970
alexxiyang/jdbctemplatetool
src/main/java/org/crazycake/jdbcTemplateTool/JdbcTemplateTool.java
JdbcTemplateTool.getProxy
private JdbcTemplateProxy getProxy(){ if(_proxy == null){ _proxy = new JdbcTemplateProxy(); _proxy.setJdbcTemplate(jdbcTemplate); } return _proxy; }
java
private JdbcTemplateProxy getProxy(){ if(_proxy == null){ _proxy = new JdbcTemplateProxy(); _proxy.setJdbcTemplate(jdbcTemplate); } return _proxy; }
[ "private", "JdbcTemplateProxy", "getProxy", "(", ")", "{", "if", "(", "_proxy", "==", "null", ")", "{", "_proxy", "=", "new", "JdbcTemplateProxy", "(", ")", ";", "_proxy", ".", "setJdbcTemplate", "(", "jdbcTemplate", ")", ";", "}", "return", "_proxy", ";", "}" ]
return the singleton proxy
[ "return", "the", "singleton", "proxy" ]
8406e0a7eb13677c4b7147a12f5f95caf9498aeb
https://github.com/alexxiyang/jdbctemplatetool/blob/8406e0a7eb13677c4b7147a12f5f95caf9498aeb/src/main/java/org/crazycake/jdbcTemplateTool/JdbcTemplateTool.java#L39-L45
1,971
alexxiyang/jdbctemplatetool
src/main/java/org/crazycake/jdbcTemplateTool/JdbcTemplateProxy.java
JdbcTemplateProxy.insert
public int insert(String sql,Object[] params,String autoGeneratedColumnName) throws DataAccessException{ //dynamic change catalog name sql = changeCatalog(sql); ReturnIdPreparedStatementCreator psc = new ReturnIdPreparedStatementCreator(sql, params, autoGeneratedColumnName); KeyHolder keyHolder = new GeneratedKeyHolder(); try{ jdbcTemplate.update(psc, keyHolder); }catch(DataAccessException e){ StringBuilder sb = new StringBuilder(); sb.append("["); for(Object p:params){ sb.append(p + " | "); } sb.append("]"); logger.error("Error SQL: " + sql + " Params: " + sb.toString()); throw e; } return keyHolder.getKey().intValue(); }
java
public int insert(String sql,Object[] params,String autoGeneratedColumnName) throws DataAccessException{ //dynamic change catalog name sql = changeCatalog(sql); ReturnIdPreparedStatementCreator psc = new ReturnIdPreparedStatementCreator(sql, params, autoGeneratedColumnName); KeyHolder keyHolder = new GeneratedKeyHolder(); try{ jdbcTemplate.update(psc, keyHolder); }catch(DataAccessException e){ StringBuilder sb = new StringBuilder(); sb.append("["); for(Object p:params){ sb.append(p + " | "); } sb.append("]"); logger.error("Error SQL: " + sql + " Params: " + sb.toString()); throw e; } return keyHolder.getKey().intValue(); }
[ "public", "int", "insert", "(", "String", "sql", ",", "Object", "[", "]", "params", ",", "String", "autoGeneratedColumnName", ")", "throws", "DataAccessException", "{", "//dynamic change catalog name", "sql", "=", "changeCatalog", "(", "sql", ")", ";", "ReturnIdPreparedStatementCreator", "psc", "=", "new", "ReturnIdPreparedStatementCreator", "(", "sql", ",", "params", ",", "autoGeneratedColumnName", ")", ";", "KeyHolder", "keyHolder", "=", "new", "GeneratedKeyHolder", "(", ")", ";", "try", "{", "jdbcTemplate", ".", "update", "(", "psc", ",", "keyHolder", ")", ";", "}", "catch", "(", "DataAccessException", "e", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"[\"", ")", ";", "for", "(", "Object", "p", ":", "params", ")", "{", "sb", ".", "append", "(", "p", "+", "\" | \"", ")", ";", "}", "sb", ".", "append", "(", "\"]\"", ")", ";", "logger", ".", "error", "(", "\"Error SQL: \"", "+", "sql", "+", "\" Params: \"", "+", "sb", ".", "toString", "(", ")", ")", ";", "throw", "e", ";", "}", "return", "keyHolder", ".", "getKey", "(", ")", ".", "intValue", "(", ")", ";", "}" ]
insert a row with auto increament id @param sql @param params @param autoGeneratedColumnName @return @throws DataAccessException
[ "insert", "a", "row", "with", "auto", "increament", "id" ]
8406e0a7eb13677c4b7147a12f5f95caf9498aeb
https://github.com/alexxiyang/jdbctemplatetool/blob/8406e0a7eb13677c4b7147a12f5f95caf9498aeb/src/main/java/org/crazycake/jdbcTemplateTool/JdbcTemplateProxy.java#L119-L140
1,972
alexxiyang/jdbctemplatetool
src/main/java/org/crazycake/jdbcTemplateTool/utils/CatalogUtils.java
CatalogUtils.changeCatalog
public static String changeCatalog(String sql){ CatalogContext catalogContext = catalogContextHolder.get(); if(catalogContext != null && catalogContext.getCatalog() != null && catalogContext.getPlaceHolder() != null){ sql = sql.replace(catalogContext.getPlaceHolder(), catalogContext.getCatalog()); } logger.debug("real sql: "+sql); return sql; }
java
public static String changeCatalog(String sql){ CatalogContext catalogContext = catalogContextHolder.get(); if(catalogContext != null && catalogContext.getCatalog() != null && catalogContext.getPlaceHolder() != null){ sql = sql.replace(catalogContext.getPlaceHolder(), catalogContext.getCatalog()); } logger.debug("real sql: "+sql); return sql; }
[ "public", "static", "String", "changeCatalog", "(", "String", "sql", ")", "{", "CatalogContext", "catalogContext", "=", "catalogContextHolder", ".", "get", "(", ")", ";", "if", "(", "catalogContext", "!=", "null", "&&", "catalogContext", ".", "getCatalog", "(", ")", "!=", "null", "&&", "catalogContext", ".", "getPlaceHolder", "(", ")", "!=", "null", ")", "{", "sql", "=", "sql", ".", "replace", "(", "catalogContext", ".", "getPlaceHolder", "(", ")", ",", "catalogContext", ".", "getCatalog", "(", ")", ")", ";", "}", "logger", ".", "debug", "(", "\"real sql: \"", "+", "sql", ")", ";", "return", "sql", ";", "}" ]
JdbcTemplateTool supports mulitiple catalog query. You can put a placeholder before your table name, JdbcTemplateTool will change this placeholder to real catalog name with the catalog stored in catalogContext. @param sql @return
[ "JdbcTemplateTool", "supports", "mulitiple", "catalog", "query", ".", "You", "can", "put", "a", "placeholder", "before", "your", "table", "name", "JdbcTemplateTool", "will", "change", "this", "placeholder", "to", "real", "catalog", "name", "with", "the", "catalog", "stored", "in", "catalogContext", "." ]
8406e0a7eb13677c4b7147a12f5f95caf9498aeb
https://github.com/alexxiyang/jdbctemplatetool/blob/8406e0a7eb13677c4b7147a12f5f95caf9498aeb/src/main/java/org/crazycake/jdbcTemplateTool/utils/CatalogUtils.java#L29-L36
1,973
qos-ch/cal10n
cal10n-api/src/main/java/ch/qos/cal10n/util/Parser.java
Parser.V
private void V(StringBuilder buf) { Token t = getNextToken(); if (t.tokenType != TokenType.VALUE) { throw new IllegalStateException("Unexpected token " + t); } buf.append(t.getValue()); t = getNextToken(); if (t.tokenType == TokenType.EOL) { return; } else if (t.tokenType == TokenType.TRAILING_BACKSLASH) { Vopt(buf); } }
java
private void V(StringBuilder buf) { Token t = getNextToken(); if (t.tokenType != TokenType.VALUE) { throw new IllegalStateException("Unexpected token " + t); } buf.append(t.getValue()); t = getNextToken(); if (t.tokenType == TokenType.EOL) { return; } else if (t.tokenType == TokenType.TRAILING_BACKSLASH) { Vopt(buf); } }
[ "private", "void", "V", "(", "StringBuilder", "buf", ")", "{", "Token", "t", "=", "getNextToken", "(", ")", ";", "if", "(", "t", ".", "tokenType", "!=", "TokenType", ".", "VALUE", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Unexpected token \"", "+", "t", ")", ";", "}", "buf", ".", "append", "(", "t", ".", "getValue", "(", ")", ")", ";", "t", "=", "getNextToken", "(", ")", ";", "if", "(", "t", ".", "tokenType", "==", "TokenType", ".", "EOL", ")", "{", "return", ";", "}", "else", "if", "(", "t", ".", "tokenType", "==", "TokenType", ".", "TRAILING_BACKSLASH", ")", "{", "Vopt", "(", "buf", ")", ";", "}", "}" ]
Vopt = EOL V
[ "Vopt", "=", "EOL", "V" ]
22c048801fb6d04c991a0c8c01bb6fb97ef50b37
https://github.com/qos-ch/cal10n/blob/22c048801fb6d04c991a0c8c01bb6fb97ef50b37/cal10n-api/src/main/java/ch/qos/cal10n/util/Parser.java#L88-L103
1,974
qos-ch/cal10n
cal10n-api/src/main/java/ch/qos/cal10n/verifier/AbstractMessageKeyVerifier.java
AbstractMessageKeyVerifier.verifyAllLocales
public List<Cal10nError> verifyAllLocales() { List<Cal10nError> errorList = new ArrayList<Cal10nError>(); String[] localeNameArray = getLocaleNames(); ErrorFactory errorFactory = new ErrorFactory(enumTypeAsStr, null, getBaseName()); if (localeNameArray == null || localeNameArray.length == 0) { errorList.add(errorFactory.buildError(MISSING_LOCALE_DATA_ANNOTATION, "*")); return errorList; } for (String localeName : localeNameArray) { Locale locale = MiscUtil.toLocale(localeName); List<Cal10nError> tmpList = verify(locale); errorList.addAll(tmpList); } return errorList; }
java
public List<Cal10nError> verifyAllLocales() { List<Cal10nError> errorList = new ArrayList<Cal10nError>(); String[] localeNameArray = getLocaleNames(); ErrorFactory errorFactory = new ErrorFactory(enumTypeAsStr, null, getBaseName()); if (localeNameArray == null || localeNameArray.length == 0) { errorList.add(errorFactory.buildError(MISSING_LOCALE_DATA_ANNOTATION, "*")); return errorList; } for (String localeName : localeNameArray) { Locale locale = MiscUtil.toLocale(localeName); List<Cal10nError> tmpList = verify(locale); errorList.addAll(tmpList); } return errorList; }
[ "public", "List", "<", "Cal10nError", ">", "verifyAllLocales", "(", ")", "{", "List", "<", "Cal10nError", ">", "errorList", "=", "new", "ArrayList", "<", "Cal10nError", ">", "(", ")", ";", "String", "[", "]", "localeNameArray", "=", "getLocaleNames", "(", ")", ";", "ErrorFactory", "errorFactory", "=", "new", "ErrorFactory", "(", "enumTypeAsStr", ",", "null", ",", "getBaseName", "(", ")", ")", ";", "if", "(", "localeNameArray", "==", "null", "||", "localeNameArray", ".", "length", "==", "0", ")", "{", "errorList", ".", "add", "(", "errorFactory", ".", "buildError", "(", "MISSING_LOCALE_DATA_ANNOTATION", ",", "\"*\"", ")", ")", ";", "return", "errorList", ";", "}", "for", "(", "String", "localeName", ":", "localeNameArray", ")", "{", "Locale", "locale", "=", "MiscUtil", ".", "toLocale", "(", "localeName", ")", ";", "List", "<", "Cal10nError", ">", "tmpList", "=", "verify", "(", "locale", ")", ";", "errorList", ".", "addAll", "(", "tmpList", ")", ";", "}", "return", "errorList", ";", "}" ]
Verify all declared locales in one step.
[ "Verify", "all", "declared", "locales", "in", "one", "step", "." ]
22c048801fb6d04c991a0c8c01bb6fb97ef50b37
https://github.com/qos-ch/cal10n/blob/22c048801fb6d04c991a0c8c01bb6fb97ef50b37/cal10n-api/src/main/java/ch/qos/cal10n/verifier/AbstractMessageKeyVerifier.java#L130-L149
1,975
smurn/jPLY
jply/src/main/java/org/smurn/jply/BinaryElementReader.java
BinaryElementReader.readListProperty
private double[] readListProperty(final ListProperty property) throws IOException { int valueCount = (int) stream.read(property.getCountType()); double[] values = new double[valueCount]; for (int i = 0; i < values.length; i++) { values[i] = stream.read(property.getType()); } return values; }
java
private double[] readListProperty(final ListProperty property) throws IOException { int valueCount = (int) stream.read(property.getCountType()); double[] values = new double[valueCount]; for (int i = 0; i < values.length; i++) { values[i] = stream.read(property.getType()); } return values; }
[ "private", "double", "[", "]", "readListProperty", "(", "final", "ListProperty", "property", ")", "throws", "IOException", "{", "int", "valueCount", "=", "(", "int", ")", "stream", ".", "read", "(", "property", ".", "getCountType", "(", ")", ")", ";", "double", "[", "]", "values", "=", "new", "double", "[", "valueCount", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "values", ".", "length", ";", "i", "++", ")", "{", "values", "[", "i", "]", "=", "stream", ".", "read", "(", "property", ".", "getType", "(", ")", ")", ";", "}", "return", "values", ";", "}" ]
Reads the values of a list-property. @param property Property to read. @return Values of that property. @throws IOException if reading fails.
[ "Reads", "the", "values", "of", "a", "list", "-", "property", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/BinaryElementReader.java#L105-L113
1,976
smurn/jPLY
jply/src/main/java/org/smurn/jply/ElementType.java
ElementType.parse
static HeaderEntry parse(final String elementLine) throws IOException { if (!elementLine.startsWith("element ")) { throw new IOException("not an element: '" + elementLine + "'"); } String definition = elementLine.substring("element ".length()); String[] parts = definition.split(" +", 2); if (parts.length != 2) { throw new IOException("Expected two parts in element definition: '" + elementLine + "'"); } String name = parts[0]; String countStr = parts[1]; int count; try { count = Integer.parseInt(countStr); } catch (NumberFormatException e) { throw new IOException("Invalid element entry. Not an integer: '" + countStr + "'."); } return new HeaderEntry(name, count); }
java
static HeaderEntry parse(final String elementLine) throws IOException { if (!elementLine.startsWith("element ")) { throw new IOException("not an element: '" + elementLine + "'"); } String definition = elementLine.substring("element ".length()); String[] parts = definition.split(" +", 2); if (parts.length != 2) { throw new IOException("Expected two parts in element definition: '" + elementLine + "'"); } String name = parts[0]; String countStr = parts[1]; int count; try { count = Integer.parseInt(countStr); } catch (NumberFormatException e) { throw new IOException("Invalid element entry. Not an integer: '" + countStr + "'."); } return new HeaderEntry(name, count); }
[ "static", "HeaderEntry", "parse", "(", "final", "String", "elementLine", ")", "throws", "IOException", "{", "if", "(", "!", "elementLine", ".", "startsWith", "(", "\"element \"", ")", ")", "{", "throw", "new", "IOException", "(", "\"not an element: '\"", "+", "elementLine", "+", "\"'\"", ")", ";", "}", "String", "definition", "=", "elementLine", ".", "substring", "(", "\"element \"", ".", "length", "(", ")", ")", ";", "String", "[", "]", "parts", "=", "definition", ".", "split", "(", "\" +\"", ",", "2", ")", ";", "if", "(", "parts", ".", "length", "!=", "2", ")", "{", "throw", "new", "IOException", "(", "\"Expected two parts in element definition: '\"", "+", "elementLine", "+", "\"'\"", ")", ";", "}", "String", "name", "=", "parts", "[", "0", "]", ";", "String", "countStr", "=", "parts", "[", "1", "]", ";", "int", "count", ";", "try", "{", "count", "=", "Integer", ".", "parseInt", "(", "countStr", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "throw", "new", "IOException", "(", "\"Invalid element entry. Not an integer: '\"", "+", "countStr", "+", "\"'.\"", ")", ";", "}", "return", "new", "HeaderEntry", "(", "name", ",", "count", ")", ";", "}" ]
Parses a header line starting an element description. @param elementLine Header line. @return ElementType without properties. @throws IOException if the header line has an invalid format.
[ "Parses", "a", "header", "line", "starting", "an", "element", "description", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/ElementType.java#L214-L237
1,977
smurn/jPLY
jply/src/main/java/org/smurn/jply/util/RandomPlyReader.java
RandomPlyReader.getElementReader
public RandomElementReader getElementReader(final String elementType) throws IOException { if (elementType == null) { throw new NullPointerException("elementType must not be null."); } if (!buffer.containsKey(elementType)) { throw new IllegalArgumentException("No such element type."); } if (closed) { throw new IllegalStateException("Reader is closed."); } while (buffer.get(elementType) == null) { ElementReader eReader = reader.nextElementReader(); BufferedElementReader bReader = new BufferedElementReader(eReader); bReader.detach(); buffer.put(eReader.getElementType().getName(), bReader); } return buffer.get(elementType).duplicate(); }
java
public RandomElementReader getElementReader(final String elementType) throws IOException { if (elementType == null) { throw new NullPointerException("elementType must not be null."); } if (!buffer.containsKey(elementType)) { throw new IllegalArgumentException("No such element type."); } if (closed) { throw new IllegalStateException("Reader is closed."); } while (buffer.get(elementType) == null) { ElementReader eReader = reader.nextElementReader(); BufferedElementReader bReader = new BufferedElementReader(eReader); bReader.detach(); buffer.put(eReader.getElementType().getName(), bReader); } return buffer.get(elementType).duplicate(); }
[ "public", "RandomElementReader", "getElementReader", "(", "final", "String", "elementType", ")", "throws", "IOException", "{", "if", "(", "elementType", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"elementType must not be null.\"", ")", ";", "}", "if", "(", "!", "buffer", ".", "containsKey", "(", "elementType", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"No such element type.\"", ")", ";", "}", "if", "(", "closed", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Reader is closed.\"", ")", ";", "}", "while", "(", "buffer", ".", "get", "(", "elementType", ")", "==", "null", ")", "{", "ElementReader", "eReader", "=", "reader", ".", "nextElementReader", "(", ")", ";", "BufferedElementReader", "bReader", "=", "new", "BufferedElementReader", "(", "eReader", ")", ";", "bReader", ".", "detach", "(", ")", ";", "buffer", ".", "put", "(", "eReader", ".", "getElementType", "(", ")", ".", "getName", "(", ")", ",", "bReader", ")", ";", "}", "return", "buffer", ".", "get", "(", "elementType", ")", ".", "duplicate", "(", ")", ";", "}" ]
Returns an element reader for the given element type. @param elementType Element type. @return Reader for the elements of the given type. @throws IOException if reading fails. @throws NullPointerException if {@code elementType} is {@code null}. @throws IllegalArgumentException if there is no element with the given name. @throws IllegalStateException if this reader is closed.
[ "Returns", "an", "element", "reader", "for", "the", "given", "element", "type", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/util/RandomPlyReader.java#L76-L94
1,978
smurn/jPLY
jply/src/main/java/org/smurn/jply/Property.java
Property.parse
static Property parse(final String propertyLine) throws IOException { if (!propertyLine.startsWith("property ")) { throw new IOException("not a property: '" + propertyLine + "'"); } String definition = propertyLine.substring("property ".length()); if (definition.startsWith("list")) { return ListProperty.parse(propertyLine); } String[] parts = definition.split(" +", 2); if (parts.length != 2) { throw new IOException("Expected two parts in property definition: '" + propertyLine + "'"); } String type = parts[0]; String name = parts[1]; DataType dataType; try { dataType = DataType.parse(type); } catch (IllegalArgumentException e) { throw new IOException(e.getMessage()); } return new Property(name, dataType); }
java
static Property parse(final String propertyLine) throws IOException { if (!propertyLine.startsWith("property ")) { throw new IOException("not a property: '" + propertyLine + "'"); } String definition = propertyLine.substring("property ".length()); if (definition.startsWith("list")) { return ListProperty.parse(propertyLine); } String[] parts = definition.split(" +", 2); if (parts.length != 2) { throw new IOException("Expected two parts in property definition: '" + propertyLine + "'"); } String type = parts[0]; String name = parts[1]; DataType dataType; try { dataType = DataType.parse(type); } catch (IllegalArgumentException e) { throw new IOException(e.getMessage()); } return new Property(name, dataType); }
[ "static", "Property", "parse", "(", "final", "String", "propertyLine", ")", "throws", "IOException", "{", "if", "(", "!", "propertyLine", ".", "startsWith", "(", "\"property \"", ")", ")", "{", "throw", "new", "IOException", "(", "\"not a property: '\"", "+", "propertyLine", "+", "\"'\"", ")", ";", "}", "String", "definition", "=", "propertyLine", ".", "substring", "(", "\"property \"", ".", "length", "(", ")", ")", ";", "if", "(", "definition", ".", "startsWith", "(", "\"list\"", ")", ")", "{", "return", "ListProperty", ".", "parse", "(", "propertyLine", ")", ";", "}", "String", "[", "]", "parts", "=", "definition", ".", "split", "(", "\" +\"", ",", "2", ")", ";", "if", "(", "parts", ".", "length", "!=", "2", ")", "{", "throw", "new", "IOException", "(", "\"Expected two parts in property definition: '\"", "+", "propertyLine", "+", "\"'\"", ")", ";", "}", "String", "type", "=", "parts", "[", "0", "]", ";", "String", "name", "=", "parts", "[", "1", "]", ";", "DataType", "dataType", ";", "try", "{", "dataType", "=", "DataType", ".", "parse", "(", "type", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "throw", "new", "IOException", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "return", "new", "Property", "(", "name", ",", "dataType", ")", ";", "}" ]
Parses a property header line. @param propertyLine Header line. @return Property described on the line. @throws IOException if the header line as an invalid format.
[ "Parses", "a", "property", "header", "line", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/Property.java#L89-L117
1,979
smurn/jPLY
jply/src/main/java/org/smurn/jply/util/TypeChangingElementReader.java
TypeChangingElementReader.getSourceName
private String getSourceName(final String property) { if (propertyNameMap.containsKey(property)) { return propertyNameMap.get(property); } else { return property; } }
java
private String getSourceName(final String property) { if (propertyNameMap.containsKey(property)) { return propertyNameMap.get(property); } else { return property; } }
[ "private", "String", "getSourceName", "(", "final", "String", "property", ")", "{", "if", "(", "propertyNameMap", ".", "containsKey", "(", "property", ")", ")", "{", "return", "propertyNameMap", ".", "get", "(", "property", ")", ";", "}", "else", "{", "return", "property", ";", "}", "}" ]
Get the name of a property in the source type. @param property Name of the property in the target type. @return Name of a property in the source type.
[ "Get", "the", "name", "of", "a", "property", "in", "the", "source", "type", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/util/TypeChangingElementReader.java#L138-L144
1,980
smurn/jPLY
jply/src/main/java/org/smurn/jply/util/AxisShufflingVertexReader.java
AxisShufflingVertexReader.getValue
private double getValue(final double x, final double y, final double z, final Axis axis) { switch (axis) { case X: return x; case X_INVERTED: return -x; case Y: return y; case Y_INVERTED: return -y; case Z: return z; case Z_INVERTED: return -z; default: throw new IllegalArgumentException("Unsupported axis."); } }
java
private double getValue(final double x, final double y, final double z, final Axis axis) { switch (axis) { case X: return x; case X_INVERTED: return -x; case Y: return y; case Y_INVERTED: return -y; case Z: return z; case Z_INVERTED: return -z; default: throw new IllegalArgumentException("Unsupported axis."); } }
[ "private", "double", "getValue", "(", "final", "double", "x", ",", "final", "double", "y", ",", "final", "double", "z", ",", "final", "Axis", "axis", ")", "{", "switch", "(", "axis", ")", "{", "case", "X", ":", "return", "x", ";", "case", "X_INVERTED", ":", "return", "-", "x", ";", "case", "Y", ":", "return", "y", ";", "case", "Y_INVERTED", ":", "return", "-", "y", ";", "case", "Z", ":", "return", "z", ";", "case", "Z_INVERTED", ":", "return", "-", "z", ";", "default", ":", "throw", "new", "IllegalArgumentException", "(", "\"Unsupported axis.\"", ")", ";", "}", "}" ]
Returns the value of a given axis. @param x Input x value. @param y Input y value. @param z Input z value. @param axis Axis to return. @return The value of a given axis.
[ "Returns", "the", "value", "of", "a", "given", "axis", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/util/AxisShufflingVertexReader.java#L110-L128
1,981
smurn/jPLY
jply/src/main/java/org/smurn/jply/util/NormalGenerator.java
NormalGenerator.generateNormals
public void generateNormals(final RandomElementReader vertexReader, final ElementReader faceReader) throws IOException { if (vertexReader == null) { throw new NullPointerException("vertexReader must not be null."); } if (faceReader == null) { throw new NullPointerException("faceReader must not be null."); } if (!vertexReader.getElementType().getName().equals("vertex")) { throw new IllegalArgumentException( "vertexReader does not read vertices."); } boolean foundX = false; boolean foundY = false; boolean foundZ = false; for (Property p : vertexReader.getElementType().getProperties()) { foundX |= p.getName().equals("x") && !(p instanceof ListProperty); foundY |= p.getName().equals("y") && !(p instanceof ListProperty); foundZ |= p.getName().equals("z") && !(p instanceof ListProperty); } if (!foundX || !foundY || !foundZ) { throw new IllegalArgumentException("Vertex type does not include" + " the three non-list properties x y and z."); } if (!faceReader.getElementType().getName().equals("face")) { throw new IllegalArgumentException( "faceReader does not read faces."); } boolean foundVertexIndex = false; for (Property p : faceReader.getElementType().getProperties()) { foundVertexIndex |= p.getName().equals("vertex_index") && (p instanceof ListProperty); } if (!foundVertexIndex) { throw new IllegalArgumentException( "Face type does not include a list property named " + "vertex_index."); } // Phase 1: accumulate weighted normals for (Element face = faceReader.readElement(); face != null; face = faceReader.readElement()) { accumulateNormals(vertexReader, face); } // Phase 2: normalize the normal vectors for (Element vertex = vertexReader.readElement(); vertex != null; vertex = vertexReader.readElement()) { normalize(vertex); } }
java
public void generateNormals(final RandomElementReader vertexReader, final ElementReader faceReader) throws IOException { if (vertexReader == null) { throw new NullPointerException("vertexReader must not be null."); } if (faceReader == null) { throw new NullPointerException("faceReader must not be null."); } if (!vertexReader.getElementType().getName().equals("vertex")) { throw new IllegalArgumentException( "vertexReader does not read vertices."); } boolean foundX = false; boolean foundY = false; boolean foundZ = false; for (Property p : vertexReader.getElementType().getProperties()) { foundX |= p.getName().equals("x") && !(p instanceof ListProperty); foundY |= p.getName().equals("y") && !(p instanceof ListProperty); foundZ |= p.getName().equals("z") && !(p instanceof ListProperty); } if (!foundX || !foundY || !foundZ) { throw new IllegalArgumentException("Vertex type does not include" + " the three non-list properties x y and z."); } if (!faceReader.getElementType().getName().equals("face")) { throw new IllegalArgumentException( "faceReader does not read faces."); } boolean foundVertexIndex = false; for (Property p : faceReader.getElementType().getProperties()) { foundVertexIndex |= p.getName().equals("vertex_index") && (p instanceof ListProperty); } if (!foundVertexIndex) { throw new IllegalArgumentException( "Face type does not include a list property named " + "vertex_index."); } // Phase 1: accumulate weighted normals for (Element face = faceReader.readElement(); face != null; face = faceReader.readElement()) { accumulateNormals(vertexReader, face); } // Phase 2: normalize the normal vectors for (Element vertex = vertexReader.readElement(); vertex != null; vertex = vertexReader.readElement()) { normalize(vertex); } }
[ "public", "void", "generateNormals", "(", "final", "RandomElementReader", "vertexReader", ",", "final", "ElementReader", "faceReader", ")", "throws", "IOException", "{", "if", "(", "vertexReader", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"vertexReader must not be null.\"", ")", ";", "}", "if", "(", "faceReader", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"faceReader must not be null.\"", ")", ";", "}", "if", "(", "!", "vertexReader", ".", "getElementType", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "\"vertex\"", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"vertexReader does not read vertices.\"", ")", ";", "}", "boolean", "foundX", "=", "false", ";", "boolean", "foundY", "=", "false", ";", "boolean", "foundZ", "=", "false", ";", "for", "(", "Property", "p", ":", "vertexReader", ".", "getElementType", "(", ")", ".", "getProperties", "(", ")", ")", "{", "foundX", "|=", "p", ".", "getName", "(", ")", ".", "equals", "(", "\"x\"", ")", "&&", "!", "(", "p", "instanceof", "ListProperty", ")", ";", "foundY", "|=", "p", ".", "getName", "(", ")", ".", "equals", "(", "\"y\"", ")", "&&", "!", "(", "p", "instanceof", "ListProperty", ")", ";", "foundZ", "|=", "p", ".", "getName", "(", ")", ".", "equals", "(", "\"z\"", ")", "&&", "!", "(", "p", "instanceof", "ListProperty", ")", ";", "}", "if", "(", "!", "foundX", "||", "!", "foundY", "||", "!", "foundZ", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Vertex type does not include\"", "+", "\" the three non-list properties x y and z.\"", ")", ";", "}", "if", "(", "!", "faceReader", ".", "getElementType", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "\"face\"", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"faceReader does not read faces.\"", ")", ";", "}", "boolean", "foundVertexIndex", "=", "false", ";", "for", "(", "Property", "p", ":", "faceReader", ".", "getElementType", "(", ")", ".", "getProperties", "(", ")", ")", "{", "foundVertexIndex", "|=", "p", ".", "getName", "(", ")", ".", "equals", "(", "\"vertex_index\"", ")", "&&", "(", "p", "instanceof", "ListProperty", ")", ";", "}", "if", "(", "!", "foundVertexIndex", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Face type does not include a list property named \"", "+", "\"vertex_index.\"", ")", ";", "}", "// Phase 1: accumulate weighted normals", "for", "(", "Element", "face", "=", "faceReader", ".", "readElement", "(", ")", ";", "face", "!=", "null", ";", "face", "=", "faceReader", ".", "readElement", "(", ")", ")", "{", "accumulateNormals", "(", "vertexReader", ",", "face", ")", ";", "}", "// Phase 2: normalize the normal vectors", "for", "(", "Element", "vertex", "=", "vertexReader", ".", "readElement", "(", ")", ";", "vertex", "!=", "null", ";", "vertex", "=", "vertexReader", ".", "readElement", "(", ")", ")", "{", "normalize", "(", "vertex", ")", ";", "}", "}" ]
Performs the normal generation. @param vertexReader Reader providing the vertices. @param faceReader Reader providing the faces. @throws IOException if reading fails. @throws NullPointerException if {@code vertexReader} or {@code faceReader} is {@code null}. @throws IllegalArgumentException if <ul> <li>The vertex reader does not provide elements with a type named {@code vertex}.</li> <li>The face reader does not provide elements with a type named {@code face}.</li> <li>The vertex reader does not provide elements with three non-list-properties {@code x}, {@code y} and {@code z}.</li> <li>The face reader does not provide elements a list-property named {@code vertex_index}.</li> </ul>
[ "Performs", "the", "normal", "generation", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/util/NormalGenerator.java#L80-L132
1,982
smurn/jPLY
jply/src/main/java/org/smurn/jply/util/NormalGenerator.java
NormalGenerator.normalize
private void normalize(final Element vertex) { double nx = vertex.getDouble("nx"); double ny = vertex.getDouble("ny"); double nz = vertex.getDouble("nz"); double n = Math.sqrt(nx * nx + ny * ny + nz * nz); if (n < EPSILON) { vertex.setDouble("nx", 0); vertex.setDouble("ny", 0); vertex.setDouble("nz", 0); } vertex.setDouble("nx", nx / n); vertex.setDouble("ny", ny / n); vertex.setDouble("nz", nz / n); }
java
private void normalize(final Element vertex) { double nx = vertex.getDouble("nx"); double ny = vertex.getDouble("ny"); double nz = vertex.getDouble("nz"); double n = Math.sqrt(nx * nx + ny * ny + nz * nz); if (n < EPSILON) { vertex.setDouble("nx", 0); vertex.setDouble("ny", 0); vertex.setDouble("nz", 0); } vertex.setDouble("nx", nx / n); vertex.setDouble("ny", ny / n); vertex.setDouble("nz", nz / n); }
[ "private", "void", "normalize", "(", "final", "Element", "vertex", ")", "{", "double", "nx", "=", "vertex", ".", "getDouble", "(", "\"nx\"", ")", ";", "double", "ny", "=", "vertex", ".", "getDouble", "(", "\"ny\"", ")", ";", "double", "nz", "=", "vertex", ".", "getDouble", "(", "\"nz\"", ")", ";", "double", "n", "=", "Math", ".", "sqrt", "(", "nx", "*", "nx", "+", "ny", "*", "ny", "+", "nz", "*", "nz", ")", ";", "if", "(", "n", "<", "EPSILON", ")", "{", "vertex", ".", "setDouble", "(", "\"nx\"", ",", "0", ")", ";", "vertex", ".", "setDouble", "(", "\"ny\"", ",", "0", ")", ";", "vertex", ".", "setDouble", "(", "\"nz\"", ",", "0", ")", ";", "}", "vertex", ".", "setDouble", "(", "\"nx\"", ",", "nx", "/", "n", ")", ";", "vertex", ".", "setDouble", "(", "\"ny\"", ",", "ny", "/", "n", ")", ";", "vertex", ".", "setDouble", "(", "\"nz\"", ",", "nz", "/", "n", ")", ";", "}" ]
Normalizes the normal vector of a vertex. @param vertex Vertex to normalize.
[ "Normalizes", "the", "normal", "vector", "of", "a", "vertex", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/util/NormalGenerator.java#L138-L151
1,983
smurn/jPLY
jply/src/main/java/org/smurn/jply/util/NormalGenerator.java
NormalGenerator.accumulateNormals
private void accumulateNormals(final RandomElementReader vertices, final Element face) throws IOException { int[] indices = face.getIntList("vertex_index"); for (int i = 0; i < indices.length; i++) { int pre; int post; if (counterClockwise) { pre = (i + indices.length - 1) % indices.length; post = (i + 1) % indices.length; } else { pre = (i + 1) % indices.length; post = (i + indices.length - 1) % indices.length; } Element centerVertex; Element preVertex; Element postVertex; try { centerVertex = vertices.readElement(indices[i]); preVertex = vertices.readElement(indices[pre]); postVertex = vertices.readElement(indices[post]); accumulateNormal(centerVertex, preVertex, postVertex); } catch (IndexOutOfBoundsException e) { // we ignore defects in the normals. } } }
java
private void accumulateNormals(final RandomElementReader vertices, final Element face) throws IOException { int[] indices = face.getIntList("vertex_index"); for (int i = 0; i < indices.length; i++) { int pre; int post; if (counterClockwise) { pre = (i + indices.length - 1) % indices.length; post = (i + 1) % indices.length; } else { pre = (i + 1) % indices.length; post = (i + indices.length - 1) % indices.length; } Element centerVertex; Element preVertex; Element postVertex; try { centerVertex = vertices.readElement(indices[i]); preVertex = vertices.readElement(indices[pre]); postVertex = vertices.readElement(indices[post]); accumulateNormal(centerVertex, preVertex, postVertex); } catch (IndexOutOfBoundsException e) { // we ignore defects in the normals. } } }
[ "private", "void", "accumulateNormals", "(", "final", "RandomElementReader", "vertices", ",", "final", "Element", "face", ")", "throws", "IOException", "{", "int", "[", "]", "indices", "=", "face", ".", "getIntList", "(", "\"vertex_index\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "indices", ".", "length", ";", "i", "++", ")", "{", "int", "pre", ";", "int", "post", ";", "if", "(", "counterClockwise", ")", "{", "pre", "=", "(", "i", "+", "indices", ".", "length", "-", "1", ")", "%", "indices", ".", "length", ";", "post", "=", "(", "i", "+", "1", ")", "%", "indices", ".", "length", ";", "}", "else", "{", "pre", "=", "(", "i", "+", "1", ")", "%", "indices", ".", "length", ";", "post", "=", "(", "i", "+", "indices", ".", "length", "-", "1", ")", "%", "indices", ".", "length", ";", "}", "Element", "centerVertex", ";", "Element", "preVertex", ";", "Element", "postVertex", ";", "try", "{", "centerVertex", "=", "vertices", ".", "readElement", "(", "indices", "[", "i", "]", ")", ";", "preVertex", "=", "vertices", ".", "readElement", "(", "indices", "[", "pre", "]", ")", ";", "postVertex", "=", "vertices", ".", "readElement", "(", "indices", "[", "post", "]", ")", ";", "accumulateNormal", "(", "centerVertex", ",", "preVertex", ",", "postVertex", ")", ";", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "// we ignore defects in the normals.", "}", "}", "}" ]
Calculate the face normal, weight by angle and add them to the vertices. @param vertices Vertices buffer. @param face Face to process. @throws IOException if reading fails.
[ "Calculate", "the", "face", "normal", "weight", "by", "angle", "and", "add", "them", "to", "the", "vertices", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/util/NormalGenerator.java#L160-L186
1,984
smurn/jPLY
jply/src/main/java/org/smurn/jply/util/NormalGenerator.java
NormalGenerator.accumulateNormal
private void accumulateNormal(final Element center, final Element pre, final Element post) { double cx = center.getDouble("x"); double cy = center.getDouble("y"); double cz = center.getDouble("z"); double ax = post.getDouble("x") - cx; double ay = post.getDouble("y") - cy; double az = post.getDouble("z") - cz; double a = Math.sqrt(ax * ax + ay * ay + az * az); if (a < EPSILON) { return; } double bx = pre.getDouble("x") - cx; double by = pre.getDouble("y") - cy; double bz = pre.getDouble("z") - cz; double b = Math.sqrt(bx * bx + by * by + bz * bz); if (b < EPSILON) { return; } double nx = ay * bz - az * by; double ny = az * bx - ax * bz; double nz = ax * by - ay * bx; double n = Math.sqrt(nx * nx + ny * ny + nz * nz); if (n < EPSILON) { return; } double sin = n / (a * b); double dot = ax * bx + ay * by + az * bz; double angle; if (dot < 0) { angle = Math.PI - Math.asin(sin); } else { angle = Math.asin(sin); } double factor = angle / n; nx *= factor; ny *= factor; nz *= factor; center.setDouble("nx", center.getDouble("nx") + nx); center.setDouble("ny", center.getDouble("ny") + ny); center.setDouble("nz", center.getDouble("nz") + nz); }
java
private void accumulateNormal(final Element center, final Element pre, final Element post) { double cx = center.getDouble("x"); double cy = center.getDouble("y"); double cz = center.getDouble("z"); double ax = post.getDouble("x") - cx; double ay = post.getDouble("y") - cy; double az = post.getDouble("z") - cz; double a = Math.sqrt(ax * ax + ay * ay + az * az); if (a < EPSILON) { return; } double bx = pre.getDouble("x") - cx; double by = pre.getDouble("y") - cy; double bz = pre.getDouble("z") - cz; double b = Math.sqrt(bx * bx + by * by + bz * bz); if (b < EPSILON) { return; } double nx = ay * bz - az * by; double ny = az * bx - ax * bz; double nz = ax * by - ay * bx; double n = Math.sqrt(nx * nx + ny * ny + nz * nz); if (n < EPSILON) { return; } double sin = n / (a * b); double dot = ax * bx + ay * by + az * bz; double angle; if (dot < 0) { angle = Math.PI - Math.asin(sin); } else { angle = Math.asin(sin); } double factor = angle / n; nx *= factor; ny *= factor; nz *= factor; center.setDouble("nx", center.getDouble("nx") + nx); center.setDouble("ny", center.getDouble("ny") + ny); center.setDouble("nz", center.getDouble("nz") + nz); }
[ "private", "void", "accumulateNormal", "(", "final", "Element", "center", ",", "final", "Element", "pre", ",", "final", "Element", "post", ")", "{", "double", "cx", "=", "center", ".", "getDouble", "(", "\"x\"", ")", ";", "double", "cy", "=", "center", ".", "getDouble", "(", "\"y\"", ")", ";", "double", "cz", "=", "center", ".", "getDouble", "(", "\"z\"", ")", ";", "double", "ax", "=", "post", ".", "getDouble", "(", "\"x\"", ")", "-", "cx", ";", "double", "ay", "=", "post", ".", "getDouble", "(", "\"y\"", ")", "-", "cy", ";", "double", "az", "=", "post", ".", "getDouble", "(", "\"z\"", ")", "-", "cz", ";", "double", "a", "=", "Math", ".", "sqrt", "(", "ax", "*", "ax", "+", "ay", "*", "ay", "+", "az", "*", "az", ")", ";", "if", "(", "a", "<", "EPSILON", ")", "{", "return", ";", "}", "double", "bx", "=", "pre", ".", "getDouble", "(", "\"x\"", ")", "-", "cx", ";", "double", "by", "=", "pre", ".", "getDouble", "(", "\"y\"", ")", "-", "cy", ";", "double", "bz", "=", "pre", ".", "getDouble", "(", "\"z\"", ")", "-", "cz", ";", "double", "b", "=", "Math", ".", "sqrt", "(", "bx", "*", "bx", "+", "by", "*", "by", "+", "bz", "*", "bz", ")", ";", "if", "(", "b", "<", "EPSILON", ")", "{", "return", ";", "}", "double", "nx", "=", "ay", "*", "bz", "-", "az", "*", "by", ";", "double", "ny", "=", "az", "*", "bx", "-", "ax", "*", "bz", ";", "double", "nz", "=", "ax", "*", "by", "-", "ay", "*", "bx", ";", "double", "n", "=", "Math", ".", "sqrt", "(", "nx", "*", "nx", "+", "ny", "*", "ny", "+", "nz", "*", "nz", ")", ";", "if", "(", "n", "<", "EPSILON", ")", "{", "return", ";", "}", "double", "sin", "=", "n", "/", "(", "a", "*", "b", ")", ";", "double", "dot", "=", "ax", "*", "bx", "+", "ay", "*", "by", "+", "az", "*", "bz", ";", "double", "angle", ";", "if", "(", "dot", "<", "0", ")", "{", "angle", "=", "Math", ".", "PI", "-", "Math", ".", "asin", "(", "sin", ")", ";", "}", "else", "{", "angle", "=", "Math", ".", "asin", "(", "sin", ")", ";", "}", "double", "factor", "=", "angle", "/", "n", ";", "nx", "*=", "factor", ";", "ny", "*=", "factor", ";", "nz", "*=", "factor", ";", "center", ".", "setDouble", "(", "\"nx\"", ",", "center", ".", "getDouble", "(", "\"nx\"", ")", "+", "nx", ")", ";", "center", ".", "setDouble", "(", "\"ny\"", ",", "center", ".", "getDouble", "(", "\"ny\"", ")", "+", "ny", ")", ";", "center", ".", "setDouble", "(", "\"nz\"", ",", "center", ".", "getDouble", "(", "\"nz\"", ")", "+", "nz", ")", ";", "}" ]
Calculate the face normal, weight by angle and add them to the vertex. @param center Vertex for which to sum the normal. @param pre Neighbor vertex on the face. @param post Neighbor vertex on the face.
[ "Calculate", "the", "face", "normal", "weight", "by", "angle", "and", "add", "them", "to", "the", "vertex", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/util/NormalGenerator.java#L195-L242
1,985
smurn/jPLY
LWJGLDemo/src/main/java/org/smurn/jply/lwjgldemo/LWJGLDemo.java
LWJGLDemo.fillBuffers
private static RectBounds fillBuffers( PlyReader plyReader, FloatBuffer vertexBuffer, IntBuffer indexBuffer) throws IOException { // Get all element readers and find the two providing // the vertices and triangles. ElementReader reader = plyReader.nextElementReader(); RectBounds bounds = null; while (reader != null) { if (reader.getElementType().getName().equals("vertex")) { bounds = fillVertexBuffer(reader, vertexBuffer); } else if (reader.getElementType().getName().equals("face")) { fillIndexBuffer(reader, indexBuffer); } reader.close(); reader = plyReader.nextElementReader(); } return bounds; }
java
private static RectBounds fillBuffers( PlyReader plyReader, FloatBuffer vertexBuffer, IntBuffer indexBuffer) throws IOException { // Get all element readers and find the two providing // the vertices and triangles. ElementReader reader = plyReader.nextElementReader(); RectBounds bounds = null; while (reader != null) { if (reader.getElementType().getName().equals("vertex")) { bounds = fillVertexBuffer(reader, vertexBuffer); } else if (reader.getElementType().getName().equals("face")) { fillIndexBuffer(reader, indexBuffer); } reader.close(); reader = plyReader.nextElementReader(); } return bounds; }
[ "private", "static", "RectBounds", "fillBuffers", "(", "PlyReader", "plyReader", ",", "FloatBuffer", "vertexBuffer", ",", "IntBuffer", "indexBuffer", ")", "throws", "IOException", "{", "// Get all element readers and find the two providing ", "// the vertices and triangles.", "ElementReader", "reader", "=", "plyReader", ".", "nextElementReader", "(", ")", ";", "RectBounds", "bounds", "=", "null", ";", "while", "(", "reader", "!=", "null", ")", "{", "if", "(", "reader", ".", "getElementType", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "\"vertex\"", ")", ")", "{", "bounds", "=", "fillVertexBuffer", "(", "reader", ",", "vertexBuffer", ")", ";", "}", "else", "if", "(", "reader", ".", "getElementType", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "\"face\"", ")", ")", "{", "fillIndexBuffer", "(", "reader", ",", "indexBuffer", ")", ";", "}", "reader", ".", "close", "(", ")", ";", "reader", "=", "plyReader", ".", "nextElementReader", "(", ")", ";", "}", "return", "bounds", ";", "}" ]
Loads the data from the PLY file into the buffers.
[ "Loads", "the", "data", "from", "the", "PLY", "file", "into", "the", "buffers", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/LWJGLDemo/src/main/java/org/smurn/jply/lwjgldemo/LWJGLDemo.java#L249-L269
1,986
smurn/jPLY
LWJGLDemo/src/main/java/org/smurn/jply/lwjgldemo/LWJGLDemo.java
LWJGLDemo.fillVertexBuffer
private static RectBounds fillVertexBuffer( ElementReader reader, FloatBuffer vertexBuffer) throws IOException { // Just go though the vertices and store the coordinates in the buffer. Element vertex = reader.readElement(); RectBounds bounds = new RectBounds(); while (vertex != null) { double x = vertex.getDouble("x"); double y = vertex.getDouble("y"); double z = vertex.getDouble("z"); double nx = vertex.getDouble("nx"); double ny = vertex.getDouble("ny"); double nz = vertex.getDouble("nz"); vertexBuffer.put((float) x); vertexBuffer.put((float) y); vertexBuffer.put((float) z); vertexBuffer.put((float) nx); vertexBuffer.put((float) ny); vertexBuffer.put((float) nz); bounds.addPoint(x, y, z); vertex = reader.readElement(); } return bounds; }
java
private static RectBounds fillVertexBuffer( ElementReader reader, FloatBuffer vertexBuffer) throws IOException { // Just go though the vertices and store the coordinates in the buffer. Element vertex = reader.readElement(); RectBounds bounds = new RectBounds(); while (vertex != null) { double x = vertex.getDouble("x"); double y = vertex.getDouble("y"); double z = vertex.getDouble("z"); double nx = vertex.getDouble("nx"); double ny = vertex.getDouble("ny"); double nz = vertex.getDouble("nz"); vertexBuffer.put((float) x); vertexBuffer.put((float) y); vertexBuffer.put((float) z); vertexBuffer.put((float) nx); vertexBuffer.put((float) ny); vertexBuffer.put((float) nz); bounds.addPoint(x, y, z); vertex = reader.readElement(); } return bounds; }
[ "private", "static", "RectBounds", "fillVertexBuffer", "(", "ElementReader", "reader", ",", "FloatBuffer", "vertexBuffer", ")", "throws", "IOException", "{", "// Just go though the vertices and store the coordinates in the buffer.", "Element", "vertex", "=", "reader", ".", "readElement", "(", ")", ";", "RectBounds", "bounds", "=", "new", "RectBounds", "(", ")", ";", "while", "(", "vertex", "!=", "null", ")", "{", "double", "x", "=", "vertex", ".", "getDouble", "(", "\"x\"", ")", ";", "double", "y", "=", "vertex", ".", "getDouble", "(", "\"y\"", ")", ";", "double", "z", "=", "vertex", ".", "getDouble", "(", "\"z\"", ")", ";", "double", "nx", "=", "vertex", ".", "getDouble", "(", "\"nx\"", ")", ";", "double", "ny", "=", "vertex", ".", "getDouble", "(", "\"ny\"", ")", ";", "double", "nz", "=", "vertex", ".", "getDouble", "(", "\"nz\"", ")", ";", "vertexBuffer", ".", "put", "(", "(", "float", ")", "x", ")", ";", "vertexBuffer", ".", "put", "(", "(", "float", ")", "y", ")", ";", "vertexBuffer", ".", "put", "(", "(", "float", ")", "z", ")", ";", "vertexBuffer", ".", "put", "(", "(", "float", ")", "nx", ")", ";", "vertexBuffer", ".", "put", "(", "(", "float", ")", "ny", ")", ";", "vertexBuffer", ".", "put", "(", "(", "float", ")", "nz", ")", ";", "bounds", ".", "addPoint", "(", "x", ",", "y", ",", "z", ")", ";", "vertex", "=", "reader", ".", "readElement", "(", ")", ";", "}", "return", "bounds", ";", "}" ]
Fill the vertex buffer with the data from the PLY file.
[ "Fill", "the", "vertex", "buffer", "with", "the", "data", "from", "the", "PLY", "file", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/LWJGLDemo/src/main/java/org/smurn/jply/lwjgldemo/LWJGLDemo.java#L274-L298
1,987
smurn/jPLY
LWJGLDemo/src/main/java/org/smurn/jply/lwjgldemo/LWJGLDemo.java
LWJGLDemo.fillIndexBuffer
private static void fillIndexBuffer( ElementReader reader, IntBuffer indexBuffer) throws IOException { // Just go though the triangles and store the indices in the buffer. Element triangle = reader.readElement(); while (triangle != null) { int[] indices = triangle.getIntList("vertex_index"); for (int index : indices) { indexBuffer.put(index); } triangle = reader.readElement(); } }
java
private static void fillIndexBuffer( ElementReader reader, IntBuffer indexBuffer) throws IOException { // Just go though the triangles and store the indices in the buffer. Element triangle = reader.readElement(); while (triangle != null) { int[] indices = triangle.getIntList("vertex_index"); for (int index : indices) { indexBuffer.put(index); } triangle = reader.readElement(); } }
[ "private", "static", "void", "fillIndexBuffer", "(", "ElementReader", "reader", ",", "IntBuffer", "indexBuffer", ")", "throws", "IOException", "{", "// Just go though the triangles and store the indices in the buffer.", "Element", "triangle", "=", "reader", ".", "readElement", "(", ")", ";", "while", "(", "triangle", "!=", "null", ")", "{", "int", "[", "]", "indices", "=", "triangle", ".", "getIntList", "(", "\"vertex_index\"", ")", ";", "for", "(", "int", "index", ":", "indices", ")", "{", "indexBuffer", ".", "put", "(", "index", ")", ";", "}", "triangle", "=", "reader", ".", "readElement", "(", ")", ";", "}", "}" ]
Fill the index buffer with the data from the PLY file.
[ "Fill", "the", "index", "buffer", "with", "the", "data", "from", "the", "PLY", "file", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/LWJGLDemo/src/main/java/org/smurn/jply/lwjgldemo/LWJGLDemo.java#L303-L318
1,988
smurn/jPLY
LWJGLDemo/src/main/java/org/smurn/jply/lwjgldemo/LWJGLDemo.java
LWJGLDemo.createShaders
private static int createShaders() throws IOException { // load and compile the vertex shader. String vertexShaderCode = IOUtils.toString( ClassLoader.getSystemResourceAsStream("vertexShader.glsl")); int vertexShaderId = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); glShaderSourceARB(vertexShaderId, vertexShaderCode); glCompileShaderARB(vertexShaderId); printLogInfo(vertexShaderId); // load and compile the fragment shader. String fragmentShaderCode = IOUtils.toString( ClassLoader.getSystemResourceAsStream("fragmentShader.glsl")); int fragmentShaderId = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); glShaderSourceARB(fragmentShaderId, fragmentShaderCode); glCompileShaderARB(fragmentShaderId); printLogInfo(fragmentShaderId); // combine the two into a program. int programId = ARBShaderObjects.glCreateProgramObjectARB(); glAttachObjectARB(programId, vertexShaderId); glAttachObjectARB(programId, fragmentShaderId); glValidateProgramARB(programId); glLinkProgramARB(programId); printLogInfo(programId); return programId; }
java
private static int createShaders() throws IOException { // load and compile the vertex shader. String vertexShaderCode = IOUtils.toString( ClassLoader.getSystemResourceAsStream("vertexShader.glsl")); int vertexShaderId = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); glShaderSourceARB(vertexShaderId, vertexShaderCode); glCompileShaderARB(vertexShaderId); printLogInfo(vertexShaderId); // load and compile the fragment shader. String fragmentShaderCode = IOUtils.toString( ClassLoader.getSystemResourceAsStream("fragmentShader.glsl")); int fragmentShaderId = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); glShaderSourceARB(fragmentShaderId, fragmentShaderCode); glCompileShaderARB(fragmentShaderId); printLogInfo(fragmentShaderId); // combine the two into a program. int programId = ARBShaderObjects.glCreateProgramObjectARB(); glAttachObjectARB(programId, vertexShaderId); glAttachObjectARB(programId, fragmentShaderId); glValidateProgramARB(programId); glLinkProgramARB(programId); printLogInfo(programId); return programId; }
[ "private", "static", "int", "createShaders", "(", ")", "throws", "IOException", "{", "// load and compile the vertex shader.", "String", "vertexShaderCode", "=", "IOUtils", ".", "toString", "(", "ClassLoader", ".", "getSystemResourceAsStream", "(", "\"vertexShader.glsl\"", ")", ")", ";", "int", "vertexShaderId", "=", "glCreateShaderObjectARB", "(", "GL_VERTEX_SHADER_ARB", ")", ";", "glShaderSourceARB", "(", "vertexShaderId", ",", "vertexShaderCode", ")", ";", "glCompileShaderARB", "(", "vertexShaderId", ")", ";", "printLogInfo", "(", "vertexShaderId", ")", ";", "// load and compile the fragment shader.", "String", "fragmentShaderCode", "=", "IOUtils", ".", "toString", "(", "ClassLoader", ".", "getSystemResourceAsStream", "(", "\"fragmentShader.glsl\"", ")", ")", ";", "int", "fragmentShaderId", "=", "glCreateShaderObjectARB", "(", "GL_FRAGMENT_SHADER_ARB", ")", ";", "glShaderSourceARB", "(", "fragmentShaderId", ",", "fragmentShaderCode", ")", ";", "glCompileShaderARB", "(", "fragmentShaderId", ")", ";", "printLogInfo", "(", "fragmentShaderId", ")", ";", "// combine the two into a program.", "int", "programId", "=", "ARBShaderObjects", ".", "glCreateProgramObjectARB", "(", ")", ";", "glAttachObjectARB", "(", "programId", ",", "vertexShaderId", ")", ";", "glAttachObjectARB", "(", "programId", ",", "fragmentShaderId", ")", ";", "glValidateProgramARB", "(", "programId", ")", ";", "glLinkProgramARB", "(", "programId", ")", ";", "printLogInfo", "(", "programId", ")", ";", "return", "programId", ";", "}" ]
Loads the vertex and fragment shader.
[ "Loads", "the", "vertex", "and", "fragment", "shader", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/LWJGLDemo/src/main/java/org/smurn/jply/lwjgldemo/LWJGLDemo.java#L323-L350
1,989
smurn/jPLY
LWJGLDemo/src/main/java/org/smurn/jply/lwjgldemo/LWJGLDemo.java
LWJGLDemo.printLogInfo
private static boolean printLogInfo(int obj) { IntBuffer iVal = BufferUtils.createIntBuffer(1); ARBShaderObjects.glGetObjectParameterARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB, iVal); int length = iVal.get(); if (length > 1) { // We have some info we need to output. ByteBuffer infoLog = BufferUtils.createByteBuffer(length); iVal.flip(); ARBShaderObjects.glGetInfoLogARB(obj, iVal, infoLog); byte[] infoBytes = new byte[length]; infoLog.get(infoBytes); String out = new String(infoBytes); System.out.println("Info log:\n" + out); } else { return true; } return false; }
java
private static boolean printLogInfo(int obj) { IntBuffer iVal = BufferUtils.createIntBuffer(1); ARBShaderObjects.glGetObjectParameterARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB, iVal); int length = iVal.get(); if (length > 1) { // We have some info we need to output. ByteBuffer infoLog = BufferUtils.createByteBuffer(length); iVal.flip(); ARBShaderObjects.glGetInfoLogARB(obj, iVal, infoLog); byte[] infoBytes = new byte[length]; infoLog.get(infoBytes); String out = new String(infoBytes); System.out.println("Info log:\n" + out); } else { return true; } return false; }
[ "private", "static", "boolean", "printLogInfo", "(", "int", "obj", ")", "{", "IntBuffer", "iVal", "=", "BufferUtils", ".", "createIntBuffer", "(", "1", ")", ";", "ARBShaderObjects", ".", "glGetObjectParameterARB", "(", "obj", ",", "ARBShaderObjects", ".", "GL_OBJECT_INFO_LOG_LENGTH_ARB", ",", "iVal", ")", ";", "int", "length", "=", "iVal", ".", "get", "(", ")", ";", "if", "(", "length", ">", "1", ")", "{", "// We have some info we need to output.", "ByteBuffer", "infoLog", "=", "BufferUtils", ".", "createByteBuffer", "(", "length", ")", ";", "iVal", ".", "flip", "(", ")", ";", "ARBShaderObjects", ".", "glGetInfoLogARB", "(", "obj", ",", "iVal", ",", "infoLog", ")", ";", "byte", "[", "]", "infoBytes", "=", "new", "byte", "[", "length", "]", ";", "infoLog", ".", "get", "(", "infoBytes", ")", ";", "String", "out", "=", "new", "String", "(", "infoBytes", ")", ";", "System", ".", "out", ".", "println", "(", "\"Info log:\\n\"", "+", "out", ")", ";", "}", "else", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Helper to get the log messages from the shader compiler.
[ "Helper", "to", "get", "the", "log", "messages", "from", "the", "shader", "compiler", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/LWJGLDemo/src/main/java/org/smurn/jply/lwjgldemo/LWJGLDemo.java#L355-L374
1,990
smurn/jPLY
jply/src/main/java/org/smurn/jply/UnbufferedASCIIReader.java
UnbufferedASCIIReader.readLine
public String readLine() throws IOException { StringBuilder str = new StringBuilder(); while (true) { int c = read(); if (c < 0) { break; } if (c == '\n') { // if possible consume another '\r' int peek = stream.read(); if (peek != '\r' && peek >= 0){ stream.unread(peek); } break; } if (c == '\r') { // if possible consume another '\n' int peek = stream.read(); if (peek != '\n' && peek >= 0){ stream.unread(peek); } break; } str.append((char) c); } return str.toString(); }
java
public String readLine() throws IOException { StringBuilder str = new StringBuilder(); while (true) { int c = read(); if (c < 0) { break; } if (c == '\n') { // if possible consume another '\r' int peek = stream.read(); if (peek != '\r' && peek >= 0){ stream.unread(peek); } break; } if (c == '\r') { // if possible consume another '\n' int peek = stream.read(); if (peek != '\n' && peek >= 0){ stream.unread(peek); } break; } str.append((char) c); } return str.toString(); }
[ "public", "String", "readLine", "(", ")", "throws", "IOException", "{", "StringBuilder", "str", "=", "new", "StringBuilder", "(", ")", ";", "while", "(", "true", ")", "{", "int", "c", "=", "read", "(", ")", ";", "if", "(", "c", "<", "0", ")", "{", "break", ";", "}", "if", "(", "c", "==", "'", "'", ")", "{", "// if possible consume another '\\r'", "int", "peek", "=", "stream", ".", "read", "(", ")", ";", "if", "(", "peek", "!=", "'", "'", "&&", "peek", ">=", "0", ")", "{", "stream", ".", "unread", "(", "peek", ")", ";", "}", "break", ";", "}", "if", "(", "c", "==", "'", "'", ")", "{", "// if possible consume another '\\n'", "int", "peek", "=", "stream", ".", "read", "(", ")", ";", "if", "(", "peek", "!=", "'", "'", "&&", "peek", ">=", "0", ")", "{", "stream", ".", "unread", "(", "peek", ")", ";", "}", "break", ";", "}", "str", ".", "append", "(", "(", "char", ")", "c", ")", ";", "}", "return", "str", ".", "toString", "(", ")", ";", "}" ]
Reads the next line. @return The next line or {@code null} if the end of the stream is reached. @throws IOException if reading fails.
[ "Reads", "the", "next", "line", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/UnbufferedASCIIReader.java#L52-L78
1,991
smurn/jPLY
LWJGLDemo/src/main/java/org/smurn/jply/lwjgldemo/RectBounds.java
RectBounds.getScaleToUnityBox
public double getScaleToUnityBox(){ double largestEdge = 0; largestEdge = Math.max(largestEdge, maxX - minX); largestEdge = Math.max(largestEdge, maxY - minY); largestEdge = Math.max(largestEdge, maxZ - minZ); return 1.0 / largestEdge; }
java
public double getScaleToUnityBox(){ double largestEdge = 0; largestEdge = Math.max(largestEdge, maxX - minX); largestEdge = Math.max(largestEdge, maxY - minY); largestEdge = Math.max(largestEdge, maxZ - minZ); return 1.0 / largestEdge; }
[ "public", "double", "getScaleToUnityBox", "(", ")", "{", "double", "largestEdge", "=", "0", ";", "largestEdge", "=", "Math", ".", "max", "(", "largestEdge", ",", "maxX", "-", "minX", ")", ";", "largestEdge", "=", "Math", ".", "max", "(", "largestEdge", ",", "maxY", "-", "minY", ")", ";", "largestEdge", "=", "Math", ".", "max", "(", "largestEdge", ",", "maxZ", "-", "minZ", ")", ";", "return", "1.0", "/", "largestEdge", ";", "}" ]
Gets the scale factor by which the box needs to be multiplied that it fits into a cube with edge length 1.
[ "Gets", "the", "scale", "factor", "by", "which", "the", "box", "needs", "to", "be", "multiplied", "that", "it", "fits", "into", "a", "cube", "with", "edge", "length", "1", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/LWJGLDemo/src/main/java/org/smurn/jply/lwjgldemo/RectBounds.java#L99-L105
1,992
smurn/jPLY
jply/src/main/java/org/smurn/jply/util/NormalizingPlyReader.java
NormalizingPlyReader.addNormalProps
private static ElementType addNormalProps(final ElementType sourceType) { List<Property> properties = new ArrayList<Property>(); boolean foundNX = false; boolean foundNY = false; boolean foundNZ = false; for (Property property : sourceType.getProperties()) { if (property.getName().equals("nx")) { foundNX = true; } if (property.getName().equals("ny")) { foundNY = true; } if (property.getName().equals("nz")) { foundNZ = true; } properties.add(property); } if (foundNX && foundNY && foundNZ) { return sourceType; } if (!foundNX) { properties.add(new Property("nx", DataType.DOUBLE)); } if (!foundNY) { properties.add(new Property("ny", DataType.DOUBLE)); } if (!foundNZ) { properties.add(new Property("nz", DataType.DOUBLE)); } return new ElementType("vertex", properties); }
java
private static ElementType addNormalProps(final ElementType sourceType) { List<Property> properties = new ArrayList<Property>(); boolean foundNX = false; boolean foundNY = false; boolean foundNZ = false; for (Property property : sourceType.getProperties()) { if (property.getName().equals("nx")) { foundNX = true; } if (property.getName().equals("ny")) { foundNY = true; } if (property.getName().equals("nz")) { foundNZ = true; } properties.add(property); } if (foundNX && foundNY && foundNZ) { return sourceType; } if (!foundNX) { properties.add(new Property("nx", DataType.DOUBLE)); } if (!foundNY) { properties.add(new Property("ny", DataType.DOUBLE)); } if (!foundNZ) { properties.add(new Property("nz", DataType.DOUBLE)); } return new ElementType("vertex", properties); }
[ "private", "static", "ElementType", "addNormalProps", "(", "final", "ElementType", "sourceType", ")", "{", "List", "<", "Property", ">", "properties", "=", "new", "ArrayList", "<", "Property", ">", "(", ")", ";", "boolean", "foundNX", "=", "false", ";", "boolean", "foundNY", "=", "false", ";", "boolean", "foundNZ", "=", "false", ";", "for", "(", "Property", "property", ":", "sourceType", ".", "getProperties", "(", ")", ")", "{", "if", "(", "property", ".", "getName", "(", ")", ".", "equals", "(", "\"nx\"", ")", ")", "{", "foundNX", "=", "true", ";", "}", "if", "(", "property", ".", "getName", "(", ")", ".", "equals", "(", "\"ny\"", ")", ")", "{", "foundNY", "=", "true", ";", "}", "if", "(", "property", ".", "getName", "(", ")", ".", "equals", "(", "\"nz\"", ")", ")", "{", "foundNZ", "=", "true", ";", "}", "properties", ".", "add", "(", "property", ")", ";", "}", "if", "(", "foundNX", "&&", "foundNY", "&&", "foundNZ", ")", "{", "return", "sourceType", ";", "}", "if", "(", "!", "foundNX", ")", "{", "properties", ".", "add", "(", "new", "Property", "(", "\"nx\"", ",", "DataType", ".", "DOUBLE", ")", ")", ";", "}", "if", "(", "!", "foundNY", ")", "{", "properties", ".", "add", "(", "new", "Property", "(", "\"ny\"", ",", "DataType", ".", "DOUBLE", ")", ")", ";", "}", "if", "(", "!", "foundNZ", ")", "{", "properties", ".", "add", "(", "new", "Property", "(", "\"nz\"", ",", "DataType", ".", "DOUBLE", ")", ")", ";", "}", "return", "new", "ElementType", "(", "\"vertex\"", ",", "properties", ")", ";", "}" ]
Adds properties for nx, ny and nz if they don't already exist. @param sourceType Source vertex type. @return Vertex type guaranteed to have nx, ny and nz.
[ "Adds", "properties", "for", "nx", "ny", "and", "nz", "if", "they", "don", "t", "already", "exist", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/util/NormalizingPlyReader.java#L262-L292
1,993
smurn/jPLY
jply/src/main/java/org/smurn/jply/util/NormalizingPlyReader.java
NormalizingPlyReader.addTextureProps
private static ElementType addTextureProps(final ElementType sourceType) { List<Property> properties = new ArrayList<Property>(); boolean foundU = false; boolean foundV = false; for (Property property : sourceType.getProperties()) { if (property.getName().equals("u")) { foundU = true; } if (property.getName().equals("v")) { foundV = true; } properties.add(property); } if (foundU && foundV) { return sourceType; } if (!foundU) { properties.add(new Property("u", DataType.DOUBLE)); } if (!foundV) { properties.add(new Property("v", DataType.DOUBLE)); } return new ElementType("vertex", properties); }
java
private static ElementType addTextureProps(final ElementType sourceType) { List<Property> properties = new ArrayList<Property>(); boolean foundU = false; boolean foundV = false; for (Property property : sourceType.getProperties()) { if (property.getName().equals("u")) { foundU = true; } if (property.getName().equals("v")) { foundV = true; } properties.add(property); } if (foundU && foundV) { return sourceType; } if (!foundU) { properties.add(new Property("u", DataType.DOUBLE)); } if (!foundV) { properties.add(new Property("v", DataType.DOUBLE)); } return new ElementType("vertex", properties); }
[ "private", "static", "ElementType", "addTextureProps", "(", "final", "ElementType", "sourceType", ")", "{", "List", "<", "Property", ">", "properties", "=", "new", "ArrayList", "<", "Property", ">", "(", ")", ";", "boolean", "foundU", "=", "false", ";", "boolean", "foundV", "=", "false", ";", "for", "(", "Property", "property", ":", "sourceType", ".", "getProperties", "(", ")", ")", "{", "if", "(", "property", ".", "getName", "(", ")", ".", "equals", "(", "\"u\"", ")", ")", "{", "foundU", "=", "true", ";", "}", "if", "(", "property", ".", "getName", "(", ")", ".", "equals", "(", "\"v\"", ")", ")", "{", "foundV", "=", "true", ";", "}", "properties", ".", "add", "(", "property", ")", ";", "}", "if", "(", "foundU", "&&", "foundV", ")", "{", "return", "sourceType", ";", "}", "if", "(", "!", "foundU", ")", "{", "properties", ".", "add", "(", "new", "Property", "(", "\"u\"", ",", "DataType", ".", "DOUBLE", ")", ")", ";", "}", "if", "(", "!", "foundV", ")", "{", "properties", ".", "add", "(", "new", "Property", "(", "\"v\"", ",", "DataType", ".", "DOUBLE", ")", ")", ";", "}", "return", "new", "ElementType", "(", "\"vertex\"", ",", "properties", ")", ";", "}" ]
Adds properties for u and v if they don't already exist. @param sourceType Source vertex type. @return Vertex type guaranteed to have u and v.
[ "Adds", "properties", "for", "u", "and", "v", "if", "they", "don", "t", "already", "exist", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/util/NormalizingPlyReader.java#L299-L323
1,994
smurn/jPLY
jply/src/main/java/org/smurn/jply/Element.java
Element.setDouble
public void setDouble(final String propertyName, final double value) { if (propertyName == null) { throw new NullPointerException("propertyName must not be null."); } Integer index = propertyMap.get(propertyName); if (index == null) { throw new IllegalArgumentException("non existent property: '" + propertyName + "'."); } this.data[index] = new double[]{value}; }
java
public void setDouble(final String propertyName, final double value) { if (propertyName == null) { throw new NullPointerException("propertyName must not be null."); } Integer index = propertyMap.get(propertyName); if (index == null) { throw new IllegalArgumentException("non existent property: '" + propertyName + "'."); } this.data[index] = new double[]{value}; }
[ "public", "void", "setDouble", "(", "final", "String", "propertyName", ",", "final", "double", "value", ")", "{", "if", "(", "propertyName", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"propertyName must not be null.\"", ")", ";", "}", "Integer", "index", "=", "propertyMap", ".", "get", "(", "propertyName", ")", ";", "if", "(", "index", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"non existent property: '\"", "+", "propertyName", "+", "\"'.\"", ")", ";", "}", "this", ".", "data", "[", "index", "]", "=", "new", "double", "[", "]", "{", "value", "}", ";", "}" ]
Sets the value of a property-list. If the property is a list, the list will be set to a single entry. @param propertyName Name of the property to set. @param value Value to set for that property. @throws NullPointerException if {@code propertyName} is {@code null}. @throws IllegalArgumentException if the element type does not have a property with the given name.
[ "Sets", "the", "value", "of", "a", "property", "-", "list", ".", "If", "the", "property", "is", "a", "list", "the", "list", "will", "be", "set", "to", "a", "single", "entry", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/Element.java#L221-L231
1,995
smurn/jPLY
jply/src/main/java/org/smurn/jply/ListProperty.java
ListProperty.parse
static Property parse(final String line) throws IOException { if (!line.startsWith("property ")) { throw new IOException("not a property: '" + line + "'"); } String definition = line.substring("property ".length()); definition = definition.trim(); if (!definition.startsWith("list ")) { throw new IllegalArgumentException("not a list property: '" + line + "'"); } definition = definition.substring("list ".length()); definition = definition.trim(); String[] parts = definition.split(" +", 3); if (parts.length != 3) { throw new IOException("Expected three parts in list property " + "definition: '" + line + "'"); } String countType = parts[0]; String type = parts[1]; String name = parts[2]; DataType dataType; DataType countDataType; try { dataType = DataType.parse(type); countDataType = DataType.parse(countType); } catch (IllegalArgumentException e) { throw new IOException(e.getMessage()); } return new ListProperty(countDataType, name, dataType); }
java
static Property parse(final String line) throws IOException { if (!line.startsWith("property ")) { throw new IOException("not a property: '" + line + "'"); } String definition = line.substring("property ".length()); definition = definition.trim(); if (!definition.startsWith("list ")) { throw new IllegalArgumentException("not a list property: '" + line + "'"); } definition = definition.substring("list ".length()); definition = definition.trim(); String[] parts = definition.split(" +", 3); if (parts.length != 3) { throw new IOException("Expected three parts in list property " + "definition: '" + line + "'"); } String countType = parts[0]; String type = parts[1]; String name = parts[2]; DataType dataType; DataType countDataType; try { dataType = DataType.parse(type); countDataType = DataType.parse(countType); } catch (IllegalArgumentException e) { throw new IOException(e.getMessage()); } return new ListProperty(countDataType, name, dataType); }
[ "static", "Property", "parse", "(", "final", "String", "line", ")", "throws", "IOException", "{", "if", "(", "!", "line", ".", "startsWith", "(", "\"property \"", ")", ")", "{", "throw", "new", "IOException", "(", "\"not a property: '\"", "+", "line", "+", "\"'\"", ")", ";", "}", "String", "definition", "=", "line", ".", "substring", "(", "\"property \"", ".", "length", "(", ")", ")", ";", "definition", "=", "definition", ".", "trim", "(", ")", ";", "if", "(", "!", "definition", ".", "startsWith", "(", "\"list \"", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"not a list property: '\"", "+", "line", "+", "\"'\"", ")", ";", "}", "definition", "=", "definition", ".", "substring", "(", "\"list \"", ".", "length", "(", ")", ")", ";", "definition", "=", "definition", ".", "trim", "(", ")", ";", "String", "[", "]", "parts", "=", "definition", ".", "split", "(", "\" +\"", ",", "3", ")", ";", "if", "(", "parts", ".", "length", "!=", "3", ")", "{", "throw", "new", "IOException", "(", "\"Expected three parts in list property \"", "+", "\"definition: '\"", "+", "line", "+", "\"'\"", ")", ";", "}", "String", "countType", "=", "parts", "[", "0", "]", ";", "String", "type", "=", "parts", "[", "1", "]", ";", "String", "name", "=", "parts", "[", "2", "]", ";", "DataType", "dataType", ";", "DataType", "countDataType", ";", "try", "{", "dataType", "=", "DataType", ".", "parse", "(", "type", ")", ";", "countDataType", "=", "DataType", ".", "parse", "(", "countType", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "throw", "new", "IOException", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "return", "new", "ListProperty", "(", "countDataType", ",", "name", ",", "dataType", ")", ";", "}" ]
Parses a list-property header line. @param line Header line. @return Property described on the line. @throws IOException if the header line as an invalid format.
[ "Parses", "a", "list", "-", "property", "header", "line", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/ListProperty.java#L68-L103
1,996
smurn/jPLY
jply/src/main/java/org/smurn/jply/PlyReaderFile.java
PlyReaderFile.getElementCount
@Override public int getElementCount(final String elementType) { if (elementType == null) { throw new IllegalArgumentException("elementType must not be null."); } Integer count = elementCounts.get(elementType); if (count == null) { throw new IllegalArgumentException( "Type does not exist in this file."); } else { return count; } }
java
@Override public int getElementCount(final String elementType) { if (elementType == null) { throw new IllegalArgumentException("elementType must not be null."); } Integer count = elementCounts.get(elementType); if (count == null) { throw new IllegalArgumentException( "Type does not exist in this file."); } else { return count; } }
[ "@", "Override", "public", "int", "getElementCount", "(", "final", "String", "elementType", ")", "{", "if", "(", "elementType", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"elementType must not be null.\"", ")", ";", "}", "Integer", "count", "=", "elementCounts", ".", "get", "(", "elementType", ")", ";", "if", "(", "count", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Type does not exist in this file.\"", ")", ";", "}", "else", "{", "return", "count", ";", "}", "}" ]
Gets the number of elements for a given element type. @param elementType Name of the element type. @return Number of elements of the given type. @throws NullPointerException if {@code elementType} is {@code null}. @throws IllegalArgumentException if there is no such type in this file.
[ "Gets", "the", "number", "of", "elements", "for", "a", "given", "element", "type", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/PlyReaderFile.java#L224-L236
1,997
smurn/jPLY
jply/src/main/java/org/smurn/jply/PlyReaderFile.java
PlyReaderFile.nextElementReaderInternal
private ElementReader nextElementReaderInternal() { if (nextElement >= elements.size()) { return null; } try { ElementType type = elements.get(nextElement); switch (format) { case ASCII: return new AsciiElementReader( type, getElementCount(type.getName()), asciiReader); case BINARY_BIG_ENDIAN: case BINARY_LITTLE_ENDIAN: return new BinaryElementReader( type, getElementCount(type.getName()), binaryStream); default: throw new UnsupportedOperationException("PLY format " + format + " is currently not supported."); } } finally { nextElement++; } }
java
private ElementReader nextElementReaderInternal() { if (nextElement >= elements.size()) { return null; } try { ElementType type = elements.get(nextElement); switch (format) { case ASCII: return new AsciiElementReader( type, getElementCount(type.getName()), asciiReader); case BINARY_BIG_ENDIAN: case BINARY_LITTLE_ENDIAN: return new BinaryElementReader( type, getElementCount(type.getName()), binaryStream); default: throw new UnsupportedOperationException("PLY format " + format + " is currently not supported."); } } finally { nextElement++; } }
[ "private", "ElementReader", "nextElementReaderInternal", "(", ")", "{", "if", "(", "nextElement", ">=", "elements", ".", "size", "(", ")", ")", "{", "return", "null", ";", "}", "try", "{", "ElementType", "type", "=", "elements", ".", "get", "(", "nextElement", ")", ";", "switch", "(", "format", ")", "{", "case", "ASCII", ":", "return", "new", "AsciiElementReader", "(", "type", ",", "getElementCount", "(", "type", ".", "getName", "(", ")", ")", ",", "asciiReader", ")", ";", "case", "BINARY_BIG_ENDIAN", ":", "case", "BINARY_LITTLE_ENDIAN", ":", "return", "new", "BinaryElementReader", "(", "type", ",", "getElementCount", "(", "type", ".", "getName", "(", ")", ")", ",", "binaryStream", ")", ";", "default", ":", "throw", "new", "UnsupportedOperationException", "(", "\"PLY format \"", "+", "format", "+", "\" is currently not supported.\"", ")", ";", "}", "}", "finally", "{", "nextElement", "++", ";", "}", "}" ]
Creates the next element reader. @return next element Reader.
[ "Creates", "the", "next", "element", "reader", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/PlyReaderFile.java#L286-L312
1,998
smurn/jPLY
jply/src/main/java/org/smurn/jply/BinaryPlyInputStream.java
BinaryPlyInputStream.read
public double read(final DataType type) throws IOException { if (type == null) { throw new NullPointerException("type must not be null."); } switch (type) { case CHAR: ensureAvailable(1); return buffer.get(); case UCHAR: ensureAvailable(1); return ( (int) buffer.get() ) & 0x000000FF; case SHORT: ensureAvailable(2); return buffer.getShort(); case USHORT: ensureAvailable(2); return ( (int) buffer.getShort() ) & 0x0000FFFF; case INT: ensureAvailable(4); return buffer.getInt(); case UINT: ensureAvailable(4); return ( (long) buffer.getShort() ) & 0x00000000FFFFFFFF; case FLOAT: ensureAvailable(4); return buffer.getFloat(); case DOUBLE: ensureAvailable(8); return buffer.getDouble(); default: throw new IllegalArgumentException("Unsupported type: " + type); } }
java
public double read(final DataType type) throws IOException { if (type == null) { throw new NullPointerException("type must not be null."); } switch (type) { case CHAR: ensureAvailable(1); return buffer.get(); case UCHAR: ensureAvailable(1); return ( (int) buffer.get() ) & 0x000000FF; case SHORT: ensureAvailable(2); return buffer.getShort(); case USHORT: ensureAvailable(2); return ( (int) buffer.getShort() ) & 0x0000FFFF; case INT: ensureAvailable(4); return buffer.getInt(); case UINT: ensureAvailable(4); return ( (long) buffer.getShort() ) & 0x00000000FFFFFFFF; case FLOAT: ensureAvailable(4); return buffer.getFloat(); case DOUBLE: ensureAvailable(8); return buffer.getDouble(); default: throw new IllegalArgumentException("Unsupported type: " + type); } }
[ "public", "double", "read", "(", "final", "DataType", "type", ")", "throws", "IOException", "{", "if", "(", "type", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"type must not be null.\"", ")", ";", "}", "switch", "(", "type", ")", "{", "case", "CHAR", ":", "ensureAvailable", "(", "1", ")", ";", "return", "buffer", ".", "get", "(", ")", ";", "case", "UCHAR", ":", "ensureAvailable", "(", "1", ")", ";", "return", "(", "(", "int", ")", "buffer", ".", "get", "(", ")", ")", "&", "0x000000FF", ";", "case", "SHORT", ":", "ensureAvailable", "(", "2", ")", ";", "return", "buffer", ".", "getShort", "(", ")", ";", "case", "USHORT", ":", "ensureAvailable", "(", "2", ")", ";", "return", "(", "(", "int", ")", "buffer", ".", "getShort", "(", ")", ")", "&", "0x0000FFFF", ";", "case", "INT", ":", "ensureAvailable", "(", "4", ")", ";", "return", "buffer", ".", "getInt", "(", ")", ";", "case", "UINT", ":", "ensureAvailable", "(", "4", ")", ";", "return", "(", "(", "long", ")", "buffer", ".", "getShort", "(", ")", ")", "&", "0x00000000FFFFFFFF", ";", "case", "FLOAT", ":", "ensureAvailable", "(", "4", ")", ";", "return", "buffer", ".", "getFloat", "(", ")", ";", "case", "DOUBLE", ":", "ensureAvailable", "(", "8", ")", ";", "return", "buffer", ".", "getDouble", "(", ")", ";", "default", ":", "throw", "new", "IllegalArgumentException", "(", "\"Unsupported type: \"", "+", "type", ")", ";", "}", "}" ]
Reads a value from the stream. @param type Encoding of the value in the binary stream. @return Value casted to {@code double}. @throws IOException if reading the value fails. @throws NullPointerException if {@code type} is {@code null}.
[ "Reads", "a", "value", "from", "the", "stream", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/BinaryPlyInputStream.java#L65-L97
1,999
smurn/jPLY
jply/src/main/java/org/smurn/jply/BinaryPlyInputStream.java
BinaryPlyInputStream.ensureAvailable
private void ensureAvailable(final int bytes) throws IOException { while (buffer.remaining() < bytes) { buffer.compact(); if (channel.read(buffer) < 0) { throw new EOFException(); } buffer.flip(); } }
java
private void ensureAvailable(final int bytes) throws IOException { while (buffer.remaining() < bytes) { buffer.compact(); if (channel.read(buffer) < 0) { throw new EOFException(); } buffer.flip(); } }
[ "private", "void", "ensureAvailable", "(", "final", "int", "bytes", ")", "throws", "IOException", "{", "while", "(", "buffer", ".", "remaining", "(", ")", "<", "bytes", ")", "{", "buffer", ".", "compact", "(", ")", ";", "if", "(", "channel", ".", "read", "(", "buffer", ")", "<", "0", ")", "{", "throw", "new", "EOFException", "(", ")", ";", "}", "buffer", ".", "flip", "(", ")", ";", "}", "}" ]
Ensures that a certain amount of bytes are in the buffer, ready to be read. @param bytes Minimal number of unread bytes required in the buffer. @see ByteBuffer#remaining() @throws IOException if reading sufficient more data into the buffer fails.
[ "Ensures", "that", "a", "certain", "amount", "of", "bytes", "are", "in", "the", "buffer", "ready", "to", "be", "read", "." ]
77cb8c47fff7549ae1da8d8568ad8bdf374fe89f
https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/BinaryPlyInputStream.java#L107-L115