id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
150,100
eurekaclinical/datastore
src/main/java/org/eurekaclinical/datastore/bdb/BdbStoreFactory.java
BdbStoreFactory.closeAndRemoveAllDatabaseHandles
final void closeAndRemoveAllDatabaseHandles() { for (Database databaseHandle : this.databaseHandles) { try { databaseHandle.close(); } catch (EnvironmentFailureException | IllegalStateException ex) { LOGGER.log(Level.SEVERE, "Error closing databases", ex); } } this.databaseHandles.clear(); }
java
final void closeAndRemoveAllDatabaseHandles() { for (Database databaseHandle : this.databaseHandles) { try { databaseHandle.close(); } catch (EnvironmentFailureException | IllegalStateException ex) { LOGGER.log(Level.SEVERE, "Error closing databases", ex); } } this.databaseHandles.clear(); }
[ "final", "void", "closeAndRemoveAllDatabaseHandles", "(", ")", "{", "for", "(", "Database", "databaseHandle", ":", "this", ".", "databaseHandles", ")", "{", "try", "{", "databaseHandle", ".", "close", "(", ")", ";", "}", "catch", "(", "EnvironmentFailureException", "|", "IllegalStateException", "ex", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"Error closing databases\"", ",", "ex", ")", ";", "}", "}", "this", ".", "databaseHandles", ".", "clear", "(", ")", ";", "}" ]
Closes all databases that this factory instance previously created. @throws EnvironmentFailureException if an unexpected, internal or environment-wide failure occurs. @throws IllegalStateException if the database has been closed.
[ "Closes", "all", "databases", "that", "this", "factory", "instance", "previously", "created", "." ]
a03a70819bb562ba45eac66ca49f778035ee45e0
https://github.com/eurekaclinical/datastore/blob/a03a70819bb562ba45eac66ca49f778035ee45e0/src/main/java/org/eurekaclinical/datastore/bdb/BdbStoreFactory.java#L197-L207
150,101
eurekaclinical/datastore
src/main/java/org/eurekaclinical/datastore/bdb/BdbStoreFactory.java
BdbStoreFactory.createEnvironment
private Environment createEnvironment() { EnvironmentConfig envConf = createEnvConfig(); if (!envFile.exists()) { envFile.mkdirs(); } LOGGER.log(Level.INFO, "Initialized BerkeleyDB cache environment at {0}", envFile.getAbsolutePath()); return new Environment(this.envFile, envConf); }
java
private Environment createEnvironment() { EnvironmentConfig envConf = createEnvConfig(); if (!envFile.exists()) { envFile.mkdirs(); } LOGGER.log(Level.INFO, "Initialized BerkeleyDB cache environment at {0}", envFile.getAbsolutePath()); return new Environment(this.envFile, envConf); }
[ "private", "Environment", "createEnvironment", "(", ")", "{", "EnvironmentConfig", "envConf", "=", "createEnvConfig", "(", ")", ";", "if", "(", "!", "envFile", ".", "exists", "(", ")", ")", "{", "envFile", ".", "mkdirs", "(", ")", ";", "}", "LOGGER", ".", "log", "(", "Level", ".", "INFO", ",", "\"Initialized BerkeleyDB cache environment at {0}\"", ",", "envFile", ".", "getAbsolutePath", "(", ")", ")", ";", "return", "new", "Environment", "(", "this", ".", "envFile", ",", "envConf", ")", ";", "}" ]
Creates a Berkeley DB database environment from the provided environment configuration. @return an environment instance. @throws SecurityException if the directory for storing the databases could not be created. @throws EnvironmentNotFoundException if the environment does not exist (does not contain at least one log file) and the EnvironmentConfig AllowCreate parameter is false. @throws EnvironmentLockedException when an environment cannot be opened for write access because another process has the same environment open for write access. Warning: This exception should be handled when an environment is opened by more than one process. @throws VersionMismatchException when the existing log is not compatible with the version of JE that is running. This occurs when a later version of JE was used to create the log. Warning: This exception should be handled when more than one version of JE may be used to access an environment. @throws EnvironmentFailureException if an unexpected, internal or environment-wide failure occurs. @throws java.lang.UnsupportedOperationException if this environment was previously opened for replication and is not being opened read-only. @throws java.lang.IllegalArgumentException if an invalid parameter is specified, for example, an invalid EnvironmentConfig parameter.
[ "Creates", "a", "Berkeley", "DB", "database", "environment", "from", "the", "provided", "environment", "configuration", "." ]
a03a70819bb562ba45eac66ca49f778035ee45e0
https://github.com/eurekaclinical/datastore/blob/a03a70819bb562ba45eac66ca49f778035ee45e0/src/main/java/org/eurekaclinical/datastore/bdb/BdbStoreFactory.java#L244-L254
150,102
io7m/jcanephora
com.io7m.jcanephora.lwjgl3/src/main/java/com/io7m/jcanephora/lwjgl3/LWJGL3TypeConversions.java
LWJGL3TypeConversions.framebufferBlitFilterFromGL
public static JCGLFramebufferBlitFilter framebufferBlitFilterFromGL( final int filter) { switch (filter) { case GL11.GL_LINEAR: { return JCGLFramebufferBlitFilter.FRAMEBUFFER_BLIT_FILTER_LINEAR; } case GL11.GL_NEAREST: { return JCGLFramebufferBlitFilter.FRAMEBUFFER_BLIT_FILTER_NEAREST; } default: throw new UnreachableCodeException(); } }
java
public static JCGLFramebufferBlitFilter framebufferBlitFilterFromGL( final int filter) { switch (filter) { case GL11.GL_LINEAR: { return JCGLFramebufferBlitFilter.FRAMEBUFFER_BLIT_FILTER_LINEAR; } case GL11.GL_NEAREST: { return JCGLFramebufferBlitFilter.FRAMEBUFFER_BLIT_FILTER_NEAREST; } default: throw new UnreachableCodeException(); } }
[ "public", "static", "JCGLFramebufferBlitFilter", "framebufferBlitFilterFromGL", "(", "final", "int", "filter", ")", "{", "switch", "(", "filter", ")", "{", "case", "GL11", ".", "GL_LINEAR", ":", "{", "return", "JCGLFramebufferBlitFilter", ".", "FRAMEBUFFER_BLIT_FILTER_LINEAR", ";", "}", "case", "GL11", ".", "GL_NEAREST", ":", "{", "return", "JCGLFramebufferBlitFilter", ".", "FRAMEBUFFER_BLIT_FILTER_NEAREST", ";", "}", "default", ":", "throw", "new", "UnreachableCodeException", "(", ")", ";", "}", "}" ]
Convert framebuffer blit filter from GL constants. @param filter The GL constant. @return The value.
[ "Convert", "framebuffer", "blit", "filter", "from", "GL", "constants", "." ]
0004c1744b7f0969841d04cd4fa693f402b10980
https://github.com/io7m/jcanephora/blob/0004c1744b7f0969841d04cd4fa693f402b10980/com.io7m.jcanephora.lwjgl3/src/main/java/com/io7m/jcanephora/lwjgl3/LWJGL3TypeConversions.java#L1191-L1204
150,103
io7m/jcanephora
com.io7m.jcanephora.lwjgl3/src/main/java/com/io7m/jcanephora/lwjgl3/LWJGL3TypeConversions.java
LWJGL3TypeConversions.faceSelectionToGL
public static int faceSelectionToGL( final JCGLFaceSelection faces) { switch (faces) { case FACE_BACK: return GL11.GL_BACK; case FACE_FRONT: return GL11.GL_FRONT; case FACE_FRONT_AND_BACK: return GL11.GL_FRONT_AND_BACK; } throw new UnreachableCodeException(); }
java
public static int faceSelectionToGL( final JCGLFaceSelection faces) { switch (faces) { case FACE_BACK: return GL11.GL_BACK; case FACE_FRONT: return GL11.GL_FRONT; case FACE_FRONT_AND_BACK: return GL11.GL_FRONT_AND_BACK; } throw new UnreachableCodeException(); }
[ "public", "static", "int", "faceSelectionToGL", "(", "final", "JCGLFaceSelection", "faces", ")", "{", "switch", "(", "faces", ")", "{", "case", "FACE_BACK", ":", "return", "GL11", ".", "GL_BACK", ";", "case", "FACE_FRONT", ":", "return", "GL11", ".", "GL_FRONT", ";", "case", "FACE_FRONT_AND_BACK", ":", "return", "GL11", ".", "GL_FRONT_AND_BACK", ";", "}", "throw", "new", "UnreachableCodeException", "(", ")", ";", "}" ]
Convert faces to GL constants. @param faces The faces. @return The resulting GL constant.
[ "Convert", "faces", "to", "GL", "constants", "." ]
0004c1744b7f0969841d04cd4fa693f402b10980
https://github.com/io7m/jcanephora/blob/0004c1744b7f0969841d04cd4fa693f402b10980/com.io7m.jcanephora.lwjgl3/src/main/java/com/io7m/jcanephora/lwjgl3/LWJGL3TypeConversions.java#L1324-L1337
150,104
io7m/jcanephora
com.io7m.jcanephora.lwjgl3/src/main/java/com/io7m/jcanephora/lwjgl3/LWJGL3TypeConversions.java
LWJGL3TypeConversions.faceWindingOrderToGL
public static int faceWindingOrderToGL( final JCGLFaceWindingOrder f) { switch (f) { case FRONT_FACE_CLOCKWISE: return GL11.GL_CW; case FRONT_FACE_COUNTER_CLOCKWISE: return GL11.GL_CCW; } throw new UnreachableCodeException(); }
java
public static int faceWindingOrderToGL( final JCGLFaceWindingOrder f) { switch (f) { case FRONT_FACE_CLOCKWISE: return GL11.GL_CW; case FRONT_FACE_COUNTER_CLOCKWISE: return GL11.GL_CCW; } throw new UnreachableCodeException(); }
[ "public", "static", "int", "faceWindingOrderToGL", "(", "final", "JCGLFaceWindingOrder", "f", ")", "{", "switch", "(", "f", ")", "{", "case", "FRONT_FACE_CLOCKWISE", ":", "return", "GL11", ".", "GL_CW", ";", "case", "FRONT_FACE_COUNTER_CLOCKWISE", ":", "return", "GL11", ".", "GL_CCW", ";", "}", "throw", "new", "UnreachableCodeException", "(", ")", ";", "}" ]
Convert face winding orders to GL constants. @param f The face winding order. @return The resulting GL constant.
[ "Convert", "face", "winding", "orders", "to", "GL", "constants", "." ]
0004c1744b7f0969841d04cd4fa693f402b10980
https://github.com/io7m/jcanephora/blob/0004c1744b7f0969841d04cd4fa693f402b10980/com.io7m.jcanephora.lwjgl3/src/main/java/com/io7m/jcanephora/lwjgl3/LWJGL3TypeConversions.java#L1368-L1379
150,105
eurekaclinical/eurekaclinical-standard-apis
src/main/java/org/eurekaclinical/standardapis/filter/RolesFromDbFilter.java
RolesFromDbFilter.getRoles
@Override protected String[] getRoles(Principal inPrincipal, ServletRequest inRequest) { UserEntity user = this.userDao.getByPrincipal(inPrincipal); if (user != null) { return user.getRoleNames(); } else { return null; } }
java
@Override protected String[] getRoles(Principal inPrincipal, ServletRequest inRequest) { UserEntity user = this.userDao.getByPrincipal(inPrincipal); if (user != null) { return user.getRoleNames(); } else { return null; } }
[ "@", "Override", "protected", "String", "[", "]", "getRoles", "(", "Principal", "inPrincipal", ",", "ServletRequest", "inRequest", ")", "{", "UserEntity", "user", "=", "this", ".", "userDao", ".", "getByPrincipal", "(", "inPrincipal", ")", ";", "if", "(", "user", "!=", "null", ")", "{", "return", "user", ".", "getRoleNames", "(", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
The getRoles method will now return Null if UserObject not found, EMPTY_ARRAY if the user found and don't have any associated roles and String Array if the user found and have associated roles. @param inPrincipal the user principal. @param inRequest the HTTP request. @return Array of Roles, empth array if no roles associated and Null if User not found @author Dileep Gunda @since 06-11-18
[ "The", "getRoles", "method", "will", "now", "return", "Null", "if", "UserObject", "not", "found", "EMPTY_ARRAY", "if", "the", "user", "found", "and", "don", "t", "have", "any", "associated", "roles", "and", "String", "Array", "if", "the", "user", "found", "and", "have", "associated", "roles", "." ]
690036dde82a4f2c2106d32403cdf1c713429377
https://github.com/eurekaclinical/eurekaclinical-standard-apis/blob/690036dde82a4f2c2106d32403cdf1c713429377/src/main/java/org/eurekaclinical/standardapis/filter/RolesFromDbFilter.java#L63-L72
150,106
trustathsh/ifmapj
src/main/java/de/hshannover/f4/trust/ifmapj21/ClockSkewDetector.java
ClockSkewDetector.performClockSkewDetection
public long performClockSkewDetection(Calendar clientTime) throws IfmapErrorResult, IfmapException { publishTime(clientTime); Element time = searchTime(); deleteTimes(); mClockSkew = calculateTimeDiff(time); mLastTimeSynchronization = Calendar.getInstance(TimeZone.getTimeZone("UTC")); return mClockSkew; }
java
public long performClockSkewDetection(Calendar clientTime) throws IfmapErrorResult, IfmapException { publishTime(clientTime); Element time = searchTime(); deleteTimes(); mClockSkew = calculateTimeDiff(time); mLastTimeSynchronization = Calendar.getInstance(TimeZone.getTimeZone("UTC")); return mClockSkew; }
[ "public", "long", "performClockSkewDetection", "(", "Calendar", "clientTime", ")", "throws", "IfmapErrorResult", ",", "IfmapException", "{", "publishTime", "(", "clientTime", ")", ";", "Element", "time", "=", "searchTime", "(", ")", ";", "deleteTimes", "(", ")", ";", "mClockSkew", "=", "calculateTimeDiff", "(", "time", ")", ";", "mLastTimeSynchronization", "=", "Calendar", ".", "getInstance", "(", "TimeZone", ".", "getTimeZone", "(", "\"UTC\"", ")", ")", ";", "return", "mClockSkew", ";", "}" ]
Send a client-time publish request with the current time followed by a search request in order to synchronize time to MAPS. <pre> This function implements the behaviour described in sec. 4.6.1 of published TNC IF-MAP Binding for SOAP specification 2.1 Rev 15. </pre> @since 0.1.5 @throws IfmapErrorResult @throws IfmapException @throws EndSessionException
[ "Send", "a", "client", "-", "time", "publish", "request", "with", "the", "current", "time", "followed", "by", "a", "search", "request", "in", "order", "to", "synchronize", "time", "to", "MAPS", "." ]
44ece9e95a3d2a1b7019573ba6178598a6cbdaa3
https://github.com/trustathsh/ifmapj/blob/44ece9e95a3d2a1b7019573ba6178598a6cbdaa3/src/main/java/de/hshannover/f4/trust/ifmapj21/ClockSkewDetector.java#L169-L178
150,107
trustathsh/ifmapj
src/main/java/de/hshannover/f4/trust/ifmapj21/ClockSkewDetector.java
ClockSkewDetector.getClockOfServer
public Calendar getClockOfServer() { Calendar retCal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); retCal.add(Calendar.MILLISECOND, mClockSkew.intValue()); return retCal; }
java
public Calendar getClockOfServer() { Calendar retCal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); retCal.add(Calendar.MILLISECOND, mClockSkew.intValue()); return retCal; }
[ "public", "Calendar", "getClockOfServer", "(", ")", "{", "Calendar", "retCal", "=", "Calendar", ".", "getInstance", "(", "TimeZone", ".", "getTimeZone", "(", "\"UTC\"", ")", ")", ";", "retCal", ".", "add", "(", "Calendar", ".", "MILLISECOND", ",", "mClockSkew", ".", "intValue", "(", ")", ")", ";", "return", "retCal", ";", "}" ]
The corrected server time @since 0.1.5 @return current UTC server time
[ "The", "corrected", "server", "time" ]
44ece9e95a3d2a1b7019573ba6178598a6cbdaa3
https://github.com/trustathsh/ifmapj/blob/44ece9e95a3d2a1b7019573ba6178598a6cbdaa3/src/main/java/de/hshannover/f4/trust/ifmapj21/ClockSkewDetector.java#L246-L250
150,108
agmip/dome
src/main/java/org/agmip/dome/Engine.java
Engine.getGenerators
public ArrayList<String> getGenerators() { ArrayList<String> genList = new ArrayList<String>(); for (ArrayList<HashMap<String, String>> genGroup : genGroups) { if (!genGroup.isEmpty()) { HashMap<String, String> genRule = genGroup.get(genGroup.size() - 1); if (!genRule.isEmpty()) { genList.add(genRule.get("cmd") + "," + genRule.get("variable") + "," + genRule.get("args")); } } } return genList; }
java
public ArrayList<String> getGenerators() { ArrayList<String> genList = new ArrayList<String>(); for (ArrayList<HashMap<String, String>> genGroup : genGroups) { if (!genGroup.isEmpty()) { HashMap<String, String> genRule = genGroup.get(genGroup.size() - 1); if (!genRule.isEmpty()) { genList.add(genRule.get("cmd") + "," + genRule.get("variable") + "," + genRule.get("args")); } } } return genList; }
[ "public", "ArrayList", "<", "String", ">", "getGenerators", "(", ")", "{", "ArrayList", "<", "String", ">", "genList", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "ArrayList", "<", "HashMap", "<", "String", ",", "String", ">", ">", "genGroup", ":", "genGroups", ")", "{", "if", "(", "!", "genGroup", ".", "isEmpty", "(", ")", ")", "{", "HashMap", "<", "String", ",", "String", ">", "genRule", "=", "genGroup", ".", "get", "(", "genGroup", ".", "size", "(", ")", "-", "1", ")", ";", "if", "(", "!", "genRule", ".", "isEmpty", "(", ")", ")", "{", "genList", ".", "add", "(", "genRule", ".", "get", "(", "\"cmd\"", ")", "+", "\",\"", "+", "genRule", ".", "get", "(", "\"variable\"", ")", "+", "\",\"", "+", "genRule", ".", "get", "(", "\"args\"", ")", ")", ";", "}", "}", "}", "return", "genList", ";", "}" ]
Get the list of loaded generator rules @return The list of DOME command string with format (command,variable,arguments)
[ "Get", "the", "list", "of", "loaded", "generator", "rules" ]
ca7c15bf2bae09bb7e8d51160e77592bbda9343d
https://github.com/agmip/dome/blob/ca7c15bf2bae09bb7e8d51160e77592bbda9343d/src/main/java/org/agmip/dome/Engine.java#L591-L603
150,109
aragozin/jorka
src/main/java/org/gridkit/jorka/Jorka.java
Jorka.addPatternFromFile
public void addPatternFromFile(String file) throws IOException { File f = new File(file); addPatternFromReader(new FileReader(f)); }
java
public void addPatternFromFile(String file) throws IOException { File f = new File(file); addPatternFromReader(new FileReader(f)); }
[ "public", "void", "addPatternFromFile", "(", "String", "file", ")", "throws", "IOException", "{", "File", "f", "=", "new", "File", "(", "file", ")", ";", "addPatternFromReader", "(", "new", "FileReader", "(", "f", ")", ")", ";", "}" ]
Add patterns from a file
[ "Add", "patterns", "from", "a", "file" ]
9f380a97e834c32cbfbe10508365683ea969b533
https://github.com/aragozin/jorka/blob/9f380a97e834c32cbfbe10508365683ea969b533/src/main/java/org/gridkit/jorka/Jorka.java#L143-L147
150,110
aragozin/jorka
src/main/java/org/gridkit/jorka/Jorka.java
Jorka.addPatternFromReader
public void addPatternFromReader(Reader r) throws IOException { BufferedReader br = new BufferedReader(r); String line; // We dont want \n and commented line Pattern MY_PATTERN = Pattern.compile("^([A-z0-9_]+)([~]?)\\s+(.*)$"); while ((line = br.readLine()) != null) { Matcher m = MY_PATTERN.matcher(line); if (m.matches()) { if (m.group(2).length() > 0) { // process line as simple template this.addPattern(m.group(1), simpleTemplateToRegEx(m.group(3))); } else { this.addPattern(m.group(1), m.group(3)); } } } br.close(); }
java
public void addPatternFromReader(Reader r) throws IOException { BufferedReader br = new BufferedReader(r); String line; // We dont want \n and commented line Pattern MY_PATTERN = Pattern.compile("^([A-z0-9_]+)([~]?)\\s+(.*)$"); while ((line = br.readLine()) != null) { Matcher m = MY_PATTERN.matcher(line); if (m.matches()) { if (m.group(2).length() > 0) { // process line as simple template this.addPattern(m.group(1), simpleTemplateToRegEx(m.group(3))); } else { this.addPattern(m.group(1), m.group(3)); } } } br.close(); }
[ "public", "void", "addPatternFromReader", "(", "Reader", "r", ")", "throws", "IOException", "{", "BufferedReader", "br", "=", "new", "BufferedReader", "(", "r", ")", ";", "String", "line", ";", "// We dont want \\n and commented line", "Pattern", "MY_PATTERN", "=", "Pattern", ".", "compile", "(", "\"^([A-z0-9_]+)([~]?)\\\\s+(.*)$\"", ")", ";", "while", "(", "(", "line", "=", "br", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "Matcher", "m", "=", "MY_PATTERN", ".", "matcher", "(", "line", ")", ";", "if", "(", "m", ".", "matches", "(", ")", ")", "{", "if", "(", "m", ".", "group", "(", "2", ")", ".", "length", "(", ")", ">", "0", ")", "{", "// process line as simple template", "this", ".", "addPattern", "(", "m", ".", "group", "(", "1", ")", ",", "simpleTemplateToRegEx", "(", "m", ".", "group", "(", "3", ")", ")", ")", ";", "}", "else", "{", "this", ".", "addPattern", "(", "m", ".", "group", "(", "1", ")", ",", "m", ".", "group", "(", "3", ")", ")", ";", "}", "}", "}", "br", ".", "close", "(", ")", ";", "}" ]
Add patterns from a reader
[ "Add", "patterns", "from", "a", "reader" ]
9f380a97e834c32cbfbe10508365683ea969b533
https://github.com/aragozin/jorka/blob/9f380a97e834c32cbfbe10508365683ea969b533/src/main/java/org/gridkit/jorka/Jorka.java#L152-L170
150,111
aragozin/jorka
src/main/java/org/gridkit/jorka/Jorka.java
Jorka.compile
public void compile(String pattern) { this.expandedPattern = expand(pattern); // Compile the regex if (!expandedPattern.isEmpty()) { regexp = Pattern.compile(expandedPattern); } else { throw new IllegalArgumentException("Pattern is not found '" + pattern + "'"); } }
java
public void compile(String pattern) { this.expandedPattern = expand(pattern); // Compile the regex if (!expandedPattern.isEmpty()) { regexp = Pattern.compile(expandedPattern); } else { throw new IllegalArgumentException("Pattern is not found '" + pattern + "'"); } }
[ "public", "void", "compile", "(", "String", "pattern", ")", "{", "this", ".", "expandedPattern", "=", "expand", "(", "pattern", ")", ";", "// Compile the regex", "if", "(", "!", "expandedPattern", ".", "isEmpty", "(", ")", ")", "{", "regexp", "=", "Pattern", ".", "compile", "(", "expandedPattern", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Pattern is not found '\"", "+", "pattern", "+", "\"'\"", ")", ";", "}", "}" ]
Transform Jorka regex into a compiled regex
[ "Transform", "Jorka", "regex", "into", "a", "compiled", "regex" ]
9f380a97e834c32cbfbe10508365683ea969b533
https://github.com/aragozin/jorka/blob/9f380a97e834c32cbfbe10508365683ea969b533/src/main/java/org/gridkit/jorka/Jorka.java#L227-L237
150,112
bwkimmel/jdcp
jdcp-worker/src/main/java/ca/eandb/jdcp/worker/DbCachingJobServiceClassLoaderStrategy.java
DbCachingJobServiceClassLoaderStrategy.prepareDataSource
public static void prepareDataSource(DataSource ds) throws SQLException { Connection con = null; String sql; try { con = ds.getConnection(); con.setAutoCommit(false); DatabaseMetaData meta = con.getMetaData(); ResultSet rs = meta.getTables(null, null, null, new String[]{"TABLE"}); int tableNameColumn = rs.findColumn("TABLE_NAME"); int count = 0; while (rs.next()) { String tableName = rs.getString(tableNameColumn); if (tableName.equalsIgnoreCase("CachedClasses")) { count++; } } if (count == 0) { String blobType = DbUtil.getTypeName(Types.BLOB, con); String nameType = DbUtil.getTypeName(Types.VARCHAR, 1024, con); String md5Type = DbUtil.getTypeName(Types.BINARY, 16, con); sql = "CREATE TABLE CachedClasses ( \n" + " Name " + nameType + " NOT NULL, \n" + " MD5 " + md5Type + " NOT NULL, \n" + " Definition " + blobType + " NOT NULL, \n" + " PRIMARY KEY (Name, MD5) \n" + ")"; DbUtil.update(ds, sql); con.commit(); } con.setAutoCommit(true); } catch (SQLException e) { DbUtil.rollback(con); throw e; } finally { DbUtil.close(con); } }
java
public static void prepareDataSource(DataSource ds) throws SQLException { Connection con = null; String sql; try { con = ds.getConnection(); con.setAutoCommit(false); DatabaseMetaData meta = con.getMetaData(); ResultSet rs = meta.getTables(null, null, null, new String[]{"TABLE"}); int tableNameColumn = rs.findColumn("TABLE_NAME"); int count = 0; while (rs.next()) { String tableName = rs.getString(tableNameColumn); if (tableName.equalsIgnoreCase("CachedClasses")) { count++; } } if (count == 0) { String blobType = DbUtil.getTypeName(Types.BLOB, con); String nameType = DbUtil.getTypeName(Types.VARCHAR, 1024, con); String md5Type = DbUtil.getTypeName(Types.BINARY, 16, con); sql = "CREATE TABLE CachedClasses ( \n" + " Name " + nameType + " NOT NULL, \n" + " MD5 " + md5Type + " NOT NULL, \n" + " Definition " + blobType + " NOT NULL, \n" + " PRIMARY KEY (Name, MD5) \n" + ")"; DbUtil.update(ds, sql); con.commit(); } con.setAutoCommit(true); } catch (SQLException e) { DbUtil.rollback(con); throw e; } finally { DbUtil.close(con); } }
[ "public", "static", "void", "prepareDataSource", "(", "DataSource", "ds", ")", "throws", "SQLException", "{", "Connection", "con", "=", "null", ";", "String", "sql", ";", "try", "{", "con", "=", "ds", ".", "getConnection", "(", ")", ";", "con", ".", "setAutoCommit", "(", "false", ")", ";", "DatabaseMetaData", "meta", "=", "con", ".", "getMetaData", "(", ")", ";", "ResultSet", "rs", "=", "meta", ".", "getTables", "(", "null", ",", "null", ",", "null", ",", "new", "String", "[", "]", "{", "\"TABLE\"", "}", ")", ";", "int", "tableNameColumn", "=", "rs", ".", "findColumn", "(", "\"TABLE_NAME\"", ")", ";", "int", "count", "=", "0", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "String", "tableName", "=", "rs", ".", "getString", "(", "tableNameColumn", ")", ";", "if", "(", "tableName", ".", "equalsIgnoreCase", "(", "\"CachedClasses\"", ")", ")", "{", "count", "++", ";", "}", "}", "if", "(", "count", "==", "0", ")", "{", "String", "blobType", "=", "DbUtil", ".", "getTypeName", "(", "Types", ".", "BLOB", ",", "con", ")", ";", "String", "nameType", "=", "DbUtil", ".", "getTypeName", "(", "Types", ".", "VARCHAR", ",", "1024", ",", "con", ")", ";", "String", "md5Type", "=", "DbUtil", ".", "getTypeName", "(", "Types", ".", "BINARY", ",", "16", ",", "con", ")", ";", "sql", "=", "\"CREATE TABLE CachedClasses ( \\n\"", "+", "\" Name \"", "+", "nameType", "+", "\" NOT NULL, \\n\"", "+", "\" MD5 \"", "+", "md5Type", "+", "\" NOT NULL, \\n\"", "+", "\" Definition \"", "+", "blobType", "+", "\" NOT NULL, \\n\"", "+", "\" PRIMARY KEY (Name, MD5) \\n\"", "+", "\")\"", ";", "DbUtil", ".", "update", "(", "ds", ",", "sql", ")", ";", "con", ".", "commit", "(", ")", ";", "}", "con", ".", "setAutoCommit", "(", "true", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "DbUtil", ".", "rollback", "(", "con", ")", ";", "throw", "e", ";", "}", "finally", "{", "DbUtil", ".", "close", "(", "con", ")", ";", "}", "}" ]
Prepares the data source to store cached class definitions. @param ds The <code>DataSource</code> to prepare. @throws SQLException If an error occurs while communicating with the database.
[ "Prepares", "the", "data", "source", "to", "store", "cached", "class", "definitions", "." ]
630c5150c245054e2556ff370f4bad2ec793dfb7
https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-worker/src/main/java/ca/eandb/jdcp/worker/DbCachingJobServiceClassLoaderStrategy.java#L63-L103
150,113
jtrfp/javamod
src/main/java/de/quippy/sidplay/libsidplay/components/sidtune/PP20.java
PP20.decompress
public int /* udword_ppt */decompress( final short[] /* const void* */source, int /* udword_ppt */size, final Decompressed decomp) { this.source = source; globalError = false; // assume no error readPtr = 0; if (!isCompressed(source, size)) { return 0; } // Uncompressed size is stored at end of source file. // Backwards decompression. readPtr += (size - 4); int /* udword_ppt */lastDword = readBEdword(source, readPtr); // Uncompressed length in bits 31-8 of last dword. int /* udword_ppt */outputLen = lastDword >> 8; // Allocate memory for output data. dest = new short /* ubyte_ppt */[outputLen]; // Lowest dest. address for range-checks. // Put destptr to end of uncompressed data. writePtr = outputLen; // Read number of unused bits in 1st data dword // from lowest bits 7-0 of last dword. bits = 32 - (lastDword & 0xFF); // Main decompression loop. bytesTOdword(); if (bits != 32) current >>= (32 - bits); do { if (readBits(1) == 0) bytes(); if (writePtr > 0) sequence(); if (globalError) { // statusString already set. outputLen = 0; // unsuccessful decompression break; } } while (writePtr > 0); // Finished. if (outputLen > 0) // successful { decomp.destBufRef = new short[dest.length]; // Free any previously existing destination buffer. System.arraycopy(dest, 0, decomp.destBufRef, 0, dest.length); } return outputLen; }
java
public int /* udword_ppt */decompress( final short[] /* const void* */source, int /* udword_ppt */size, final Decompressed decomp) { this.source = source; globalError = false; // assume no error readPtr = 0; if (!isCompressed(source, size)) { return 0; } // Uncompressed size is stored at end of source file. // Backwards decompression. readPtr += (size - 4); int /* udword_ppt */lastDword = readBEdword(source, readPtr); // Uncompressed length in bits 31-8 of last dword. int /* udword_ppt */outputLen = lastDword >> 8; // Allocate memory for output data. dest = new short /* ubyte_ppt */[outputLen]; // Lowest dest. address for range-checks. // Put destptr to end of uncompressed data. writePtr = outputLen; // Read number of unused bits in 1st data dword // from lowest bits 7-0 of last dword. bits = 32 - (lastDword & 0xFF); // Main decompression loop. bytesTOdword(); if (bits != 32) current >>= (32 - bits); do { if (readBits(1) == 0) bytes(); if (writePtr > 0) sequence(); if (globalError) { // statusString already set. outputLen = 0; // unsuccessful decompression break; } } while (writePtr > 0); // Finished. if (outputLen > 0) // successful { decomp.destBufRef = new short[dest.length]; // Free any previously existing destination buffer. System.arraycopy(dest, 0, decomp.destBufRef, 0, dest.length); } return outputLen; }
[ "public", "int", "/* udword_ppt */", "decompress", "(", "final", "short", "[", "]", "/* const void* */", "source", ",", "int", "/* udword_ppt */", "size", ",", "final", "Decompressed", "decomp", ")", "{", "this", ".", "source", "=", "source", ";", "globalError", "=", "false", ";", "// assume no error", "readPtr", "=", "0", ";", "if", "(", "!", "isCompressed", "(", "source", ",", "size", ")", ")", "{", "return", "0", ";", "}", "// Uncompressed size is stored at end of source file.", "// Backwards decompression.", "readPtr", "+=", "(", "size", "-", "4", ")", ";", "int", "/* udword_ppt */", "lastDword", "=", "readBEdword", "(", "source", ",", "readPtr", ")", ";", "// Uncompressed length in bits 31-8 of last dword.", "int", "/* udword_ppt */", "outputLen", "=", "lastDword", ">>", "8", ";", "// Allocate memory for output data.", "dest", "=", "new", "short", "/* ubyte_ppt */", "[", "outputLen", "]", ";", "// Lowest dest. address for range-checks.", "// Put destptr to end of uncompressed data.", "writePtr", "=", "outputLen", ";", "// Read number of unused bits in 1st data dword", "// from lowest bits 7-0 of last dword.", "bits", "=", "32", "-", "(", "lastDword", "&", "0xFF", ")", ";", "// Main decompression loop.", "bytesTOdword", "(", ")", ";", "if", "(", "bits", "!=", "32", ")", "current", ">>=", "(", "32", "-", "bits", ")", ";", "do", "{", "if", "(", "readBits", "(", "1", ")", "==", "0", ")", "bytes", "(", ")", ";", "if", "(", "writePtr", ">", "0", ")", "sequence", "(", ")", ";", "if", "(", "globalError", ")", "{", "// statusString already set.", "outputLen", "=", "0", ";", "// unsuccessful decompression", "break", ";", "}", "}", "while", "(", "writePtr", ">", "0", ")", ";", "// Finished.", "if", "(", "outputLen", ">", "0", ")", "// successful", "{", "decomp", ".", "destBufRef", "=", "new", "short", "[", "dest", ".", "length", "]", ";", "// Free any previously existing destination buffer.", "System", ".", "arraycopy", "(", "dest", ",", "0", ",", "decomp", ".", "destBufRef", ",", "0", ",", "dest", ".", "length", ")", ";", "}", "return", "outputLen", ";", "}" ]
If successful, allocates a new buffer containing the uncompresse data and returns the uncompressed length. Else, returns 0. @return
[ "If", "successful", "allocates", "a", "new", "buffer", "containing", "the", "uncompresse", "data", "and", "returns", "the", "uncompressed", "length", ".", "Else", "returns", "0", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/sidplay/libsidplay/components/sidtune/PP20.java#L52-L109
150,114
jtrfp/javamod
src/main/java/de/quippy/sidplay/libsidplay/components/sidtune/PP20.java
PP20.readBEdword
int /* udword_ppt */readBEdword(final short[] /* ubyte_ppt[4] */ptr, int pos) { return (((((short /* udword_ppt */) ptr[pos + 0]) << 24) + (((short /* udword_ppt */) ptr[pos + 1]) << 16) + (((short /* udword_ppt */) ptr[pos + 2]) << 8) + ((short /* udword_ppt */) ptr[pos + 3])) << 0); }
java
int /* udword_ppt */readBEdword(final short[] /* ubyte_ppt[4] */ptr, int pos) { return (((((short /* udword_ppt */) ptr[pos + 0]) << 24) + (((short /* udword_ppt */) ptr[pos + 1]) << 16) + (((short /* udword_ppt */) ptr[pos + 2]) << 8) + ((short /* udword_ppt */) ptr[pos + 3])) << 0); }
[ "int", "/* udword_ppt */", "readBEdword", "(", "final", "short", "[", "]", "/* ubyte_ppt[4] */", "ptr", ",", "int", "pos", ")", "{", "return", "(", "(", "(", "(", "(", "short", "/* udword_ppt */", ")", "ptr", "[", "pos", "+", "0", "]", ")", "<<", "24", ")", "+", "(", "(", "(", "short", "/* udword_ppt */", ")", "ptr", "[", "pos", "+", "1", "]", ")", "<<", "16", ")", "+", "(", "(", "(", "short", "/* udword_ppt */", ")", "ptr", "[", "pos", "+", "2", "]", ")", "<<", "8", ")", "+", "(", "(", "short", "/* udword_ppt */", ")", "ptr", "[", "pos", "+", "3", "]", ")", ")", "<<", "0", ")", ";", "}" ]
Read a big-endian 32-bit word from four bytes in memory. No endian-specific optimizations applied. @param ptr @param pos @return
[ "Read", "a", "big", "-", "endian", "32", "-", "bit", "word", "from", "four", "bytes", "in", "memory", ".", "No", "endian", "-", "specific", "optimizations", "applied", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/sidplay/libsidplay/components/sidtune/PP20.java#L272-L277
150,115
jtrfp/javamod
src/main/java/de/quippy/jflac/frame/EntropyPartitionedRice.java
EntropyPartitionedRice.readResidual
void readResidual(BitInputStream is, int predictorOrder, int partitionOrder, Header header, int[] residual) throws IOException { //System.out.println("readREsidual Pred="+predictorOrder+" part="+partitionOrder); int sample = 0; int partitions = 1 << partitionOrder; int partitionSamples = partitionOrder > 0 ? header.blockSize >> partitionOrder : header.blockSize - predictorOrder; contents.ensureSize(Math.max(6, partitionOrder)); contents.parameters = new int[partitions]; for (int partition = 0; partition < partitions; partition++) { int riceParameter = is.readRawUInt(ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN); contents.parameters[partition] = riceParameter; if (riceParameter < ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER) { int u = (partitionOrder == 0 || partition > 0) ? partitionSamples : partitionSamples - predictorOrder; is.readRiceSignedBlock(residual, sample, u, riceParameter); sample += u; } else { riceParameter = is.readRawUInt(ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN); contents.rawBits[partition] = riceParameter; for (int u = (partitionOrder == 0 || partition > 0) ? 0 : predictorOrder; u < partitionSamples; u++, sample++) { residual[sample] = is.readRawInt(riceParameter); } } } }
java
void readResidual(BitInputStream is, int predictorOrder, int partitionOrder, Header header, int[] residual) throws IOException { //System.out.println("readREsidual Pred="+predictorOrder+" part="+partitionOrder); int sample = 0; int partitions = 1 << partitionOrder; int partitionSamples = partitionOrder > 0 ? header.blockSize >> partitionOrder : header.blockSize - predictorOrder; contents.ensureSize(Math.max(6, partitionOrder)); contents.parameters = new int[partitions]; for (int partition = 0; partition < partitions; partition++) { int riceParameter = is.readRawUInt(ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN); contents.parameters[partition] = riceParameter; if (riceParameter < ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER) { int u = (partitionOrder == 0 || partition > 0) ? partitionSamples : partitionSamples - predictorOrder; is.readRiceSignedBlock(residual, sample, u, riceParameter); sample += u; } else { riceParameter = is.readRawUInt(ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN); contents.rawBits[partition] = riceParameter; for (int u = (partitionOrder == 0 || partition > 0) ? 0 : predictorOrder; u < partitionSamples; u++, sample++) { residual[sample] = is.readRawInt(riceParameter); } } } }
[ "void", "readResidual", "(", "BitInputStream", "is", ",", "int", "predictorOrder", ",", "int", "partitionOrder", ",", "Header", "header", ",", "int", "[", "]", "residual", ")", "throws", "IOException", "{", "//System.out.println(\"readREsidual Pred=\"+predictorOrder+\" part=\"+partitionOrder);", "int", "sample", "=", "0", ";", "int", "partitions", "=", "1", "<<", "partitionOrder", ";", "int", "partitionSamples", "=", "partitionOrder", ">", "0", "?", "header", ".", "blockSize", ">>", "partitionOrder", ":", "header", ".", "blockSize", "-", "predictorOrder", ";", "contents", ".", "ensureSize", "(", "Math", ".", "max", "(", "6", ",", "partitionOrder", ")", ")", ";", "contents", ".", "parameters", "=", "new", "int", "[", "partitions", "]", ";", "for", "(", "int", "partition", "=", "0", ";", "partition", "<", "partitions", ";", "partition", "++", ")", "{", "int", "riceParameter", "=", "is", ".", "readRawUInt", "(", "ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN", ")", ";", "contents", ".", "parameters", "[", "partition", "]", "=", "riceParameter", ";", "if", "(", "riceParameter", "<", "ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER", ")", "{", "int", "u", "=", "(", "partitionOrder", "==", "0", "||", "partition", ">", "0", ")", "?", "partitionSamples", ":", "partitionSamples", "-", "predictorOrder", ";", "is", ".", "readRiceSignedBlock", "(", "residual", ",", "sample", ",", "u", ",", "riceParameter", ")", ";", "sample", "+=", "u", ";", "}", "else", "{", "riceParameter", "=", "is", ".", "readRawUInt", "(", "ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN", ")", ";", "contents", ".", "rawBits", "[", "partition", "]", "=", "riceParameter", ";", "for", "(", "int", "u", "=", "(", "partitionOrder", "==", "0", "||", "partition", ">", "0", ")", "?", "0", ":", "predictorOrder", ";", "u", "<", "partitionSamples", ";", "u", "++", ",", "sample", "++", ")", "{", "residual", "[", "sample", "]", "=", "is", ".", "readRawInt", "(", "riceParameter", ")", ";", "}", "}", "}", "}" ]
Read compressed signal residual data. @param is The InputBitStream @param predictorOrder The predicate order @param partitionOrder The partition order @param header The FLAC Frame Header @param residual The residual signal (output) @throws IOException On error reading from InputBitStream
[ "Read", "compressed", "signal", "residual", "data", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/jflac/frame/EntropyPartitionedRice.java#L49-L72
150,116
jtrfp/javamod
src/main/java/de/quippy/jflac/metadata/StreamInfo.java
StreamInfo.calcLength
public int calcLength() { int bits = STREAMINFO_MIN_BLOCK_SIZE_LEN + STREAMINFO_MAX_BLOCK_SIZE_LEN + STREAMINFO_MIN_FRAME_SIZE_LEN + STREAMINFO_MAX_FRAME_SIZE_LEN + STREAMINFO_SAMPLE_RATE_LEN + STREAMINFO_CHANNELS_LEN + STREAMINFO_BITS_PER_SAMPLE_LEN + STREAMINFO_TOTAL_SAMPLES_LEN + (md5sum.length * 8); return ((bits + 7) / 8); }
java
public int calcLength() { int bits = STREAMINFO_MIN_BLOCK_SIZE_LEN + STREAMINFO_MAX_BLOCK_SIZE_LEN + STREAMINFO_MIN_FRAME_SIZE_LEN + STREAMINFO_MAX_FRAME_SIZE_LEN + STREAMINFO_SAMPLE_RATE_LEN + STREAMINFO_CHANNELS_LEN + STREAMINFO_BITS_PER_SAMPLE_LEN + STREAMINFO_TOTAL_SAMPLES_LEN + (md5sum.length * 8); return ((bits + 7) / 8); }
[ "public", "int", "calcLength", "(", ")", "{", "int", "bits", "=", "STREAMINFO_MIN_BLOCK_SIZE_LEN", "+", "STREAMINFO_MAX_BLOCK_SIZE_LEN", "+", "STREAMINFO_MIN_FRAME_SIZE_LEN", "+", "STREAMINFO_MAX_FRAME_SIZE_LEN", "+", "STREAMINFO_SAMPLE_RATE_LEN", "+", "STREAMINFO_CHANNELS_LEN", "+", "STREAMINFO_BITS_PER_SAMPLE_LEN", "+", "STREAMINFO_TOTAL_SAMPLES_LEN", "+", "(", "md5sum", ".", "length", "*", "8", ")", ";", "return", "(", "(", "bits", "+", "7", ")", "/", "8", ")", ";", "}" ]
Calculate the metadata block size. @return The metadata block size
[ "Calculate", "the", "metadata", "block", "size", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/jflac/metadata/StreamInfo.java#L128-L139
150,117
jtrfp/javamod
src/main/java/de/quippy/jflac/metadata/StreamInfo.java
StreamInfo.compatiable
public boolean compatiable(StreamInfo info) { if (sampleRate != info.sampleRate) return false; if (channels != info.channels) return false; if (bitsPerSample != info.bitsPerSample) return false; return true; }
java
public boolean compatiable(StreamInfo info) { if (sampleRate != info.sampleRate) return false; if (channels != info.channels) return false; if (bitsPerSample != info.bitsPerSample) return false; return true; }
[ "public", "boolean", "compatiable", "(", "StreamInfo", "info", ")", "{", "if", "(", "sampleRate", "!=", "info", ".", "sampleRate", ")", "return", "false", ";", "if", "(", "channels", "!=", "info", ".", "channels", ")", "return", "false", ";", "if", "(", "bitsPerSample", "!=", "info", ".", "bitsPerSample", ")", "return", "false", ";", "return", "true", ";", "}" ]
Check for compatiable StreamInfo. Checks if sampleRate, channels, and bitsPerSample are equal @param info The StreamInfo block to check @return True if this and info are compatable
[ "Check", "for", "compatiable", "StreamInfo", ".", "Checks", "if", "sampleRate", "channels", "and", "bitsPerSample", "are", "equal" ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/jflac/metadata/StreamInfo.java#L147-L152
150,118
jpaoletti/java-presentation-manager
modules/jpm-core/src/main/java/jpaoletti/jpm/converter/GenericConverter.java
GenericConverter.readFile
public void readFile(String filename) throws ConverterException { try { content = ""; final InputStream input = ResourceManager.getInputStream(filename); while (input.available() > 0) { content = content + (char) input.read(); } input.close(); } catch (Exception e) { throw new ConverterException(e); } }
java
public void readFile(String filename) throws ConverterException { try { content = ""; final InputStream input = ResourceManager.getInputStream(filename); while (input.available() > 0) { content = content + (char) input.read(); } input.close(); } catch (Exception e) { throw new ConverterException(e); } }
[ "public", "void", "readFile", "(", "String", "filename", ")", "throws", "ConverterException", "{", "try", "{", "content", "=", "\"\"", ";", "final", "InputStream", "input", "=", "ResourceManager", ".", "getInputStream", "(", "filename", ")", ";", "while", "(", "input", ".", "available", "(", ")", ">", "0", ")", "{", "content", "=", "content", "+", "(", "char", ")", "input", ".", "read", "(", ")", ";", "}", "input", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "ConverterException", "(", "e", ")", ";", "}", "}" ]
Reads the content of the converter file @param filename The file @throws ConverterException
[ "Reads", "the", "content", "of", "the", "converter", "file" ]
d5aab55638383695db244744b4bfe27c5200e04f
https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-core/src/main/java/jpaoletti/jpm/converter/GenericConverter.java#L97-L108
150,119
zmarko/jPasswordObfuscator
jPasswordObfuscator-lib/src/main/java/rs/in/zivanovic/obfuscator/Unobfuscated.java
Unobfuscated.asByteArray
public byte[] asByteArray() { Objects.requireNonNull(data); byte[] ret = Arrays.copyOf(data, data.length); Arrays.fill(data, (byte) 0); data = null; return ret; }
java
public byte[] asByteArray() { Objects.requireNonNull(data); byte[] ret = Arrays.copyOf(data, data.length); Arrays.fill(data, (byte) 0); data = null; return ret; }
[ "public", "byte", "[", "]", "asByteArray", "(", ")", "{", "Objects", ".", "requireNonNull", "(", "data", ")", ";", "byte", "[", "]", "ret", "=", "Arrays", ".", "copyOf", "(", "data", ",", "data", ".", "length", ")", ";", "Arrays", ".", "fill", "(", "data", ",", "(", "byte", ")", "0", ")", ";", "data", "=", "null", ";", "return", "ret", ";", "}" ]
Return un-obfuscated data as byte array. @return un-obfuscated data
[ "Return", "un", "-", "obfuscated", "data", "as", "byte", "array", "." ]
40844a826bb4d6ccac0caa2480cd89c6362cfdd0
https://github.com/zmarko/jPasswordObfuscator/blob/40844a826bb4d6ccac0caa2480cd89c6362cfdd0/jPasswordObfuscator-lib/src/main/java/rs/in/zivanovic/obfuscator/Unobfuscated.java#L66-L72
150,120
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/application/launcher/DynamicLibrariesManager.java
DynamicLibrariesManager.getResourceFrom
public IO.Readable getResourceFrom(ClassLoader cl, String path, byte priority) { IOProvider.Readable provider = new IOProviderFromPathUsingClassloader(cl).get(path); if (provider == null) return null; try { return provider.provideIOReadable(priority); } catch (IOException e) { return null; } }
java
public IO.Readable getResourceFrom(ClassLoader cl, String path, byte priority) { IOProvider.Readable provider = new IOProviderFromPathUsingClassloader(cl).get(path); if (provider == null) return null; try { return provider.provideIOReadable(priority); } catch (IOException e) { return null; } }
[ "public", "IO", ".", "Readable", "getResourceFrom", "(", "ClassLoader", "cl", ",", "String", "path", ",", "byte", "priority", ")", "{", "IOProvider", ".", "Readable", "provider", "=", "new", "IOProviderFromPathUsingClassloader", "(", "cl", ")", ".", "get", "(", "path", ")", ";", "if", "(", "provider", "==", "null", ")", "return", "null", ";", "try", "{", "return", "provider", ".", "provideIOReadable", "(", "priority", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "return", "null", ";", "}", "}" ]
Open a resource from the given class loader.
[ "Open", "a", "resource", "from", "the", "given", "class", "loader", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/application/launcher/DynamicLibrariesManager.java#L800-L809
150,121
OSSIndex/heuristic-version
src/main/java/net/ossindex/version/impl/VersionListener.java
VersionListener.exitIdentifier
@Override public void exitIdentifier(VersionParser.IdentifierContext ctx) { String postfix = ctx.getText(); // A numeric postfix cannot have leading zeroes // FIXME: Check to see if an alphanumeric postfix with leading zeroes counts Matcher m = numericHasLeadingZeroes.matcher(postfix); while (m.find()) { postfix = m.replaceAll(""); } // Hack to ensure correct parsing by SemanticVersion code. A postfix MUST start with a dash, digit, or letter while (!postfix.isEmpty() && !startsWithDigitLetterOrHyphen.matcher(postfix).find()) { postfix = postfix.substring(1); } stack.push(postfix); }
java
@Override public void exitIdentifier(VersionParser.IdentifierContext ctx) { String postfix = ctx.getText(); // A numeric postfix cannot have leading zeroes // FIXME: Check to see if an alphanumeric postfix with leading zeroes counts Matcher m = numericHasLeadingZeroes.matcher(postfix); while (m.find()) { postfix = m.replaceAll(""); } // Hack to ensure correct parsing by SemanticVersion code. A postfix MUST start with a dash, digit, or letter while (!postfix.isEmpty() && !startsWithDigitLetterOrHyphen.matcher(postfix).find()) { postfix = postfix.substring(1); } stack.push(postfix); }
[ "@", "Override", "public", "void", "exitIdentifier", "(", "VersionParser", ".", "IdentifierContext", "ctx", ")", "{", "String", "postfix", "=", "ctx", ".", "getText", "(", ")", ";", "// A numeric postfix cannot have leading zeroes", "// FIXME: Check to see if an alphanumeric postfix with leading zeroes counts", "Matcher", "m", "=", "numericHasLeadingZeroes", ".", "matcher", "(", "postfix", ")", ";", "while", "(", "m", ".", "find", "(", ")", ")", "{", "postfix", "=", "m", ".", "replaceAll", "(", "\"\"", ")", ";", "}", "// Hack to ensure correct parsing by SemanticVersion code. A postfix MUST start with a dash, digit, or letter", "while", "(", "!", "postfix", ".", "isEmpty", "(", ")", "&&", "!", "startsWithDigitLetterOrHyphen", ".", "matcher", "(", "postfix", ")", ".", "find", "(", ")", ")", "{", "postfix", "=", "postfix", ".", "substring", "(", "1", ")", ";", "}", "stack", ".", "push", "(", "postfix", ")", ";", "}" ]
Normalize the postfix to something that semantic version can handle
[ "Normalize", "the", "postfix", "to", "something", "that", "semantic", "version", "can", "handle" ]
9fe33a49d74acec54ddb91de9a3c3cd2f98fba40
https://github.com/OSSIndex/heuristic-version/blob/9fe33a49d74acec54ddb91de9a3c3cd2f98fba40/src/main/java/net/ossindex/version/impl/VersionListener.java#L126-L140
150,122
OSSIndex/heuristic-version
src/main/java/net/ossindex/version/impl/VersionListener.java
VersionListener.exitNamed_version
@Override public void exitNamed_version(VersionParser.Named_versionContext ctx) { IVersion version = null; try { version = new NamedVersion(ctx.getText()); } catch (InvalidRangeException e) { throw new InvalidRangeRuntimeException(e.getMessage(), e); } stack.push(version); }
java
@Override public void exitNamed_version(VersionParser.Named_versionContext ctx) { IVersion version = null; try { version = new NamedVersion(ctx.getText()); } catch (InvalidRangeException e) { throw new InvalidRangeRuntimeException(e.getMessage(), e); } stack.push(version); }
[ "@", "Override", "public", "void", "exitNamed_version", "(", "VersionParser", ".", "Named_versionContext", "ctx", ")", "{", "IVersion", "version", "=", "null", ";", "try", "{", "version", "=", "new", "NamedVersion", "(", "ctx", ".", "getText", "(", ")", ")", ";", "}", "catch", "(", "InvalidRangeException", "e", ")", "{", "throw", "new", "InvalidRangeRuntimeException", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "stack", ".", "push", "(", "version", ")", ";", "}" ]
Get a named version.
[ "Get", "a", "named", "version", "." ]
9fe33a49d74acec54ddb91de9a3c3cd2f98fba40
https://github.com/OSSIndex/heuristic-version/blob/9fe33a49d74acec54ddb91de9a3c3cd2f98fba40/src/main/java/net/ossindex/version/impl/VersionListener.java#L244-L255
150,123
OSSIndex/heuristic-version
src/main/java/net/ossindex/version/impl/VersionListener.java
VersionListener.exitRange
@Override public void exitRange(VersionParser.RangeContext ctx) { Object o = stack.pop(); if (o instanceof IVersion) { //range = new SemanticVersionRange((SemanticVersion)o); range = new VersionSet((IVersion) o); } else if (o instanceof IVersionRange) { range = (IVersionRange) o; } }
java
@Override public void exitRange(VersionParser.RangeContext ctx) { Object o = stack.pop(); if (o instanceof IVersion) { //range = new SemanticVersionRange((SemanticVersion)o); range = new VersionSet((IVersion) o); } else if (o instanceof IVersionRange) { range = (IVersionRange) o; } }
[ "@", "Override", "public", "void", "exitRange", "(", "VersionParser", ".", "RangeContext", "ctx", ")", "{", "Object", "o", "=", "stack", ".", "pop", "(", ")", ";", "if", "(", "o", "instanceof", "IVersion", ")", "{", "//range = new SemanticVersionRange((SemanticVersion)o);", "range", "=", "new", "VersionSet", "(", "(", "IVersion", ")", "o", ")", ";", "}", "else", "if", "(", "o", "instanceof", "IVersionRange", ")", "{", "range", "=", "(", "IVersionRange", ")", "o", ";", "}", "}" ]
Get whatever is on the stack and make a version range out of it @see net.ossindex.version.parser.VersionBaseListener#exitRange(net.ossindex.version.parser.VersionParser.RangeContext)
[ "Get", "whatever", "is", "on", "the", "stack", "and", "make", "a", "version", "range", "out", "of", "it" ]
9fe33a49d74acec54ddb91de9a3c3cd2f98fba40
https://github.com/OSSIndex/heuristic-version/blob/9fe33a49d74acec54ddb91de9a3c3cd2f98fba40/src/main/java/net/ossindex/version/impl/VersionListener.java#L262-L274
150,124
OSSIndex/heuristic-version
src/main/java/net/ossindex/version/impl/VersionListener.java
VersionListener.exitSemantic_range
@Override public void exitSemantic_range(VersionParser.Semantic_rangeContext ctx) { String operator = ctx.getChild(0).getText(); Object o = stack.pop(); if (o instanceof SemanticVersion) { switch (operator) { case "^": SemanticVersion sv = (SemanticVersion) o; VersionRange from = new VersionRange(">=", sv); VersionRange to = new VersionRange("<", sv.getNextCaretVersion()); range = new AndRange(from, to); break; } stack.push(range); } else { throw new InvalidRangeRuntimeException("Expected a semantic version, got a " + o.getClass().getSimpleName()); } }
java
@Override public void exitSemantic_range(VersionParser.Semantic_rangeContext ctx) { String operator = ctx.getChild(0).getText(); Object o = stack.pop(); if (o instanceof SemanticVersion) { switch (operator) { case "^": SemanticVersion sv = (SemanticVersion) o; VersionRange from = new VersionRange(">=", sv); VersionRange to = new VersionRange("<", sv.getNextCaretVersion()); range = new AndRange(from, to); break; } stack.push(range); } else { throw new InvalidRangeRuntimeException("Expected a semantic version, got a " + o.getClass().getSimpleName()); } }
[ "@", "Override", "public", "void", "exitSemantic_range", "(", "VersionParser", ".", "Semantic_rangeContext", "ctx", ")", "{", "String", "operator", "=", "ctx", ".", "getChild", "(", "0", ")", ".", "getText", "(", ")", ";", "Object", "o", "=", "stack", ".", "pop", "(", ")", ";", "if", "(", "o", "instanceof", "SemanticVersion", ")", "{", "switch", "(", "operator", ")", "{", "case", "\"^\"", ":", "SemanticVersion", "sv", "=", "(", "SemanticVersion", ")", "o", ";", "VersionRange", "from", "=", "new", "VersionRange", "(", "\">=\"", ",", "sv", ")", ";", "VersionRange", "to", "=", "new", "VersionRange", "(", "\"<\"", ",", "sv", ".", "getNextCaretVersion", "(", ")", ")", ";", "range", "=", "new", "AndRange", "(", "from", ",", "to", ")", ";", "break", ";", "}", "stack", ".", "push", "(", "range", ")", ";", "}", "else", "{", "throw", "new", "InvalidRangeRuntimeException", "(", "\"Expected a semantic version, got a \"", "+", "o", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "}", "}" ]
Special semantic version type ranges
[ "Special", "semantic", "version", "type", "ranges" ]
9fe33a49d74acec54ddb91de9a3c3cd2f98fba40
https://github.com/OSSIndex/heuristic-version/blob/9fe33a49d74acec54ddb91de9a3c3cd2f98fba40/src/main/java/net/ossindex/version/impl/VersionListener.java#L279-L297
150,125
OSSIndex/heuristic-version
src/main/java/net/ossindex/version/impl/VersionListener.java
VersionListener.exitSimple_range
@Override public void exitSimple_range(VersionParser.Simple_rangeContext ctx) { String operator = ctx.getChild(0).getText(); Object o = stack.pop(); if (o instanceof SemanticVersion) { //range = new SemanticVersionRange((SemanticVersion)o); switch (operator) { case "~>": // Special case for "pessimistic" range, see // https://www.devalot.com/articles/2012/04/gem-versions.html SemanticVersion sv = (SemanticVersion) o; VersionRange from = new VersionRange(">=", sv); VersionRange to = new VersionRange("<", sv.getNextParentVersion()); range = new AndRange(from, to); break; default: range = new VersionRange(operator, (SemanticVersion) o); break; } stack.push(range); } else { throw new InvalidRangeRuntimeException("Expected a semantic version, got a " + o.getClass().getSimpleName()); } }
java
@Override public void exitSimple_range(VersionParser.Simple_rangeContext ctx) { String operator = ctx.getChild(0).getText(); Object o = stack.pop(); if (o instanceof SemanticVersion) { //range = new SemanticVersionRange((SemanticVersion)o); switch (operator) { case "~>": // Special case for "pessimistic" range, see // https://www.devalot.com/articles/2012/04/gem-versions.html SemanticVersion sv = (SemanticVersion) o; VersionRange from = new VersionRange(">=", sv); VersionRange to = new VersionRange("<", sv.getNextParentVersion()); range = new AndRange(from, to); break; default: range = new VersionRange(operator, (SemanticVersion) o); break; } stack.push(range); } else { throw new InvalidRangeRuntimeException("Expected a semantic version, got a " + o.getClass().getSimpleName()); } }
[ "@", "Override", "public", "void", "exitSimple_range", "(", "VersionParser", ".", "Simple_rangeContext", "ctx", ")", "{", "String", "operator", "=", "ctx", ".", "getChild", "(", "0", ")", ".", "getText", "(", ")", ";", "Object", "o", "=", "stack", ".", "pop", "(", ")", ";", "if", "(", "o", "instanceof", "SemanticVersion", ")", "{", "//range = new SemanticVersionRange((SemanticVersion)o);", "switch", "(", "operator", ")", "{", "case", "\"~>\"", ":", "// Special case for \"pessimistic\" range, see", "// https://www.devalot.com/articles/2012/04/gem-versions.html", "SemanticVersion", "sv", "=", "(", "SemanticVersion", ")", "o", ";", "VersionRange", "from", "=", "new", "VersionRange", "(", "\">=\"", ",", "sv", ")", ";", "VersionRange", "to", "=", "new", "VersionRange", "(", "\"<\"", ",", "sv", ".", "getNextParentVersion", "(", ")", ")", ";", "range", "=", "new", "AndRange", "(", "from", ",", "to", ")", ";", "break", ";", "default", ":", "range", "=", "new", "VersionRange", "(", "operator", ",", "(", "SemanticVersion", ")", "o", ")", ";", "break", ";", "}", "stack", ".", "push", "(", "range", ")", ";", "}", "else", "{", "throw", "new", "InvalidRangeRuntimeException", "(", "\"Expected a semantic version, got a \"", "+", "o", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "}", "}" ]
A simple range. < 1.2.5 @see net.ossindex.version.parser.VersionBaseListener#exitSimple_range(net.ossindex.version.parser.VersionParser.Simple_rangeContext)
[ "A", "simple", "range", "." ]
9fe33a49d74acec54ddb91de9a3c3cd2f98fba40
https://github.com/OSSIndex/heuristic-version/blob/9fe33a49d74acec54ddb91de9a3c3cd2f98fba40/src/main/java/net/ossindex/version/impl/VersionListener.java#L306-L331
150,126
OSSIndex/heuristic-version
src/main/java/net/ossindex/version/impl/VersionListener.java
VersionListener.exitVersion_set
@Override public void exitVersion_set(VersionParser.Version_setContext ctx) { Object o1 = stack.pop(); if (strict && (o1 instanceof NamedVersion)) { String name = o1.toString(); // FIXME: There needs to be a better way to identify illegal named versions. Perhaps insist it contains an alphanumeric? switch (name.trim()) { case "-": case "_": throw new InvalidRangeRuntimeException("Invalid named version: " + o1); default: break; } } if (stack.isEmpty()) { VersionSet set = new VersionSet((IVersion) o1); stack.push(set); } else { VersionSet set = (VersionSet) stack.peek(); set.add((IVersion) o1); } }
java
@Override public void exitVersion_set(VersionParser.Version_setContext ctx) { Object o1 = stack.pop(); if (strict && (o1 instanceof NamedVersion)) { String name = o1.toString(); // FIXME: There needs to be a better way to identify illegal named versions. Perhaps insist it contains an alphanumeric? switch (name.trim()) { case "-": case "_": throw new InvalidRangeRuntimeException("Invalid named version: " + o1); default: break; } } if (stack.isEmpty()) { VersionSet set = new VersionSet((IVersion) o1); stack.push(set); } else { VersionSet set = (VersionSet) stack.peek(); set.add((IVersion) o1); } }
[ "@", "Override", "public", "void", "exitVersion_set", "(", "VersionParser", ".", "Version_setContext", "ctx", ")", "{", "Object", "o1", "=", "stack", ".", "pop", "(", ")", ";", "if", "(", "strict", "&&", "(", "o1", "instanceof", "NamedVersion", ")", ")", "{", "String", "name", "=", "o1", ".", "toString", "(", ")", ";", "// FIXME: There needs to be a better way to identify illegal named versions. Perhaps insist it contains an alphanumeric?", "switch", "(", "name", ".", "trim", "(", ")", ")", "{", "case", "\"-\"", ":", "case", "\"_\"", ":", "throw", "new", "InvalidRangeRuntimeException", "(", "\"Invalid named version: \"", "+", "o1", ")", ";", "default", ":", "break", ";", "}", "}", "if", "(", "stack", ".", "isEmpty", "(", ")", ")", "{", "VersionSet", "set", "=", "new", "VersionSet", "(", "(", "IVersion", ")", "o1", ")", ";", "stack", ".", "push", "(", "set", ")", ";", "}", "else", "{", "VersionSet", "set", "=", "(", "VersionSet", ")", "stack", ".", "peek", "(", ")", ";", "set", ".", "add", "(", "(", "IVersion", ")", "o1", ")", ";", "}", "}" ]
Set of versions @see net.ossindex.version.parser.VersionBaseListener#exitVersion_set(net.ossindex.version.parser.VersionParser.Version_setContext)
[ "Set", "of", "versions" ]
9fe33a49d74acec54ddb91de9a3c3cd2f98fba40
https://github.com/OSSIndex/heuristic-version/blob/9fe33a49d74acec54ddb91de9a3c3cd2f98fba40/src/main/java/net/ossindex/version/impl/VersionListener.java#L338-L361
150,127
OSSIndex/heuristic-version
src/main/java/net/ossindex/version/impl/NamedVersion.java
NamedVersion.isValidNamedVersion
public boolean isValidNamedVersion(final String s) { if (SEMANTIC_RANGE_SPECIAL_CHARS.matcher(s).find() || SET_RANGE_SPECIAL_CHARS.matcher(s).find() || INVALID_VERSION_CHARS.matcher(s).find() ) { return false; } return true; }
java
public boolean isValidNamedVersion(final String s) { if (SEMANTIC_RANGE_SPECIAL_CHARS.matcher(s).find() || SET_RANGE_SPECIAL_CHARS.matcher(s).find() || INVALID_VERSION_CHARS.matcher(s).find() ) { return false; } return true; }
[ "public", "boolean", "isValidNamedVersion", "(", "final", "String", "s", ")", "{", "if", "(", "SEMANTIC_RANGE_SPECIAL_CHARS", ".", "matcher", "(", "s", ")", ".", "find", "(", ")", "||", "SET_RANGE_SPECIAL_CHARS", ".", "matcher", "(", "s", ")", ".", "find", "(", ")", "||", "INVALID_VERSION_CHARS", ".", "matcher", "(", "s", ")", ".", "find", "(", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
People use all sorts of whack characters in version. We are just excluding the smallest set that we can.
[ "People", "use", "all", "sorts", "of", "whack", "characters", "in", "version", ".", "We", "are", "just", "excluding", "the", "smallest", "set", "that", "we", "can", "." ]
9fe33a49d74acec54ddb91de9a3c3cd2f98fba40
https://github.com/OSSIndex/heuristic-version/blob/9fe33a49d74acec54ddb91de9a3c3cd2f98fba40/src/main/java/net/ossindex/version/impl/NamedVersion.java#L154-L162
150,128
danidemi/jlubricant
jlubricant-embeddable-h2/src/main/java/com/danidemi/jlubricant/embeddable/h2/H2Dbms.java
H2Dbms.dbByName
@Override public JdbcDatabaseDescriptor dbByName(final String dbName) { Collection<H2DatabaseWorking> select = CollectionUtils.select(dbsw, new Predicate<H2DatabaseWorking>() { @Override public boolean evaluate(H2DatabaseWorking db) { return dbName.equals( db.getName() ); } }); if(CollectionUtils.size(select)==0){ throw new IllegalArgumentException("There are no databases called '" + dbName + "'"); } if(CollectionUtils.size(select)>=2){ throw new IllegalArgumentException("More than one database is called '" + dbName + "'"); } return CollectionUtils.extractSingleton( select ); }
java
@Override public JdbcDatabaseDescriptor dbByName(final String dbName) { Collection<H2DatabaseWorking> select = CollectionUtils.select(dbsw, new Predicate<H2DatabaseWorking>() { @Override public boolean evaluate(H2DatabaseWorking db) { return dbName.equals( db.getName() ); } }); if(CollectionUtils.size(select)==0){ throw new IllegalArgumentException("There are no databases called '" + dbName + "'"); } if(CollectionUtils.size(select)>=2){ throw new IllegalArgumentException("More than one database is called '" + dbName + "'"); } return CollectionUtils.extractSingleton( select ); }
[ "@", "Override", "public", "JdbcDatabaseDescriptor", "dbByName", "(", "final", "String", "dbName", ")", "{", "Collection", "<", "H2DatabaseWorking", ">", "select", "=", "CollectionUtils", ".", "select", "(", "dbsw", ",", "new", "Predicate", "<", "H2DatabaseWorking", ">", "(", ")", "{", "@", "Override", "public", "boolean", "evaluate", "(", "H2DatabaseWorking", "db", ")", "{", "return", "dbName", ".", "equals", "(", "db", ".", "getName", "(", ")", ")", ";", "}", "}", ")", ";", "if", "(", "CollectionUtils", ".", "size", "(", "select", ")", "==", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"There are no databases called '\"", "+", "dbName", "+", "\"'\"", ")", ";", "}", "if", "(", "CollectionUtils", ".", "size", "(", "select", ")", ">=", "2", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"More than one database is called '\"", "+", "dbName", "+", "\"'\"", ")", ";", "}", "return", "CollectionUtils", ".", "extractSingleton", "(", "select", ")", ";", "}" ]
Get a database by its name.
[ "Get", "a", "database", "by", "its", "name", "." ]
a9937c141c69ec34b768bd603b8093e496329b3a
https://github.com/danidemi/jlubricant/blob/a9937c141c69ec34b768bd603b8093e496329b3a/jlubricant-embeddable-h2/src/main/java/com/danidemi/jlubricant/embeddable/h2/H2Dbms.java#L108-L125
150,129
PureSolTechnologies/graphs
trees/src/main/java/com/puresoltechnologies/graphs/trees/TreeWalker.java
TreeWalker.walk
private WalkingAction walk(N tree, TreeVisitor<N> walkerClient) { WalkingAction action = walkerClient.visit(tree); if (action == WalkingAction.ABORT) { return WalkingAction.ABORT; } else if (action == WalkingAction.LEAVE_BRANCH) { return WalkingAction.PROCEED; } for (N child : tree.getChildren()) { if (walk(child, walkerClient) == WalkingAction.ABORT) { return WalkingAction.ABORT; } } return WalkingAction.PROCEED; }
java
private WalkingAction walk(N tree, TreeVisitor<N> walkerClient) { WalkingAction action = walkerClient.visit(tree); if (action == WalkingAction.ABORT) { return WalkingAction.ABORT; } else if (action == WalkingAction.LEAVE_BRANCH) { return WalkingAction.PROCEED; } for (N child : tree.getChildren()) { if (walk(child, walkerClient) == WalkingAction.ABORT) { return WalkingAction.ABORT; } } return WalkingAction.PROCEED; }
[ "private", "WalkingAction", "walk", "(", "N", "tree", ",", "TreeVisitor", "<", "N", ">", "walkerClient", ")", "{", "WalkingAction", "action", "=", "walkerClient", ".", "visit", "(", "tree", ")", ";", "if", "(", "action", "==", "WalkingAction", ".", "ABORT", ")", "{", "return", "WalkingAction", ".", "ABORT", ";", "}", "else", "if", "(", "action", "==", "WalkingAction", ".", "LEAVE_BRANCH", ")", "{", "return", "WalkingAction", ".", "PROCEED", ";", "}", "for", "(", "N", "child", ":", "tree", ".", "getChildren", "(", ")", ")", "{", "if", "(", "walk", "(", "child", ",", "walkerClient", ")", "==", "WalkingAction", ".", "ABORT", ")", "{", "return", "WalkingAction", ".", "ABORT", ";", "}", "}", "return", "WalkingAction", ".", "PROCEED", ";", "}" ]
This is the recursive part of the walk method. @param tree @param walkerClient @return
[ "This", "is", "the", "recursive", "part", "of", "the", "walk", "method", "." ]
35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1
https://github.com/PureSolTechnologies/graphs/blob/35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1/trees/src/main/java/com/puresoltechnologies/graphs/trees/TreeWalker.java#L61-L74
150,130
amlinv/amq-monitor
amq-monitor-web-impl/src/main/java/com/amlinv/activemq/monitor/model/ActiveMQQueueJmxStats.java
ActiveMQQueueJmxStats.addCounts
public ActiveMQQueueJmxStats addCounts(ActiveMQQueueJmxStats other, String resultBrokerName) { ActiveMQQueueJmxStats result = new ActiveMQQueueJmxStats(resultBrokerName, this.queueName); result.setCursorPercentUsage(this.getCursorPercentUsage()); result.setDequeueCount(this.getDequeueCount() + other.getDequeueCount()); result.setEnqueueCount(this.getEnqueueCount() + other.getEnqueueCount()); result.setMemoryPercentUsage(this.getMemoryPercentUsage()); result.setNumConsumers(this.getNumConsumers() + other.getNumConsumers()); result.setNumProducers(this.getNumProducers() + other.getNumProducers()); result.setQueueSize(this.getQueueSize() + other.getQueueSize()); result.setInflightCount(this.getInflightCount() + other.getInflightCount()); return result; }
java
public ActiveMQQueueJmxStats addCounts(ActiveMQQueueJmxStats other, String resultBrokerName) { ActiveMQQueueJmxStats result = new ActiveMQQueueJmxStats(resultBrokerName, this.queueName); result.setCursorPercentUsage(this.getCursorPercentUsage()); result.setDequeueCount(this.getDequeueCount() + other.getDequeueCount()); result.setEnqueueCount(this.getEnqueueCount() + other.getEnqueueCount()); result.setMemoryPercentUsage(this.getMemoryPercentUsage()); result.setNumConsumers(this.getNumConsumers() + other.getNumConsumers()); result.setNumProducers(this.getNumProducers() + other.getNumProducers()); result.setQueueSize(this.getQueueSize() + other.getQueueSize()); result.setInflightCount(this.getInflightCount() + other.getInflightCount()); return result; }
[ "public", "ActiveMQQueueJmxStats", "addCounts", "(", "ActiveMQQueueJmxStats", "other", ",", "String", "resultBrokerName", ")", "{", "ActiveMQQueueJmxStats", "result", "=", "new", "ActiveMQQueueJmxStats", "(", "resultBrokerName", ",", "this", ".", "queueName", ")", ";", "result", ".", "setCursorPercentUsage", "(", "this", ".", "getCursorPercentUsage", "(", ")", ")", ";", "result", ".", "setDequeueCount", "(", "this", ".", "getDequeueCount", "(", ")", "+", "other", ".", "getDequeueCount", "(", ")", ")", ";", "result", ".", "setEnqueueCount", "(", "this", ".", "getEnqueueCount", "(", ")", "+", "other", ".", "getEnqueueCount", "(", ")", ")", ";", "result", ".", "setMemoryPercentUsage", "(", "this", ".", "getMemoryPercentUsage", "(", ")", ")", ";", "result", ".", "setNumConsumers", "(", "this", ".", "getNumConsumers", "(", ")", "+", "other", ".", "getNumConsumers", "(", ")", ")", ";", "result", ".", "setNumProducers", "(", "this", ".", "getNumProducers", "(", ")", "+", "other", ".", "getNumProducers", "(", ")", ")", ";", "result", ".", "setQueueSize", "(", "this", ".", "getQueueSize", "(", ")", "+", "other", ".", "getQueueSize", "(", ")", ")", ";", "result", ".", "setInflightCount", "(", "this", ".", "getInflightCount", "(", ")", "+", "other", ".", "getInflightCount", "(", ")", ")", ";", "return", "result", ";", "}" ]
Return a new queue stats structure with the total of the stats from this structure and the one given. Returning a new structure keeps all three structures unchanged, in the manner of immutability, to make it easier to have safe usage under concurrency. Note that non-count values are copied out from this instance; those values from the given other stats are ignored. @param other @param resultBrokerName @return
[ "Return", "a", "new", "queue", "stats", "structure", "with", "the", "total", "of", "the", "stats", "from", "this", "structure", "and", "the", "one", "given", ".", "Returning", "a", "new", "structure", "keeps", "all", "three", "structures", "unchanged", "in", "the", "manner", "of", "immutability", "to", "make", "it", "easier", "to", "have", "safe", "usage", "under", "concurrency", ".", "Note", "that", "non", "-", "count", "values", "are", "copied", "out", "from", "this", "instance", ";", "those", "values", "from", "the", "given", "other", "stats", "are", "ignored", "." ]
0ae0156f56d7d3edf98bca9c30b153b770fe5bfa
https://github.com/amlinv/amq-monitor/blob/0ae0156f56d7d3edf98bca9c30b153b770fe5bfa/amq-monitor-web-impl/src/main/java/com/amlinv/activemq/monitor/model/ActiveMQQueueJmxStats.java#L146-L158
150,131
amlinv/amq-monitor
amq-monitor-web-impl/src/main/java/com/amlinv/activemq/monitor/model/ActiveMQQueueJmxStats.java
ActiveMQQueueJmxStats.dup
public ActiveMQQueueJmxStats dup (String brokerName) { ActiveMQQueueJmxStats result = new ActiveMQQueueJmxStats(brokerName, this.queueName); this.copyOut(result); return result; }
java
public ActiveMQQueueJmxStats dup (String brokerName) { ActiveMQQueueJmxStats result = new ActiveMQQueueJmxStats(brokerName, this.queueName); this.copyOut(result); return result; }
[ "public", "ActiveMQQueueJmxStats", "dup", "(", "String", "brokerName", ")", "{", "ActiveMQQueueJmxStats", "result", "=", "new", "ActiveMQQueueJmxStats", "(", "brokerName", ",", "this", ".", "queueName", ")", ";", "this", ".", "copyOut", "(", "result", ")", ";", "return", "result", ";", "}" ]
Return a duplicate of this queue stats structure. @return new queue stats structure with the same values.
[ "Return", "a", "duplicate", "of", "this", "queue", "stats", "structure", "." ]
0ae0156f56d7d3edf98bca9c30b153b770fe5bfa
https://github.com/amlinv/amq-monitor/blob/0ae0156f56d7d3edf98bca9c30b153b770fe5bfa/amq-monitor-web-impl/src/main/java/com/amlinv/activemq/monitor/model/ActiveMQQueueJmxStats.java#L165-L170
150,132
amlinv/amq-monitor
amq-monitor-web-impl/src/main/java/com/amlinv/activemq/monitor/model/ActiveMQQueueJmxStats.java
ActiveMQQueueJmxStats.copyOut
public void copyOut (ActiveMQQueueJmxStats other) { other.setCursorPercentUsage(this.getCursorPercentUsage()); other.setDequeueCount(this.getDequeueCount()); other.setEnqueueCount(this.getEnqueueCount()); other.setMemoryPercentUsage(this.getMemoryPercentUsage()); other.setNumConsumers(this.getNumConsumers()); other.setNumProducers(this.getNumProducers()); other.setQueueSize(this.getQueueSize()); other.setInflightCount(this.getInflightCount()); }
java
public void copyOut (ActiveMQQueueJmxStats other) { other.setCursorPercentUsage(this.getCursorPercentUsage()); other.setDequeueCount(this.getDequeueCount()); other.setEnqueueCount(this.getEnqueueCount()); other.setMemoryPercentUsage(this.getMemoryPercentUsage()); other.setNumConsumers(this.getNumConsumers()); other.setNumProducers(this.getNumProducers()); other.setQueueSize(this.getQueueSize()); other.setInflightCount(this.getInflightCount()); }
[ "public", "void", "copyOut", "(", "ActiveMQQueueJmxStats", "other", ")", "{", "other", ".", "setCursorPercentUsage", "(", "this", ".", "getCursorPercentUsage", "(", ")", ")", ";", "other", ".", "setDequeueCount", "(", "this", ".", "getDequeueCount", "(", ")", ")", ";", "other", ".", "setEnqueueCount", "(", "this", ".", "getEnqueueCount", "(", ")", ")", ";", "other", ".", "setMemoryPercentUsage", "(", "this", ".", "getMemoryPercentUsage", "(", ")", ")", ";", "other", ".", "setNumConsumers", "(", "this", ".", "getNumConsumers", "(", ")", ")", ";", "other", ".", "setNumProducers", "(", "this", ".", "getNumProducers", "(", ")", ")", ";", "other", ".", "setQueueSize", "(", "this", ".", "getQueueSize", "(", ")", ")", ";", "other", ".", "setInflightCount", "(", "this", ".", "getInflightCount", "(", ")", ")", ";", "}" ]
Copy out the values to the given destination. @param other target stats object to receive the values from this one.
[ "Copy", "out", "the", "values", "to", "the", "given", "destination", "." ]
0ae0156f56d7d3edf98bca9c30b153b770fe5bfa
https://github.com/amlinv/amq-monitor/blob/0ae0156f56d7d3edf98bca9c30b153b770fe5bfa/amq-monitor-web-impl/src/main/java/com/amlinv/activemq/monitor/model/ActiveMQQueueJmxStats.java#L177-L186
150,133
jtrfp/javamod
src/main/java/de/quippy/ogg/jorbis/Mdct.java
Mdct.init
void init(int n){ bitrev=new int[n/4]; trig=new float[n+n/4]; log2n=(int)Math.rint(Math.log(n)/Math.log(2)); this.n=n; int AE=0; int AO=1; int BE=AE+n/2; int BO=BE+1; int CE=BE+n/2; int CO=CE+1; // trig lookups... for(int i=0; i<n/4; i++){ trig[AE+i*2]=(float)Math.cos((Math.PI/n)*(4*i)); trig[AO+i*2]=(float)-Math.sin((Math.PI/n)*(4*i)); trig[BE+i*2]=(float)Math.cos((Math.PI/(2*n))*(2*i+1)); trig[BO+i*2]=(float)Math.sin((Math.PI/(2*n))*(2*i+1)); } for(int i=0; i<n/8; i++){ trig[CE+i*2]=(float)Math.cos((Math.PI/n)*(4*i+2)); trig[CO+i*2]=(float)-Math.sin((Math.PI/n)*(4*i+2)); } { int mask=(1<<(log2n-1))-1; int msb=1<<(log2n-2); for(int i=0; i<n/8; i++){ int acc=0; for(int j=0; msb>>>j!=0; j++) if(((msb>>>j)&i)!=0) acc|=1<<j; bitrev[i*2]=((~acc)&mask); // bitrev[i*2]=((~acc)&mask)-1; bitrev[i*2+1]=acc; } } //scale=4.f/n; }
java
void init(int n){ bitrev=new int[n/4]; trig=new float[n+n/4]; log2n=(int)Math.rint(Math.log(n)/Math.log(2)); this.n=n; int AE=0; int AO=1; int BE=AE+n/2; int BO=BE+1; int CE=BE+n/2; int CO=CE+1; // trig lookups... for(int i=0; i<n/4; i++){ trig[AE+i*2]=(float)Math.cos((Math.PI/n)*(4*i)); trig[AO+i*2]=(float)-Math.sin((Math.PI/n)*(4*i)); trig[BE+i*2]=(float)Math.cos((Math.PI/(2*n))*(2*i+1)); trig[BO+i*2]=(float)Math.sin((Math.PI/(2*n))*(2*i+1)); } for(int i=0; i<n/8; i++){ trig[CE+i*2]=(float)Math.cos((Math.PI/n)*(4*i+2)); trig[CO+i*2]=(float)-Math.sin((Math.PI/n)*(4*i+2)); } { int mask=(1<<(log2n-1))-1; int msb=1<<(log2n-2); for(int i=0; i<n/8; i++){ int acc=0; for(int j=0; msb>>>j!=0; j++) if(((msb>>>j)&i)!=0) acc|=1<<j; bitrev[i*2]=((~acc)&mask); // bitrev[i*2]=((~acc)&mask)-1; bitrev[i*2+1]=acc; } } //scale=4.f/n; }
[ "void", "init", "(", "int", "n", ")", "{", "bitrev", "=", "new", "int", "[", "n", "/", "4", "]", ";", "trig", "=", "new", "float", "[", "n", "+", "n", "/", "4", "]", ";", "log2n", "=", "(", "int", ")", "Math", ".", "rint", "(", "Math", ".", "log", "(", "n", ")", "/", "Math", ".", "log", "(", "2", ")", ")", ";", "this", ".", "n", "=", "n", ";", "int", "AE", "=", "0", ";", "int", "AO", "=", "1", ";", "int", "BE", "=", "AE", "+", "n", "/", "2", ";", "int", "BO", "=", "BE", "+", "1", ";", "int", "CE", "=", "BE", "+", "n", "/", "2", ";", "int", "CO", "=", "CE", "+", "1", ";", "// trig lookups...", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n", "/", "4", ";", "i", "++", ")", "{", "trig", "[", "AE", "+", "i", "*", "2", "]", "=", "(", "float", ")", "Math", ".", "cos", "(", "(", "Math", ".", "PI", "/", "n", ")", "*", "(", "4", "*", "i", ")", ")", ";", "trig", "[", "AO", "+", "i", "*", "2", "]", "=", "(", "float", ")", "-", "Math", ".", "sin", "(", "(", "Math", ".", "PI", "/", "n", ")", "*", "(", "4", "*", "i", ")", ")", ";", "trig", "[", "BE", "+", "i", "*", "2", "]", "=", "(", "float", ")", "Math", ".", "cos", "(", "(", "Math", ".", "PI", "/", "(", "2", "*", "n", ")", ")", "*", "(", "2", "*", "i", "+", "1", ")", ")", ";", "trig", "[", "BO", "+", "i", "*", "2", "]", "=", "(", "float", ")", "Math", ".", "sin", "(", "(", "Math", ".", "PI", "/", "(", "2", "*", "n", ")", ")", "*", "(", "2", "*", "i", "+", "1", ")", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n", "/", "8", ";", "i", "++", ")", "{", "trig", "[", "CE", "+", "i", "*", "2", "]", "=", "(", "float", ")", "Math", ".", "cos", "(", "(", "Math", ".", "PI", "/", "n", ")", "*", "(", "4", "*", "i", "+", "2", ")", ")", ";", "trig", "[", "CO", "+", "i", "*", "2", "]", "=", "(", "float", ")", "-", "Math", ".", "sin", "(", "(", "Math", ".", "PI", "/", "n", ")", "*", "(", "4", "*", "i", "+", "2", ")", ")", ";", "}", "{", "int", "mask", "=", "(", "1", "<<", "(", "log2n", "-", "1", ")", ")", "-", "1", ";", "int", "msb", "=", "1", "<<", "(", "log2n", "-", "2", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n", "/", "8", ";", "i", "++", ")", "{", "int", "acc", "=", "0", ";", "for", "(", "int", "j", "=", "0", ";", "msb", ">>>", "j", "!=", "0", ";", "j", "++", ")", "if", "(", "(", "(", "msb", ">>>", "j", ")", "&", "i", ")", "!=", "0", ")", "acc", "|=", "1", "<<", "j", ";", "bitrev", "[", "i", "*", "2", "]", "=", "(", "(", "~", "acc", ")", "&", "mask", ")", ";", "//\tbitrev[i*2]=((~acc)&mask)-1;", "bitrev", "[", "i", "*", "2", "+", "1", "]", "=", "acc", ";", "}", "}", "//scale=4.f/n;", "}" ]
float scale;
[ "float", "scale", ";" ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/ogg/jorbis/Mdct.java#L39-L78
150,134
jpaoletti/java-presentation-manager
modules/jpm-core/src/main/java/jpaoletti/jpm/converter/Converters.java
Converters.getConverterForOperation
public Converter getConverterForOperation(String operId) { if (getConverters() != null) { for (Converter converter : getConverters()) { if (check(converter, converter.getOperations(), operId)) { return converter; } } } if (getExternalConverters() != null) { for (ExternalConverter ecs : getExternalConverters()) { final Converter c = PresentationManager.getPm().findExternalConverter(ecs.getId()); if (c != null && check(c, (ecs.getOperations() == null) ? c.getOperations() : ecs.getOperations(), operId)) { //TODO Add override of properties. return c; } } } return null; }
java
public Converter getConverterForOperation(String operId) { if (getConverters() != null) { for (Converter converter : getConverters()) { if (check(converter, converter.getOperations(), operId)) { return converter; } } } if (getExternalConverters() != null) { for (ExternalConverter ecs : getExternalConverters()) { final Converter c = PresentationManager.getPm().findExternalConverter(ecs.getId()); if (c != null && check(c, (ecs.getOperations() == null) ? c.getOperations() : ecs.getOperations(), operId)) { //TODO Add override of properties. return c; } } } return null; }
[ "public", "Converter", "getConverterForOperation", "(", "String", "operId", ")", "{", "if", "(", "getConverters", "(", ")", "!=", "null", ")", "{", "for", "(", "Converter", "converter", ":", "getConverters", "(", ")", ")", "{", "if", "(", "check", "(", "converter", ",", "converter", ".", "getOperations", "(", ")", ",", "operId", ")", ")", "{", "return", "converter", ";", "}", "}", "}", "if", "(", "getExternalConverters", "(", ")", "!=", "null", ")", "{", "for", "(", "ExternalConverter", "ecs", ":", "getExternalConverters", "(", ")", ")", "{", "final", "Converter", "c", "=", "PresentationManager", ".", "getPm", "(", ")", ".", "findExternalConverter", "(", "ecs", ".", "getId", "(", ")", ")", ";", "if", "(", "c", "!=", "null", "&&", "check", "(", "c", ",", "(", "ecs", ".", "getOperations", "(", ")", "==", "null", ")", "?", "c", ".", "getOperations", "(", ")", ":", "ecs", ".", "getOperations", "(", ")", ",", "operId", ")", ")", "{", "//TODO Add override of properties.", "return", "c", ";", "}", "}", "}", "return", "null", ";", "}" ]
Looks for an aproppiate converter for the given operation id. @param operId The operation id @return The first converter that matches this operation.
[ "Looks", "for", "an", "aproppiate", "converter", "for", "the", "given", "operation", "id", "." ]
d5aab55638383695db244744b4bfe27c5200e04f
https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-core/src/main/java/jpaoletti/jpm/converter/Converters.java#L18-L36
150,135
jtrfp/javamod
src/main/java/de/quippy/ogg/jorbis/Residue0.java
Residue0._01inverse
synchronized static int _01inverse(Block vb, Object vl, float[][] in, int ch, int decodepart){ int i, j, k, l, s; LookResidue0 look=(LookResidue0)vl; InfoResidue0 info=look.info; // move all this setup out later int samples_per_partition=info.grouping; int partitions_per_word=look.phrasebook.dim; int n=info.end-info.begin; int partvals=n/samples_per_partition; int partwords=(partvals+partitions_per_word-1)/partitions_per_word; if(_01inverse_partword.length<ch){ _01inverse_partword=new int[ch][][]; } for(j=0; j<ch; j++){ if(_01inverse_partword[j]==null||_01inverse_partword[j].length<partwords){ _01inverse_partword[j]=new int[partwords][]; } } for(s=0; s<look.stages; s++){ // each loop decodes on partition codeword containing // partitions_pre_word partitions for(i=0, l=0; i<partvals; l++){ if(s==0){ // fetch the partition word for each channel for(j=0; j<ch; j++){ int temp=look.phrasebook.decode(vb.opb); if(temp==-1){ return (0); } _01inverse_partword[j][l]=look.decodemap[temp]; if(_01inverse_partword[j][l]==null){ return (0); } } } // now we decode residual values for the partitions for(k=0; k<partitions_per_word&&i<partvals; k++, i++) for(j=0; j<ch; j++){ int offset=info.begin+i*samples_per_partition; int index=_01inverse_partword[j][l][k]; if((info.secondstages[index]&(1<<s))!=0){ CodeBook stagebook=look.fullbooks[look.partbooks[index][s]]; if(stagebook!=null){ if(decodepart==0){ if(stagebook.decodevs_add(in[j], offset, vb.opb, samples_per_partition)==-1){ return (0); } } else if(decodepart==1){ if(stagebook.decodev_add(in[j], offset, vb.opb, samples_per_partition)==-1){ return (0); } } } } } } } return (0); }
java
synchronized static int _01inverse(Block vb, Object vl, float[][] in, int ch, int decodepart){ int i, j, k, l, s; LookResidue0 look=(LookResidue0)vl; InfoResidue0 info=look.info; // move all this setup out later int samples_per_partition=info.grouping; int partitions_per_word=look.phrasebook.dim; int n=info.end-info.begin; int partvals=n/samples_per_partition; int partwords=(partvals+partitions_per_word-1)/partitions_per_word; if(_01inverse_partword.length<ch){ _01inverse_partword=new int[ch][][]; } for(j=0; j<ch; j++){ if(_01inverse_partword[j]==null||_01inverse_partword[j].length<partwords){ _01inverse_partword[j]=new int[partwords][]; } } for(s=0; s<look.stages; s++){ // each loop decodes on partition codeword containing // partitions_pre_word partitions for(i=0, l=0; i<partvals; l++){ if(s==0){ // fetch the partition word for each channel for(j=0; j<ch; j++){ int temp=look.phrasebook.decode(vb.opb); if(temp==-1){ return (0); } _01inverse_partword[j][l]=look.decodemap[temp]; if(_01inverse_partword[j][l]==null){ return (0); } } } // now we decode residual values for the partitions for(k=0; k<partitions_per_word&&i<partvals; k++, i++) for(j=0; j<ch; j++){ int offset=info.begin+i*samples_per_partition; int index=_01inverse_partword[j][l][k]; if((info.secondstages[index]&(1<<s))!=0){ CodeBook stagebook=look.fullbooks[look.partbooks[index][s]]; if(stagebook!=null){ if(decodepart==0){ if(stagebook.decodevs_add(in[j], offset, vb.opb, samples_per_partition)==-1){ return (0); } } else if(decodepart==1){ if(stagebook.decodev_add(in[j], offset, vb.opb, samples_per_partition)==-1){ return (0); } } } } } } } return (0); }
[ "synchronized", "static", "int", "_01inverse", "(", "Block", "vb", ",", "Object", "vl", ",", "float", "[", "]", "[", "]", "in", ",", "int", "ch", ",", "int", "decodepart", ")", "{", "int", "i", ",", "j", ",", "k", ",", "l", ",", "s", ";", "LookResidue0", "look", "=", "(", "LookResidue0", ")", "vl", ";", "InfoResidue0", "info", "=", "look", ".", "info", ";", "// move all this setup out later", "int", "samples_per_partition", "=", "info", ".", "grouping", ";", "int", "partitions_per_word", "=", "look", ".", "phrasebook", ".", "dim", ";", "int", "n", "=", "info", ".", "end", "-", "info", ".", "begin", ";", "int", "partvals", "=", "n", "/", "samples_per_partition", ";", "int", "partwords", "=", "(", "partvals", "+", "partitions_per_word", "-", "1", ")", "/", "partitions_per_word", ";", "if", "(", "_01inverse_partword", ".", "length", "<", "ch", ")", "{", "_01inverse_partword", "=", "new", "int", "[", "ch", "]", "[", "", "]", "[", "", "]", ";", "}", "for", "(", "j", "=", "0", ";", "j", "<", "ch", ";", "j", "++", ")", "{", "if", "(", "_01inverse_partword", "[", "j", "]", "==", "null", "||", "_01inverse_partword", "[", "j", "]", ".", "length", "<", "partwords", ")", "{", "_01inverse_partword", "[", "j", "]", "=", "new", "int", "[", "partwords", "]", "[", "", "]", ";", "}", "}", "for", "(", "s", "=", "0", ";", "s", "<", "look", ".", "stages", ";", "s", "++", ")", "{", "// each loop decodes on partition codeword containing ", "// partitions_pre_word partitions", "for", "(", "i", "=", "0", ",", "l", "=", "0", ";", "i", "<", "partvals", ";", "l", "++", ")", "{", "if", "(", "s", "==", "0", ")", "{", "// fetch the partition word for each channel", "for", "(", "j", "=", "0", ";", "j", "<", "ch", ";", "j", "++", ")", "{", "int", "temp", "=", "look", ".", "phrasebook", ".", "decode", "(", "vb", ".", "opb", ")", ";", "if", "(", "temp", "==", "-", "1", ")", "{", "return", "(", "0", ")", ";", "}", "_01inverse_partword", "[", "j", "]", "[", "l", "]", "=", "look", ".", "decodemap", "[", "temp", "]", ";", "if", "(", "_01inverse_partword", "[", "j", "]", "[", "l", "]", "==", "null", ")", "{", "return", "(", "0", ")", ";", "}", "}", "}", "// now we decode residual values for the partitions", "for", "(", "k", "=", "0", ";", "k", "<", "partitions_per_word", "&&", "i", "<", "partvals", ";", "k", "++", ",", "i", "++", ")", "for", "(", "j", "=", "0", ";", "j", "<", "ch", ";", "j", "++", ")", "{", "int", "offset", "=", "info", ".", "begin", "+", "i", "*", "samples_per_partition", ";", "int", "index", "=", "_01inverse_partword", "[", "j", "]", "[", "l", "]", "[", "k", "]", ";", "if", "(", "(", "info", ".", "secondstages", "[", "index", "]", "&", "(", "1", "<<", "s", ")", ")", "!=", "0", ")", "{", "CodeBook", "stagebook", "=", "look", ".", "fullbooks", "[", "look", ".", "partbooks", "[", "index", "]", "[", "s", "]", "]", ";", "if", "(", "stagebook", "!=", "null", ")", "{", "if", "(", "decodepart", "==", "0", ")", "{", "if", "(", "stagebook", ".", "decodevs_add", "(", "in", "[", "j", "]", ",", "offset", ",", "vb", ".", "opb", ",", "samples_per_partition", ")", "==", "-", "1", ")", "{", "return", "(", "0", ")", ";", "}", "}", "else", "if", "(", "decodepart", "==", "1", ")", "{", "if", "(", "stagebook", ".", "decodev_add", "(", "in", "[", "j", "]", ",", "offset", ",", "vb", ".", "opb", ",", "samples_per_partition", ")", "==", "-", "1", ")", "{", "return", "(", "0", ")", ";", "}", "}", "}", "}", "}", "}", "}", "return", "(", "0", ")", ";", "}" ]
re-using partword
[ "re", "-", "using", "partword" ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/ogg/jorbis/Residue0.java#L159-L227
150,136
PureSolTechnologies/graphs
trees/src/main/java/com/puresoltechnologies/graphs/trees/TreeIterator.java
TreeIterator.gotoEnd
public void gotoEnd() { currentNode = tree; while (currentNode.hasChildren()) { currentNode = currentNode.getChildren().get( currentNode.getChildren().size() - 1); } }
java
public void gotoEnd() { currentNode = tree; while (currentNode.hasChildren()) { currentNode = currentNode.getChildren().get( currentNode.getChildren().size() - 1); } }
[ "public", "void", "gotoEnd", "(", ")", "{", "currentNode", "=", "tree", ";", "while", "(", "currentNode", ".", "hasChildren", "(", ")", ")", "{", "currentNode", "=", "currentNode", ".", "getChildren", "(", ")", ".", "get", "(", "currentNode", ".", "getChildren", "(", ")", ".", "size", "(", ")", "-", "1", ")", ";", "}", "}" ]
This method sets the iterator onto the last tree element.
[ "This", "method", "sets", "the", "iterator", "onto", "the", "last", "tree", "element", "." ]
35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1
https://github.com/PureSolTechnologies/graphs/blob/35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1/trees/src/main/java/com/puresoltechnologies/graphs/trees/TreeIterator.java#L57-L63
150,137
PureSolTechnologies/graphs
trees/src/main/java/com/puresoltechnologies/graphs/trees/TreeIterator.java
TreeIterator.goForward
public boolean goForward() { if (currentNode.hasChildren()) { currentNode = currentNode.getChildren().get(0); return true; } else if (currentNode.getParent() == null) { return false; } while (true) { N parent = currentNode.getParent(); if ((parent == null) || (currentNode == tree)) { return false; } int index = parent.getChildren().indexOf(currentNode); if (parent.getChildren().size() > index + 1) { currentNode = parent.getChildren().get(index + 1); return true; } else { currentNode = parent; } } }
java
public boolean goForward() { if (currentNode.hasChildren()) { currentNode = currentNode.getChildren().get(0); return true; } else if (currentNode.getParent() == null) { return false; } while (true) { N parent = currentNode.getParent(); if ((parent == null) || (currentNode == tree)) { return false; } int index = parent.getChildren().indexOf(currentNode); if (parent.getChildren().size() > index + 1) { currentNode = parent.getChildren().get(index + 1); return true; } else { currentNode = parent; } } }
[ "public", "boolean", "goForward", "(", ")", "{", "if", "(", "currentNode", ".", "hasChildren", "(", ")", ")", "{", "currentNode", "=", "currentNode", ".", "getChildren", "(", ")", ".", "get", "(", "0", ")", ";", "return", "true", ";", "}", "else", "if", "(", "currentNode", ".", "getParent", "(", ")", "==", "null", ")", "{", "return", "false", ";", "}", "while", "(", "true", ")", "{", "N", "parent", "=", "currentNode", ".", "getParent", "(", ")", ";", "if", "(", "(", "parent", "==", "null", ")", "||", "(", "currentNode", "==", "tree", ")", ")", "{", "return", "false", ";", "}", "int", "index", "=", "parent", ".", "getChildren", "(", ")", ".", "indexOf", "(", "currentNode", ")", ";", "if", "(", "parent", ".", "getChildren", "(", ")", ".", "size", "(", ")", ">", "index", "+", "1", ")", "{", "currentNode", "=", "parent", ".", "getChildren", "(", ")", ".", "get", "(", "index", "+", "1", ")", ";", "return", "true", ";", "}", "else", "{", "currentNode", "=", "parent", ";", "}", "}", "}" ]
This method walks forward one node. @return <code>true</code> is returned if this was successful. <code>false</code> is returned otherwise, when the current node is the last node reachable.
[ "This", "method", "walks", "forward", "one", "node", "." ]
35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1
https://github.com/PureSolTechnologies/graphs/blob/35dbbd11ccaacbbc6321dcdcd4d31e9a1090d6f1/trees/src/main/java/com/puresoltechnologies/graphs/trees/TreeIterator.java#L72-L92
150,138
jtrfp/javamod
src/main/java/de/quippy/javamod/multimedia/mod/loader/ModuleFactory.java
ModuleFactory.getFileExtensionMap
private static HashMap<String, Module> getFileExtensionMap() { if (fileExtensionMap==null) fileExtensionMap= new HashMap<String, Module>(); return fileExtensionMap; }
java
private static HashMap<String, Module> getFileExtensionMap() { if (fileExtensionMap==null) fileExtensionMap= new HashMap<String, Module>(); return fileExtensionMap; }
[ "private", "static", "HashMap", "<", "String", ",", "Module", ">", "getFileExtensionMap", "(", ")", "{", "if", "(", "fileExtensionMap", "==", "null", ")", "fileExtensionMap", "=", "new", "HashMap", "<", "String", ",", "Module", ">", "(", ")", ";", "return", "fileExtensionMap", ";", "}" ]
Lazy instantiation access method @since 04.01.2010 @return
[ "Lazy", "instantiation", "access", "method" ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/javamod/multimedia/mod/loader/ModuleFactory.java#L57-L63
150,139
jtrfp/javamod
src/main/java/de/quippy/javamod/multimedia/mod/loader/ModuleFactory.java
ModuleFactory.getModuleFromStreamByID
private static Module getModuleFromStreamByID(ModfileInputStream input) { Iterator<Module> iter = getModulesArray().iterator(); while (iter.hasNext()) { Module mod = iter.next(); try { if (mod.checkLoadingPossible(input)) return mod; } catch (IOException ex) { /* Ignoring */ } } return null; }
java
private static Module getModuleFromStreamByID(ModfileInputStream input) { Iterator<Module> iter = getModulesArray().iterator(); while (iter.hasNext()) { Module mod = iter.next(); try { if (mod.checkLoadingPossible(input)) return mod; } catch (IOException ex) { /* Ignoring */ } } return null; }
[ "private", "static", "Module", "getModuleFromStreamByID", "(", "ModfileInputStream", "input", ")", "{", "Iterator", "<", "Module", ">", "iter", "=", "getModulesArray", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "Module", "mod", "=", "iter", ".", "next", "(", ")", ";", "try", "{", "if", "(", "mod", ".", "checkLoadingPossible", "(", "input", ")", ")", "return", "mod", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "/* Ignoring */", "}", "}", "return", "null", ";", "}" ]
Finds the appropriate loader through the IDs @since 04.01.2010 @param input @return
[ "Finds", "the", "appropriate", "loader", "through", "the", "IDs" ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/javamod/multimedia/mod/loader/ModuleFactory.java#L105-L121
150,140
jtrfp/javamod
src/main/java/de/quippy/javamod/multimedia/mod/loader/ModuleFactory.java
ModuleFactory.getModuleFromStream
private static Module getModuleFromStream(ModfileInputStream input) { Iterator<Module> iter = getModulesArray().iterator(); while (iter.hasNext()) { Module mod = iter.next(); try { Module result = mod.loadModFile(input); input.seek(0); return result; // <-- here this loading was a success! } catch (Throwable ex) { /* Ignoring */ } } return null; }
java
private static Module getModuleFromStream(ModfileInputStream input) { Iterator<Module> iter = getModulesArray().iterator(); while (iter.hasNext()) { Module mod = iter.next(); try { Module result = mod.loadModFile(input); input.seek(0); return result; // <-- here this loading was a success! } catch (Throwable ex) { /* Ignoring */ } } return null; }
[ "private", "static", "Module", "getModuleFromStream", "(", "ModfileInputStream", "input", ")", "{", "Iterator", "<", "Module", ">", "iter", "=", "getModulesArray", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "Module", "mod", "=", "iter", ".", "next", "(", ")", ";", "try", "{", "Module", "result", "=", "mod", ".", "loadModFile", "(", "input", ")", ";", "input", ".", "seek", "(", "0", ")", ";", "return", "result", ";", "// <-- here this loading was a success!", "}", "catch", "(", "Throwable", "ex", ")", "{", "/* Ignoring */", "}", "}", "return", "null", ";", "}" ]
Finds the appropriate loader through simply loading it! @since 13.06.2010 @param input @return
[ "Finds", "the", "appropriate", "loader", "through", "simply", "loading", "it!" ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/javamod/multimedia/mod/loader/ModuleFactory.java#L128-L146
150,141
jtrfp/javamod
src/main/java/de/quippy/javamod/multimedia/mod/loader/ModuleFactory.java
ModuleFactory.getInstance
public static Module getInstance(URL url) throws IOException { ModfileInputStream inputStream = null; try { inputStream = new ModfileInputStream(url); Module mod = getModuleFromStreamByID(inputStream); // If the header gives no infos, it's obviously a Noise Tracker file // So let's try all loaders if (mod!=null) return mod.loadModFile(inputStream); else { mod = getModuleFromStream(inputStream); if (mod!=null) return mod; else throw new IOException("Unsupported MOD-Type: " + inputStream.getFileName()); } } catch (Exception ex) { Log.error("[ModuleFactory] Failed with loading " + url.toString(), ex); return null; } finally { if (inputStream!=null) try { inputStream.close(); } catch (IOException ex) { Log.error("IGNORED", ex); } } }
java
public static Module getInstance(URL url) throws IOException { ModfileInputStream inputStream = null; try { inputStream = new ModfileInputStream(url); Module mod = getModuleFromStreamByID(inputStream); // If the header gives no infos, it's obviously a Noise Tracker file // So let's try all loaders if (mod!=null) return mod.loadModFile(inputStream); else { mod = getModuleFromStream(inputStream); if (mod!=null) return mod; else throw new IOException("Unsupported MOD-Type: " + inputStream.getFileName()); } } catch (Exception ex) { Log.error("[ModuleFactory] Failed with loading " + url.toString(), ex); return null; } finally { if (inputStream!=null) try { inputStream.close(); } catch (IOException ex) { Log.error("IGNORED", ex); } } }
[ "public", "static", "Module", "getInstance", "(", "URL", "url", ")", "throws", "IOException", "{", "ModfileInputStream", "inputStream", "=", "null", ";", "try", "{", "inputStream", "=", "new", "ModfileInputStream", "(", "url", ")", ";", "Module", "mod", "=", "getModuleFromStreamByID", "(", "inputStream", ")", ";", "// If the header gives no infos, it's obviously a Noise Tracker file", "// So let's try all loaders", "if", "(", "mod", "!=", "null", ")", "return", "mod", ".", "loadModFile", "(", "inputStream", ")", ";", "else", "{", "mod", "=", "getModuleFromStream", "(", "inputStream", ")", ";", "if", "(", "mod", "!=", "null", ")", "return", "mod", ";", "else", "throw", "new", "IOException", "(", "\"Unsupported MOD-Type: \"", "+", "inputStream", ".", "getFileName", "(", ")", ")", ";", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "Log", ".", "error", "(", "\"[ModuleFactory] Failed with loading \"", "+", "url", ".", "toString", "(", ")", ",", "ex", ")", ";", "return", "null", ";", "}", "finally", "{", "if", "(", "inputStream", "!=", "null", ")", "try", "{", "inputStream", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "Log", ".", "error", "(", "\"IGNORED\"", ",", "ex", ")", ";", "}", "}", "}" ]
Uses the File-Extension to find a suitable loader. @param url URL-Instance of the path to the modfile @return null, if fails
[ "Uses", "the", "File", "-", "Extension", "to", "find", "a", "suitable", "loader", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/javamod/multimedia/mod/loader/ModuleFactory.java#L170-L199
150,142
vdmeer/skb-java-base
src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java
MessageMgr.loadChunks
public final static Map<String, Set<String>> loadChunks(){ return new HashMap<String, Set<String>>(){ private static final long serialVersionUID = 1L;{ put("max", new HashSet<String>(){ private static final long serialVersionUID = 1L;{ add("name"); add("number"); add("type"); }} ); } }; }
java
public final static Map<String, Set<String>> loadChunks(){ return new HashMap<String, Set<String>>(){ private static final long serialVersionUID = 1L;{ put("max", new HashSet<String>(){ private static final long serialVersionUID = 1L;{ add("name"); add("number"); add("type"); }} ); } }; }
[ "public", "final", "static", "Map", "<", "String", ",", "Set", "<", "String", ">", ">", "loadChunks", "(", ")", "{", "return", "new", "HashMap", "<", "String", ",", "Set", "<", "String", ">", ">", "(", ")", "{", "private", "static", "final", "long", "serialVersionUID", "=", "1L", ";", "{", "put", "(", "\"max\"", ",", "new", "HashSet", "<", "String", ">", "(", ")", "{", "private", "static", "final", "long", "serialVersionUID", "=", "1L", ";", "{", "add", "(", "\"name\"", ")", ";", "add", "(", "\"number\"", ")", ";", "add", "(", "\"type\"", ")", ";", "}", "}", ")", ";", "}", "}", ";", "}" ]
Returns a map set with all expected template names and their expected arguments. The map that maintains the expected templates and their arguments for the manager. Any STGroup handed over the the manager will be tested against this map. Templates or template arguments that are missing can be reported, and the report manager will not invoke in any report activity if the provided STGroup does not provide for all required chunks. The set templates and their arguments are: <ul> <li>max ::= name, number, type</li> </ul> @return template map
[ "Returns", "a", "map", "set", "with", "all", "expected", "template", "names", "and", "their", "expected", "arguments", "." ]
6d845bcc482aa9344d016e80c0c3455aeae13a13
https://github.com/vdmeer/skb-java-base/blob/6d845bcc482aa9344d016e80c0c3455aeae13a13/src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java#L66-L76
150,143
vdmeer/skb-java-base
src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java
MessageMgr.createInfoMessage
public static Message5WH createInfoMessage(String what, Object ... obj){ return new Message5WH_Builder().addWhat(FormattingTupleWrapper.create(what, obj)).setType(E_MessageType.INFO).build(); }
java
public static Message5WH createInfoMessage(String what, Object ... obj){ return new Message5WH_Builder().addWhat(FormattingTupleWrapper.create(what, obj)).setType(E_MessageType.INFO).build(); }
[ "public", "static", "Message5WH", "createInfoMessage", "(", "String", "what", ",", "Object", "...", "obj", ")", "{", "return", "new", "Message5WH_Builder", "(", ")", ".", "addWhat", "(", "FormattingTupleWrapper", ".", "create", "(", "what", ",", "obj", ")", ")", ".", "setType", "(", "E_MessageType", ".", "INFO", ")", ".", "build", "(", ")", ";", "}" ]
Creates a new information message. @param what the what part of the message (what has happened) @param obj objects to add to the message @return new information message
[ "Creates", "a", "new", "information", "message", "." ]
6d845bcc482aa9344d016e80c0c3455aeae13a13
https://github.com/vdmeer/skb-java-base/blob/6d845bcc482aa9344d016e80c0c3455aeae13a13/src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java#L102-L104
150,144
vdmeer/skb-java-base
src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java
MessageMgr.createWarningMessage
public static Message5WH createWarningMessage(String what, Object ... obj){ return new Message5WH_Builder().addWhat(FormattingTupleWrapper.create(what, obj)).setType(E_MessageType.WARNING).build(); }
java
public static Message5WH createWarningMessage(String what, Object ... obj){ return new Message5WH_Builder().addWhat(FormattingTupleWrapper.create(what, obj)).setType(E_MessageType.WARNING).build(); }
[ "public", "static", "Message5WH", "createWarningMessage", "(", "String", "what", ",", "Object", "...", "obj", ")", "{", "return", "new", "Message5WH_Builder", "(", ")", ".", "addWhat", "(", "FormattingTupleWrapper", ".", "create", "(", "what", ",", "obj", ")", ")", ".", "setType", "(", "E_MessageType", ".", "WARNING", ")", ".", "build", "(", ")", ";", "}" ]
Creates a new warning message. @param what the what part of the message (what has happened) @param obj objects to add to the message @return new information message
[ "Creates", "a", "new", "warning", "message", "." ]
6d845bcc482aa9344d016e80c0c3455aeae13a13
https://github.com/vdmeer/skb-java-base/blob/6d845bcc482aa9344d016e80c0c3455aeae13a13/src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java#L112-L114
150,145
vdmeer/skb-java-base
src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java
MessageMgr.createErrorMessage
public static Message5WH createErrorMessage(String what, Object ... obj){ return new Message5WH_Builder().addWhat(FormattingTupleWrapper.create(what, obj)).setType(E_MessageType.ERROR).build(); }
java
public static Message5WH createErrorMessage(String what, Object ... obj){ return new Message5WH_Builder().addWhat(FormattingTupleWrapper.create(what, obj)).setType(E_MessageType.ERROR).build(); }
[ "public", "static", "Message5WH", "createErrorMessage", "(", "String", "what", ",", "Object", "...", "obj", ")", "{", "return", "new", "Message5WH_Builder", "(", ")", ".", "addWhat", "(", "FormattingTupleWrapper", ".", "create", "(", "what", ",", "obj", ")", ")", ".", "setType", "(", "E_MessageType", ".", "ERROR", ")", ".", "build", "(", ")", ";", "}" ]
Creates a new error message. @param what the what part of the message (what has happened) @param obj objects to add to the message @return new information message
[ "Creates", "a", "new", "error", "message", "." ]
6d845bcc482aa9344d016e80c0c3455aeae13a13
https://github.com/vdmeer/skb-java-base/blob/6d845bcc482aa9344d016e80c0c3455aeae13a13/src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java#L122-L124
150,146
vdmeer/skb-java-base
src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java
MessageMgr.hasErrors
public boolean hasErrors(){ if(this.messageHandlers.containsKey(E_MessageType.ERROR)){ return (this.messageHandlers.get(E_MessageType.ERROR).getCount()==0)?false:true; } return false; }
java
public boolean hasErrors(){ if(this.messageHandlers.containsKey(E_MessageType.ERROR)){ return (this.messageHandlers.get(E_MessageType.ERROR).getCount()==0)?false:true; } return false; }
[ "public", "boolean", "hasErrors", "(", ")", "{", "if", "(", "this", ".", "messageHandlers", ".", "containsKey", "(", "E_MessageType", ".", "ERROR", ")", ")", "{", "return", "(", "this", ".", "messageHandlers", ".", "get", "(", "E_MessageType", ".", "ERROR", ")", ".", "getCount", "(", ")", "==", "0", ")", "?", "false", ":", "true", ";", "}", "return", "false", ";", "}" ]
Returns true if the manager has errors reported, false otherwise @return true if errors have been reported, false otherwise
[ "Returns", "true", "if", "the", "manager", "has", "errors", "reported", "false", "otherwise" ]
6d845bcc482aa9344d016e80c0c3455aeae13a13
https://github.com/vdmeer/skb-java-base/blob/6d845bcc482aa9344d016e80c0c3455aeae13a13/src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java#L175-L180
150,147
vdmeer/skb-java-base
src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java
MessageMgr.hasWarnings
public boolean hasWarnings(){ if(this.messageHandlers.containsKey(E_MessageType.WARNING)){ return (this.messageHandlers.get(E_MessageType.WARNING).getCount()==0)?false:true; } return false; }
java
public boolean hasWarnings(){ if(this.messageHandlers.containsKey(E_MessageType.WARNING)){ return (this.messageHandlers.get(E_MessageType.WARNING).getCount()==0)?false:true; } return false; }
[ "public", "boolean", "hasWarnings", "(", ")", "{", "if", "(", "this", ".", "messageHandlers", ".", "containsKey", "(", "E_MessageType", ".", "WARNING", ")", ")", "{", "return", "(", "this", ".", "messageHandlers", ".", "get", "(", "E_MessageType", ".", "WARNING", ")", ".", "getCount", "(", ")", "==", "0", ")", "?", "false", ":", "true", ";", "}", "return", "false", ";", "}" ]
Returns true if the manager has warnings reported, false otherwise @return true if warnings have been reported, false otherwise
[ "Returns", "true", "if", "the", "manager", "has", "warnings", "reported", "false", "otherwise" ]
6d845bcc482aa9344d016e80c0c3455aeae13a13
https://github.com/vdmeer/skb-java-base/blob/6d845bcc482aa9344d016e80c0c3455aeae13a13/src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java#L186-L191
150,148
vdmeer/skb-java-base
src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java
MessageMgr.hasInfos
public boolean hasInfos(){ if(this.messageHandlers.containsKey(E_MessageType.INFO)){ return (this.messageHandlers.get(E_MessageType.INFO).getCount()==0)?false:true; } return false; }
java
public boolean hasInfos(){ if(this.messageHandlers.containsKey(E_MessageType.INFO)){ return (this.messageHandlers.get(E_MessageType.INFO).getCount()==0)?false:true; } return false; }
[ "public", "boolean", "hasInfos", "(", ")", "{", "if", "(", "this", ".", "messageHandlers", ".", "containsKey", "(", "E_MessageType", ".", "INFO", ")", ")", "{", "return", "(", "this", ".", "messageHandlers", ".", "get", "(", "E_MessageType", ".", "INFO", ")", ".", "getCount", "(", ")", "==", "0", ")", "?", "false", ":", "true", ";", "}", "return", "false", ";", "}" ]
Returns true if the manager has infos reported, false otherwise @return true if infos have been reported, false otherwise
[ "Returns", "true", "if", "the", "manager", "has", "infos", "reported", "false", "otherwise" ]
6d845bcc482aa9344d016e80c0c3455aeae13a13
https://github.com/vdmeer/skb-java-base/blob/6d845bcc482aa9344d016e80c0c3455aeae13a13/src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java#L197-L202
150,149
vdmeer/skb-java-base
src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java
MessageMgr.getMessageCount
public int getMessageCount(E_MessageType type) { if(this.messageHandlers.containsKey(type)){ return this.messageHandlers.get(type).getCount(); } return -1; }
java
public int getMessageCount(E_MessageType type) { if(this.messageHandlers.containsKey(type)){ return this.messageHandlers.get(type).getCount(); } return -1; }
[ "public", "int", "getMessageCount", "(", "E_MessageType", "type", ")", "{", "if", "(", "this", ".", "messageHandlers", ".", "containsKey", "(", "type", ")", ")", "{", "return", "this", ".", "messageHandlers", ".", "get", "(", "type", ")", ".", "getCount", "(", ")", ";", "}", "return", "-", "1", ";", "}" ]
Returns the current count for the given message type since its last initialization or reset. @param type message type to report count for @return current count of messages, -1 if not in active list
[ "Returns", "the", "current", "count", "for", "the", "given", "message", "type", "since", "its", "last", "initialization", "or", "reset", "." ]
6d845bcc482aa9344d016e80c0c3455aeae13a13
https://github.com/vdmeer/skb-java-base/blob/6d845bcc482aa9344d016e80c0c3455aeae13a13/src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java#L209-L214
150,150
vdmeer/skb-java-base
src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java
MessageMgr.isEnabledFor
public boolean isEnabledFor(E_MessageType type) { if(!this.messageHandlers.containsKey(type)){ return false; } return this.messageHandlers.get(type).isEnabled(); }
java
public boolean isEnabledFor(E_MessageType type) { if(!this.messageHandlers.containsKey(type)){ return false; } return this.messageHandlers.get(type).isEnabled(); }
[ "public", "boolean", "isEnabledFor", "(", "E_MessageType", "type", ")", "{", "if", "(", "!", "this", ".", "messageHandlers", ".", "containsKey", "(", "type", ")", ")", "{", "return", "false", ";", "}", "return", "this", ".", "messageHandlers", ".", "get", "(", "type", ")", ".", "isEnabled", "(", ")", ";", "}" ]
Returns is the report level is enabled or not. @param type message type to check @return true if the message type is in the list of active message types of the manager and if the associated logger is enabled, false otherwise
[ "Returns", "is", "the", "report", "level", "is", "enabled", "or", "not", "." ]
6d845bcc482aa9344d016e80c0c3455aeae13a13
https://github.com/vdmeer/skb-java-base/blob/6d845bcc482aa9344d016e80c0c3455aeae13a13/src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java#L221-L226
150,151
vdmeer/skb-java-base
src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java
MessageMgr.clear
public MessageMgr clear() { for(MessageTypeHandler handler : this.messageHandlers.values()){ handler.clear(); } this.messages.clear(); return this; }
java
public MessageMgr clear() { for(MessageTypeHandler handler : this.messageHandlers.values()){ handler.clear(); } this.messages.clear(); return this; }
[ "public", "MessageMgr", "clear", "(", ")", "{", "for", "(", "MessageTypeHandler", "handler", ":", "this", ".", "messageHandlers", ".", "values", "(", ")", ")", "{", "handler", ".", "clear", "(", ")", ";", "}", "this", ".", "messages", ".", "clear", "(", ")", ";", "return", "this", ";", "}" ]
Resets the collected messages and all counters. @return returns self to allow for chained calls
[ "Resets", "the", "collected", "messages", "and", "all", "counters", "." ]
6d845bcc482aa9344d016e80c0c3455aeae13a13
https://github.com/vdmeer/skb-java-base/blob/6d845bcc482aa9344d016e80c0c3455aeae13a13/src/main/java/de/vandermeer/skb/base/managers/MessageMgr.java#L351-L357
150,152
jtrfp/javamod
src/main/java/de/quippy/jflac/FLACDecoder.java
FLACDecoder.decodeFrame
public ByteData decodeFrame(Frame frame, ByteData pcmData) { // required size of the byte buffer int byteSize = frame.header.blockSize * channels * ((streamInfo.getBitsPerSample() + 7) / 2); if (pcmData == null || pcmData.getData().length < byteSize ) { pcmData = new ByteData(byteSize); } else { pcmData.setLen(0); } if (streamInfo.getBitsPerSample() == 8) { for (int i = 0; i < frame.header.blockSize; i++) { for (int channel = 0; channel < channels; channel++) { pcmData.append((byte) (channelData[channel].getOutput()[i] + 0x80)); } } } else if (streamInfo.getBitsPerSample() == 16) { for (int i = 0; i < frame.header.blockSize; i++) { for (int channel = 0; channel < channels; channel++) { short val = (short) (channelData[channel].getOutput()[i]); pcmData.append((byte) (val & 0xff)); pcmData.append((byte) ((val >> 8) & 0xff)); } } } else if (streamInfo.getBitsPerSample() == 24) { for (int i = 0; i < frame.header.blockSize; i++) { for (int channel = 0; channel < channels; channel++) { int val = (channelData[channel].getOutput()[i]); pcmData.append((byte) (val & 0xff)); pcmData.append((byte) ((val >> 8) & 0xff)); pcmData.append((byte) ((val >> 16) & 0xff)); } } } return pcmData; }
java
public ByteData decodeFrame(Frame frame, ByteData pcmData) { // required size of the byte buffer int byteSize = frame.header.blockSize * channels * ((streamInfo.getBitsPerSample() + 7) / 2); if (pcmData == null || pcmData.getData().length < byteSize ) { pcmData = new ByteData(byteSize); } else { pcmData.setLen(0); } if (streamInfo.getBitsPerSample() == 8) { for (int i = 0; i < frame.header.blockSize; i++) { for (int channel = 0; channel < channels; channel++) { pcmData.append((byte) (channelData[channel].getOutput()[i] + 0x80)); } } } else if (streamInfo.getBitsPerSample() == 16) { for (int i = 0; i < frame.header.blockSize; i++) { for (int channel = 0; channel < channels; channel++) { short val = (short) (channelData[channel].getOutput()[i]); pcmData.append((byte) (val & 0xff)); pcmData.append((byte) ((val >> 8) & 0xff)); } } } else if (streamInfo.getBitsPerSample() == 24) { for (int i = 0; i < frame.header.blockSize; i++) { for (int channel = 0; channel < channels; channel++) { int val = (channelData[channel].getOutput()[i]); pcmData.append((byte) (val & 0xff)); pcmData.append((byte) ((val >> 8) & 0xff)); pcmData.append((byte) ((val >> 16) & 0xff)); } } } return pcmData; }
[ "public", "ByteData", "decodeFrame", "(", "Frame", "frame", ",", "ByteData", "pcmData", ")", "{", "// required size of the byte buffer", "int", "byteSize", "=", "frame", ".", "header", ".", "blockSize", "*", "channels", "*", "(", "(", "streamInfo", ".", "getBitsPerSample", "(", ")", "+", "7", ")", "/", "2", ")", ";", "if", "(", "pcmData", "==", "null", "||", "pcmData", ".", "getData", "(", ")", ".", "length", "<", "byteSize", ")", "{", "pcmData", "=", "new", "ByteData", "(", "byteSize", ")", ";", "}", "else", "{", "pcmData", ".", "setLen", "(", "0", ")", ";", "}", "if", "(", "streamInfo", ".", "getBitsPerSample", "(", ")", "==", "8", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "frame", ".", "header", ".", "blockSize", ";", "i", "++", ")", "{", "for", "(", "int", "channel", "=", "0", ";", "channel", "<", "channels", ";", "channel", "++", ")", "{", "pcmData", ".", "append", "(", "(", "byte", ")", "(", "channelData", "[", "channel", "]", ".", "getOutput", "(", ")", "[", "i", "]", "+", "0x80", ")", ")", ";", "}", "}", "}", "else", "if", "(", "streamInfo", ".", "getBitsPerSample", "(", ")", "==", "16", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "frame", ".", "header", ".", "blockSize", ";", "i", "++", ")", "{", "for", "(", "int", "channel", "=", "0", ";", "channel", "<", "channels", ";", "channel", "++", ")", "{", "short", "val", "=", "(", "short", ")", "(", "channelData", "[", "channel", "]", ".", "getOutput", "(", ")", "[", "i", "]", ")", ";", "pcmData", ".", "append", "(", "(", "byte", ")", "(", "val", "&", "0xff", ")", ")", ";", "pcmData", ".", "append", "(", "(", "byte", ")", "(", "(", "val", ">>", "8", ")", "&", "0xff", ")", ")", ";", "}", "}", "}", "else", "if", "(", "streamInfo", ".", "getBitsPerSample", "(", ")", "==", "24", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "frame", ".", "header", ".", "blockSize", ";", "i", "++", ")", "{", "for", "(", "int", "channel", "=", "0", ";", "channel", "<", "channels", ";", "channel", "++", ")", "{", "int", "val", "=", "(", "channelData", "[", "channel", "]", ".", "getOutput", "(", ")", "[", "i", "]", ")", ";", "pcmData", ".", "append", "(", "(", "byte", ")", "(", "val", "&", "0xff", ")", ")", ";", "pcmData", ".", "append", "(", "(", "byte", ")", "(", "(", "val", ">>", "8", ")", "&", "0xff", ")", ")", ";", "pcmData", ".", "append", "(", "(", "byte", ")", "(", "(", "val", ">>", "16", ")", "&", "0xff", ")", ")", ";", "}", "}", "}", "return", "pcmData", ";", "}" ]
Fill the given ByteData object with PCM data from the frame. @param frame the frame to send to the PCM processors @param pcmData the byte data to be filled, or null if it should be allocated @return the ByteData that was filled (may be a new instance from <code>space</code>)
[ "Fill", "the", "given", "ByteData", "object", "with", "PCM", "data", "from", "the", "frame", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/jflac/FLACDecoder.java#L260-L293
150,153
jtrfp/javamod
src/main/java/de/quippy/jflac/FLACDecoder.java
FLACDecoder.readStreamInfo
public StreamInfo readStreamInfo() throws IOException { readStreamSync(); Metadata metadata = readNextMetadata(); if (!(metadata instanceof StreamInfo)) throw new IOException("StreamInfo metadata block missing"); return (StreamInfo) metadata; }
java
public StreamInfo readStreamInfo() throws IOException { readStreamSync(); Metadata metadata = readNextMetadata(); if (!(metadata instanceof StreamInfo)) throw new IOException("StreamInfo metadata block missing"); return (StreamInfo) metadata; }
[ "public", "StreamInfo", "readStreamInfo", "(", ")", "throws", "IOException", "{", "readStreamSync", "(", ")", ";", "Metadata", "metadata", "=", "readNextMetadata", "(", ")", ";", "if", "(", "!", "(", "metadata", "instanceof", "StreamInfo", ")", ")", "throw", "new", "IOException", "(", "\"StreamInfo metadata block missing\"", ")", ";", "return", "(", "StreamInfo", ")", "metadata", ";", "}" ]
Read the FLAC stream info. @return The FLAC Stream Info record @throws IOException On read error
[ "Read", "the", "FLAC", "stream", "info", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/jflac/FLACDecoder.java#L300-L305
150,154
jtrfp/javamod
src/main/java/de/quippy/jflac/FLACDecoder.java
FLACDecoder.decode
public void decode() throws IOException { readMetadata(); try { while (true) { //switch (state) { //case DECODER_SEARCH_FOR_METADATA : // readStreamSync(); // break; //case DECODER_READ_METADATA : // Metadata metadata = readNextMetadata(); // if (metadata == null) break; // break; //case DECODER_SEARCH_FOR_FRAME_SYNC : findFrameSync(); // break; //case DECODER_READ_FRAME : try { readFrame(); frameListeners.processFrame(frame); callPCMProcessors(frame); } catch (FrameDecodeException e) { badFrames++; } // break; //case DECODER_END_OF_STREAM : //case DECODER_ABORTED : // return; //default : // throw new IOException("Unknown state: " + state); //} } } catch (EOFException e) { eof = true; } }
java
public void decode() throws IOException { readMetadata(); try { while (true) { //switch (state) { //case DECODER_SEARCH_FOR_METADATA : // readStreamSync(); // break; //case DECODER_READ_METADATA : // Metadata metadata = readNextMetadata(); // if (metadata == null) break; // break; //case DECODER_SEARCH_FOR_FRAME_SYNC : findFrameSync(); // break; //case DECODER_READ_FRAME : try { readFrame(); frameListeners.processFrame(frame); callPCMProcessors(frame); } catch (FrameDecodeException e) { badFrames++; } // break; //case DECODER_END_OF_STREAM : //case DECODER_ABORTED : // return; //default : // throw new IOException("Unknown state: " + state); //} } } catch (EOFException e) { eof = true; } }
[ "public", "void", "decode", "(", ")", "throws", "IOException", "{", "readMetadata", "(", ")", ";", "try", "{", "while", "(", "true", ")", "{", "//switch (state) {", "//case DECODER_SEARCH_FOR_METADATA :", "// readStreamSync();", "// break;", "//case DECODER_READ_METADATA :", "// Metadata metadata = readNextMetadata();", "// if (metadata == null) break;", "// break;", "//case DECODER_SEARCH_FOR_FRAME_SYNC :", "findFrameSync", "(", ")", ";", "// break;", "//case DECODER_READ_FRAME :", "try", "{", "readFrame", "(", ")", ";", "frameListeners", ".", "processFrame", "(", "frame", ")", ";", "callPCMProcessors", "(", "frame", ")", ";", "}", "catch", "(", "FrameDecodeException", "e", ")", "{", "badFrames", "++", ";", "}", "// break;", "//case DECODER_END_OF_STREAM :", "//case DECODER_ABORTED :", "// return;", "//default :", "// throw new IOException(\"Unknown state: \" + state);", "//}", "}", "}", "catch", "(", "EOFException", "e", ")", "{", "eof", "=", "true", ";", "}", "}" ]
Decode the FLAC file. @throws IOException On read error
[ "Decode", "the", "FLAC", "file", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/jflac/FLACDecoder.java#L405-L439
150,155
jtrfp/javamod
src/main/java/de/quippy/jflac/FLACDecoder.java
FLACDecoder.decode
public void decode(SeekPoint from, SeekPoint to) throws IOException { // position random access file if (!(inputStream instanceof RandomFileInputStream)) throw new IOException("Not a RandomFileInputStream: " + inputStream.getClass().getName()); ((RandomFileInputStream)inputStream).seek(from.getStreamOffset()); bitStream.reset(); samplesDecoded = from.getSampleNumber(); //state = DECODER_SEARCH_FOR_FRAME_SYNC; try { while (true) { //switch (state) { //case DECODER_SEARCH_FOR_METADATA : // readStreamSync(); // break; //case DECODER_READ_METADATA : // Metadata metadata = readNextMetadata(); // if (metadata == null) break; // break; //case DECODER_SEARCH_FOR_FRAME_SYNC : findFrameSync(); // break; //case DECODER_READ_FRAME : try { readFrame(); frameListeners.processFrame(frame); callPCMProcessors(frame); } catch (FrameDecodeException e) { badFrames++; } //frameListeners.processFrame(frame); //callPCMProcessors(frame); //System.out.println(samplesDecoded +" "+ to.getSampleNumber()); if (to != null && samplesDecoded >= to.getSampleNumber()) return; // break; //case DECODER_END_OF_STREAM : //case DECODER_ABORTED : // return; //default : // throw new IOException("Unknown state: " + state); //} } } catch (EOFException e) { eof = true; } }
java
public void decode(SeekPoint from, SeekPoint to) throws IOException { // position random access file if (!(inputStream instanceof RandomFileInputStream)) throw new IOException("Not a RandomFileInputStream: " + inputStream.getClass().getName()); ((RandomFileInputStream)inputStream).seek(from.getStreamOffset()); bitStream.reset(); samplesDecoded = from.getSampleNumber(); //state = DECODER_SEARCH_FOR_FRAME_SYNC; try { while (true) { //switch (state) { //case DECODER_SEARCH_FOR_METADATA : // readStreamSync(); // break; //case DECODER_READ_METADATA : // Metadata metadata = readNextMetadata(); // if (metadata == null) break; // break; //case DECODER_SEARCH_FOR_FRAME_SYNC : findFrameSync(); // break; //case DECODER_READ_FRAME : try { readFrame(); frameListeners.processFrame(frame); callPCMProcessors(frame); } catch (FrameDecodeException e) { badFrames++; } //frameListeners.processFrame(frame); //callPCMProcessors(frame); //System.out.println(samplesDecoded +" "+ to.getSampleNumber()); if (to != null && samplesDecoded >= to.getSampleNumber()) return; // break; //case DECODER_END_OF_STREAM : //case DECODER_ABORTED : // return; //default : // throw new IOException("Unknown state: " + state); //} } } catch (EOFException e) { eof = true; } }
[ "public", "void", "decode", "(", "SeekPoint", "from", ",", "SeekPoint", "to", ")", "throws", "IOException", "{", "// position random access file", "if", "(", "!", "(", "inputStream", "instanceof", "RandomFileInputStream", ")", ")", "throw", "new", "IOException", "(", "\"Not a RandomFileInputStream: \"", "+", "inputStream", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "(", "(", "RandomFileInputStream", ")", "inputStream", ")", ".", "seek", "(", "from", ".", "getStreamOffset", "(", ")", ")", ";", "bitStream", ".", "reset", "(", ")", ";", "samplesDecoded", "=", "from", ".", "getSampleNumber", "(", ")", ";", "//state = DECODER_SEARCH_FOR_FRAME_SYNC;", "try", "{", "while", "(", "true", ")", "{", "//switch (state) {", "//case DECODER_SEARCH_FOR_METADATA :", "// readStreamSync();", "// break;", "//case DECODER_READ_METADATA :", "// Metadata metadata = readNextMetadata();", "// if (metadata == null) break;", "// break;", "//case DECODER_SEARCH_FOR_FRAME_SYNC :", "findFrameSync", "(", ")", ";", "// break;", "//case DECODER_READ_FRAME :", "try", "{", "readFrame", "(", ")", ";", "frameListeners", ".", "processFrame", "(", "frame", ")", ";", "callPCMProcessors", "(", "frame", ")", ";", "}", "catch", "(", "FrameDecodeException", "e", ")", "{", "badFrames", "++", ";", "}", "//frameListeners.processFrame(frame);", "//callPCMProcessors(frame);", "//System.out.println(samplesDecoded +\" \"+ to.getSampleNumber());", "if", "(", "to", "!=", "null", "&&", "samplesDecoded", ">=", "to", ".", "getSampleNumber", "(", ")", ")", "return", ";", "// break;", "//case DECODER_END_OF_STREAM :", "//case DECODER_ABORTED :", "// return;", "//default :", "// throw new IOException(\"Unknown state: \" + state);", "//}", "}", "}", "catch", "(", "EOFException", "e", ")", "{", "eof", "=", "true", ";", "}", "}" ]
Decode the data frames between two seek points. @param from The starting seek point @param to The ending seek point (non-inclusive) @throws IOException On read error
[ "Decode", "the", "data", "frames", "between", "two", "seek", "points", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/jflac/FLACDecoder.java#L487-L531
150,156
jtrfp/javamod
src/main/java/de/quippy/jflac/FLACDecoder.java
FLACDecoder.readStreamSync
private void readStreamSync() throws IOException { int id = 0; for (int i = 0; i < 4;) { int x = bitStream.readRawUInt(8); if (x == Constants.STREAM_SYNC_STRING[i]) { i++; id = 0; } else if (x == ID3V2_TAG[id]) { id++; i = 0; if (id == 3) { skipID3v2Tag(); id = 0; } } else { throw new IOException("Could not find Stream Sync"); //i = 0; //id = 0; } } }
java
private void readStreamSync() throws IOException { int id = 0; for (int i = 0; i < 4;) { int x = bitStream.readRawUInt(8); if (x == Constants.STREAM_SYNC_STRING[i]) { i++; id = 0; } else if (x == ID3V2_TAG[id]) { id++; i = 0; if (id == 3) { skipID3v2Tag(); id = 0; } } else { throw new IOException("Could not find Stream Sync"); //i = 0; //id = 0; } } }
[ "private", "void", "readStreamSync", "(", ")", "throws", "IOException", "{", "int", "id", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "4", ";", ")", "{", "int", "x", "=", "bitStream", ".", "readRawUInt", "(", "8", ")", ";", "if", "(", "x", "==", "Constants", ".", "STREAM_SYNC_STRING", "[", "i", "]", ")", "{", "i", "++", ";", "id", "=", "0", ";", "}", "else", "if", "(", "x", "==", "ID3V2_TAG", "[", "id", "]", ")", "{", "id", "++", ";", "i", "=", "0", ";", "if", "(", "id", "==", "3", ")", "{", "skipID3v2Tag", "(", ")", ";", "id", "=", "0", ";", "}", "}", "else", "{", "throw", "new", "IOException", "(", "\"Could not find Stream Sync\"", ")", ";", "//i = 0;", "//id = 0;", "}", "}", "}" ]
Read the stream sync string. @throws IOException On read error
[ "Read", "the", "stream", "sync", "string", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/jflac/FLACDecoder.java#L646-L666
150,157
jtrfp/javamod
src/main/java/de/quippy/jflac/FLACDecoder.java
FLACDecoder.readNextMetadata
public Metadata readNextMetadata() throws IOException { Metadata metadata = null; boolean isLast = (bitStream.readRawUInt(Metadata.STREAM_METADATA_IS_LAST_LEN) != 0); int type = bitStream.readRawUInt(Metadata.STREAM_METADATA_TYPE_LEN); int length = bitStream.readRawUInt(Metadata.STREAM_METADATA_LENGTH_LEN); if (type == Metadata.METADATA_TYPE_STREAMINFO) { metadata = streamInfo = new StreamInfo(bitStream, length, isLast); pcmProcessors.processStreamInfo((StreamInfo)metadata); } else if (type == Metadata.METADATA_TYPE_SEEKTABLE) { metadata = seekTable = new SeekTable(bitStream, length, isLast); } else if (type == Metadata.METADATA_TYPE_APPLICATION) { metadata = new Application(bitStream, length, isLast); } else if (type == Metadata.METADATA_TYPE_PADDING) { metadata = new Padding(bitStream, length, isLast); } else if (type == Metadata.METADATA_TYPE_VORBIS_COMMENT) { metadata = vorbisComment = new VorbisComment(bitStream, length, isLast); } else if (type == Metadata.METADATA_TYPE_CUESHEET) { metadata = new CueSheet(bitStream, length, isLast); } else if (type == Metadata.METADATA_TYPE_PICTURE) { metadata = new Picture(bitStream, length, isLast); } else { metadata = new Unknown(bitStream, length, isLast); } frameListeners.processMetadata(metadata); //if (isLast) state = DECODER_SEARCH_FOR_FRAME_SYNC; return metadata; }
java
public Metadata readNextMetadata() throws IOException { Metadata metadata = null; boolean isLast = (bitStream.readRawUInt(Metadata.STREAM_METADATA_IS_LAST_LEN) != 0); int type = bitStream.readRawUInt(Metadata.STREAM_METADATA_TYPE_LEN); int length = bitStream.readRawUInt(Metadata.STREAM_METADATA_LENGTH_LEN); if (type == Metadata.METADATA_TYPE_STREAMINFO) { metadata = streamInfo = new StreamInfo(bitStream, length, isLast); pcmProcessors.processStreamInfo((StreamInfo)metadata); } else if (type == Metadata.METADATA_TYPE_SEEKTABLE) { metadata = seekTable = new SeekTable(bitStream, length, isLast); } else if (type == Metadata.METADATA_TYPE_APPLICATION) { metadata = new Application(bitStream, length, isLast); } else if (type == Metadata.METADATA_TYPE_PADDING) { metadata = new Padding(bitStream, length, isLast); } else if (type == Metadata.METADATA_TYPE_VORBIS_COMMENT) { metadata = vorbisComment = new VorbisComment(bitStream, length, isLast); } else if (type == Metadata.METADATA_TYPE_CUESHEET) { metadata = new CueSheet(bitStream, length, isLast); } else if (type == Metadata.METADATA_TYPE_PICTURE) { metadata = new Picture(bitStream, length, isLast); } else { metadata = new Unknown(bitStream, length, isLast); } frameListeners.processMetadata(metadata); //if (isLast) state = DECODER_SEARCH_FOR_FRAME_SYNC; return metadata; }
[ "public", "Metadata", "readNextMetadata", "(", ")", "throws", "IOException", "{", "Metadata", "metadata", "=", "null", ";", "boolean", "isLast", "=", "(", "bitStream", ".", "readRawUInt", "(", "Metadata", ".", "STREAM_METADATA_IS_LAST_LEN", ")", "!=", "0", ")", ";", "int", "type", "=", "bitStream", ".", "readRawUInt", "(", "Metadata", ".", "STREAM_METADATA_TYPE_LEN", ")", ";", "int", "length", "=", "bitStream", ".", "readRawUInt", "(", "Metadata", ".", "STREAM_METADATA_LENGTH_LEN", ")", ";", "if", "(", "type", "==", "Metadata", ".", "METADATA_TYPE_STREAMINFO", ")", "{", "metadata", "=", "streamInfo", "=", "new", "StreamInfo", "(", "bitStream", ",", "length", ",", "isLast", ")", ";", "pcmProcessors", ".", "processStreamInfo", "(", "(", "StreamInfo", ")", "metadata", ")", ";", "}", "else", "if", "(", "type", "==", "Metadata", ".", "METADATA_TYPE_SEEKTABLE", ")", "{", "metadata", "=", "seekTable", "=", "new", "SeekTable", "(", "bitStream", ",", "length", ",", "isLast", ")", ";", "}", "else", "if", "(", "type", "==", "Metadata", ".", "METADATA_TYPE_APPLICATION", ")", "{", "metadata", "=", "new", "Application", "(", "bitStream", ",", "length", ",", "isLast", ")", ";", "}", "else", "if", "(", "type", "==", "Metadata", ".", "METADATA_TYPE_PADDING", ")", "{", "metadata", "=", "new", "Padding", "(", "bitStream", ",", "length", ",", "isLast", ")", ";", "}", "else", "if", "(", "type", "==", "Metadata", ".", "METADATA_TYPE_VORBIS_COMMENT", ")", "{", "metadata", "=", "vorbisComment", "=", "new", "VorbisComment", "(", "bitStream", ",", "length", ",", "isLast", ")", ";", "}", "else", "if", "(", "type", "==", "Metadata", ".", "METADATA_TYPE_CUESHEET", ")", "{", "metadata", "=", "new", "CueSheet", "(", "bitStream", ",", "length", ",", "isLast", ")", ";", "}", "else", "if", "(", "type", "==", "Metadata", ".", "METADATA_TYPE_PICTURE", ")", "{", "metadata", "=", "new", "Picture", "(", "bitStream", ",", "length", ",", "isLast", ")", ";", "}", "else", "{", "metadata", "=", "new", "Unknown", "(", "bitStream", ",", "length", ",", "isLast", ")", ";", "}", "frameListeners", ".", "processMetadata", "(", "metadata", ")", ";", "//if (isLast) state = DECODER_SEARCH_FOR_FRAME_SYNC;", "return", "metadata", ";", "}" ]
Read a single metadata record. @return The next metadata record @throws IOException on read error
[ "Read", "a", "single", "metadata", "record", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/jflac/FLACDecoder.java#L673-L701
150,158
jtrfp/javamod
src/main/java/de/quippy/jflac/FLACDecoder.java
FLACDecoder.seekTo
public void seekTo(long seekToSamples) throws IOException { // Seek with SeekTable if any provided if (seekTable!=null) { for (int s=0; s < seekTable.numberOfPoints(); s++) { SeekPoint p = seekTable.getSeekPoint(s); samplesDecoded = p.getSampleNumber(); if (samplesDecoded >= seekToSamples) { if (s>0) p = seekTable.getSeekPoint(s-1); samplesDecoded = p.getSampleNumber(); bitStream.skip(p.getStreamOffset()); break; } } } while (samplesDecoded < seekToSamples) { try { findFrameSync(); readFrame(); if (frame!=null && frame.header!=null) { samplesDecoded = frame.header.sampleNumber; if (samplesDecoded + frame.header.blockSize >= seekToSamples) break; } } catch (Throwable ex) { // We will recieve DecoderExceptions if we did seek // I would expect that seeking will reach a sync point } } }
java
public void seekTo(long seekToSamples) throws IOException { // Seek with SeekTable if any provided if (seekTable!=null) { for (int s=0; s < seekTable.numberOfPoints(); s++) { SeekPoint p = seekTable.getSeekPoint(s); samplesDecoded = p.getSampleNumber(); if (samplesDecoded >= seekToSamples) { if (s>0) p = seekTable.getSeekPoint(s-1); samplesDecoded = p.getSampleNumber(); bitStream.skip(p.getStreamOffset()); break; } } } while (samplesDecoded < seekToSamples) { try { findFrameSync(); readFrame(); if (frame!=null && frame.header!=null) { samplesDecoded = frame.header.sampleNumber; if (samplesDecoded + frame.header.blockSize >= seekToSamples) break; } } catch (Throwable ex) { // We will recieve DecoderExceptions if we did seek // I would expect that seeking will reach a sync point } } }
[ "public", "void", "seekTo", "(", "long", "seekToSamples", ")", "throws", "IOException", "{", "// Seek with SeekTable if any provided", "if", "(", "seekTable", "!=", "null", ")", "{", "for", "(", "int", "s", "=", "0", ";", "s", "<", "seekTable", ".", "numberOfPoints", "(", ")", ";", "s", "++", ")", "{", "SeekPoint", "p", "=", "seekTable", ".", "getSeekPoint", "(", "s", ")", ";", "samplesDecoded", "=", "p", ".", "getSampleNumber", "(", ")", ";", "if", "(", "samplesDecoded", ">=", "seekToSamples", ")", "{", "if", "(", "s", ">", "0", ")", "p", "=", "seekTable", ".", "getSeekPoint", "(", "s", "-", "1", ")", ";", "samplesDecoded", "=", "p", ".", "getSampleNumber", "(", ")", ";", "bitStream", ".", "skip", "(", "p", ".", "getStreamOffset", "(", ")", ")", ";", "break", ";", "}", "}", "}", "while", "(", "samplesDecoded", "<", "seekToSamples", ")", "{", "try", "{", "findFrameSync", "(", ")", ";", "readFrame", "(", ")", ";", "if", "(", "frame", "!=", "null", "&&", "frame", ".", "header", "!=", "null", ")", "{", "samplesDecoded", "=", "frame", ".", "header", ".", "sampleNumber", ";", "if", "(", "samplesDecoded", "+", "frame", ".", "header", ".", "blockSize", ">=", "seekToSamples", ")", "break", ";", "}", "}", "catch", "(", "Throwable", "ex", ")", "{", "// We will recieve DecoderExceptions if we did seek", "// I would expect that seeking will reach a sync point", "}", "}", "}" ]
This will do a forward seek - backwards is not possible yet because we would need to reset the inputstream @since 18.02.2012 @param seekToSamples
[ "This", "will", "do", "a", "forward", "seek", "-", "backwards", "is", "not", "possible", "yet", "because", "we", "would", "need", "to", "reset", "the", "inputstream" ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/jflac/FLACDecoder.java#L947-L983
150,159
jtrfp/javamod
src/main/java/de/quippy/mp3/decoder/Equalizer.java
Equalizer.getBand
public float getBand(int band) { float eq = 0.0f; if ((band>=0) && (band<BANDS)) { eq = settings[band]; } return eq; }
java
public float getBand(int band) { float eq = 0.0f; if ((band>=0) && (band<BANDS)) { eq = settings[band]; } return eq; }
[ "public", "float", "getBand", "(", "int", "band", ")", "{", "float", "eq", "=", "0.0f", ";", "if", "(", "(", "band", ">=", "0", ")", "&&", "(", "band", "<", "BANDS", ")", ")", "{", "eq", "=", "settings", "[", "band", "]", ";", "}", "return", "eq", ";", "}" ]
Retrieves the eq setting for a given band.
[ "Retrieves", "the", "eq", "setting", "for", "a", "given", "band", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/mp3/decoder/Equalizer.java#L149-L159
150,160
jtrfp/javamod
src/main/java/de/quippy/mp3/decoder/Equalizer.java
Equalizer.getBandFactors
float[] getBandFactors() { float[] factors = new float[BANDS]; for (int i=0, maxCount=BANDS; i<maxCount; i++) { factors[i] = getBandFactor(settings[i]); } return factors; }
java
float[] getBandFactors() { float[] factors = new float[BANDS]; for (int i=0, maxCount=BANDS; i<maxCount; i++) { factors[i] = getBandFactor(settings[i]); } return factors; }
[ "float", "[", "]", "getBandFactors", "(", ")", "{", "float", "[", "]", "factors", "=", "new", "float", "[", "BANDS", "]", ";", "for", "(", "int", "i", "=", "0", ",", "maxCount", "=", "BANDS", ";", "i", "<", "maxCount", ";", "i", "++", ")", "{", "factors", "[", "i", "]", "=", "getBandFactor", "(", "settings", "[", "i", "]", ")", ";", "}", "return", "factors", ";", "}" ]
Retrieves an array of floats whose values represent a scaling factor that can be applied to linear samples in each band to provide the equalization represented by this instance. @return an array of factors that can be applied to the subbands.
[ "Retrieves", "an", "array", "of", "floats", "whose", "values", "represent", "a", "scaling", "factor", "that", "can", "be", "applied", "to", "linear", "samples", "in", "each", "band", "to", "provide", "the", "equalization", "represented", "by", "this", "instance", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/mp3/decoder/Equalizer.java#L182-L191
150,161
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/collections/TreeWithParent.java
TreeWithParent.add
public Node<T> add(T element) { Node<T> node = new Node<>(this, element); nodes.add(node); return node; }
java
public Node<T> add(T element) { Node<T> node = new Node<>(this, element); nodes.add(node); return node; }
[ "public", "Node", "<", "T", ">", "add", "(", "T", "element", ")", "{", "Node", "<", "T", ">", "node", "=", "new", "Node", "<>", "(", "this", ",", "element", ")", ";", "nodes", ".", "add", "(", "node", ")", ";", "return", "node", ";", "}" ]
Append a new node with the given element.
[ "Append", "a", "new", "node", "with", "the", "given", "element", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/collections/TreeWithParent.java#L43-L47
150,162
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/collections/TreeWithParent.java
TreeWithParent.remove
public boolean remove(T element) { for (Iterator<Node<T>> it = nodes.iterator(); it.hasNext(); ) if (ObjectUtil.equalsOrNull(it.next().element, element)) { it.remove(); return true; } return false; }
java
public boolean remove(T element) { for (Iterator<Node<T>> it = nodes.iterator(); it.hasNext(); ) if (ObjectUtil.equalsOrNull(it.next().element, element)) { it.remove(); return true; } return false; }
[ "public", "boolean", "remove", "(", "T", "element", ")", "{", "for", "(", "Iterator", "<", "Node", "<", "T", ">", ">", "it", "=", "nodes", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "if", "(", "ObjectUtil", ".", "equalsOrNull", "(", "it", ".", "next", "(", ")", ".", "element", ",", "element", ")", ")", "{", "it", ".", "remove", "(", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Remove the first occurrence of the given element. @return true if an element has been removed
[ "Remove", "the", "first", "occurrence", "of", "the", "given", "element", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/collections/TreeWithParent.java#L52-L59
150,163
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/collections/TreeWithParent.java
TreeWithParent.get
public Node<T> get(T element) { for (Node<T> node : nodes) if (node.element.equals(element)) return node; return null; }
java
public Node<T> get(T element) { for (Node<T> node : nodes) if (node.element.equals(element)) return node; return null; }
[ "public", "Node", "<", "T", ">", "get", "(", "T", "element", ")", "{", "for", "(", "Node", "<", "T", ">", "node", ":", "nodes", ")", "if", "(", "node", ".", "element", ".", "equals", "(", "element", ")", ")", "return", "node", ";", "return", "null", ";", "}" ]
Get the node containing the given element.
[ "Get", "the", "node", "containing", "the", "given", "element", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/collections/TreeWithParent.java#L74-L79
150,164
jpaoletti/java-presentation-manager
modules/jpm-struts1/src/main/java/jpaoletti/jpm/struts/tags/PMTags.java
PMTags.tooltip
public static String tooltip(Field field) { final String tooltip = field.getTooltip(); if (tooltip == null) { return ""; } return "<img class='tooltip' title='" + tooltip + "' alt='?' src='" + getContextPath() + "/templates/" + getTemplate() + "/img/tooltip.gif' />"; }
java
public static String tooltip(Field field) { final String tooltip = field.getTooltip(); if (tooltip == null) { return ""; } return "<img class='tooltip' title='" + tooltip + "' alt='?' src='" + getContextPath() + "/templates/" + getTemplate() + "/img/tooltip.gif' />"; }
[ "public", "static", "String", "tooltip", "(", "Field", "field", ")", "{", "final", "String", "tooltip", "=", "field", ".", "getTooltip", "(", ")", ";", "if", "(", "tooltip", "==", "null", ")", "{", "return", "\"\"", ";", "}", "return", "\"<img class='tooltip' title='\"", "+", "tooltip", "+", "\"' alt='?' src='\"", "+", "getContextPath", "(", ")", "+", "\"/templates/\"", "+", "getTemplate", "(", ")", "+", "\"/img/tooltip.gif' />\"", ";", "}" ]
This method show a tooltip if the key is defined @param key Key
[ "This", "method", "show", "a", "tooltip", "if", "the", "key", "is", "defined" ]
d5aab55638383695db244744b4bfe27c5200e04f
https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-struts1/src/main/java/jpaoletti/jpm/struts/tags/PMTags.java#L187-L195
150,165
jpaoletti/java-presentation-manager
modules/jpm-struts1/src/main/java/jpaoletti/jpm/struts/tags/PMTags.java
PMTags.print
protected void print(Object... objects) throws IOException { for (Object object : objects) { pageContext.getOut().print(object); } }
java
protected void print(Object... objects) throws IOException { for (Object object : objects) { pageContext.getOut().print(object); } }
[ "protected", "void", "print", "(", "Object", "...", "objects", ")", "throws", "IOException", "{", "for", "(", "Object", "object", ":", "objects", ")", "{", "pageContext", ".", "getOut", "(", ")", ".", "print", "(", "object", ")", ";", "}", "}" ]
Prints the objects in the jsp writer of the page context
[ "Prints", "the", "objects", "in", "the", "jsp", "writer", "of", "the", "page", "context" ]
d5aab55638383695db244744b4bfe27c5200e04f
https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-struts1/src/main/java/jpaoletti/jpm/struts/tags/PMTags.java#L228-L232
150,166
jpaoletti/java-presentation-manager
modules/jpm-struts1/src/main/java/jpaoletti/jpm/struts/tags/PMTags.java
PMTags.println
protected void println(Object... objects) throws IOException { for (Object object : objects) { pageContext.getOut().println(object); } }
java
protected void println(Object... objects) throws IOException { for (Object object : objects) { pageContext.getOut().println(object); } }
[ "protected", "void", "println", "(", "Object", "...", "objects", ")", "throws", "IOException", "{", "for", "(", "Object", "object", ":", "objects", ")", "{", "pageContext", ".", "getOut", "(", ")", ".", "println", "(", "object", ")", ";", "}", "}" ]
Prints the objects in the jsp writer of the page context with a new line
[ "Prints", "the", "objects", "in", "the", "jsp", "writer", "of", "the", "page", "context", "with", "a", "new", "line" ]
d5aab55638383695db244744b4bfe27c5200e04f
https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-struts1/src/main/java/jpaoletti/jpm/struts/tags/PMTags.java#L237-L241
150,167
vdmeer/skb-java-base
src/main/java/de/vandermeer/skb/base/strings/VersionString.java
VersionString.toMap
public Map<String, Integer> toMap(){ Map<String, Integer> ret = new HashMap<>(); ret.put("major", this.major); ret.put("minor", this.minor); ret.put("patch", this.patch); return ret; }
java
public Map<String, Integer> toMap(){ Map<String, Integer> ret = new HashMap<>(); ret.put("major", this.major); ret.put("minor", this.minor); ret.put("patch", this.patch); return ret; }
[ "public", "Map", "<", "String", ",", "Integer", ">", "toMap", "(", ")", "{", "Map", "<", "String", ",", "Integer", ">", "ret", "=", "new", "HashMap", "<>", "(", ")", ";", "ret", ".", "put", "(", "\"major\"", ",", "this", ".", "major", ")", ";", "ret", ".", "put", "(", "\"minor\"", ",", "this", ".", "minor", ")", ";", "ret", ".", "put", "(", "\"patch\"", ",", "this", ".", "patch", ")", ";", "return", "ret", ";", "}" ]
Returns the string as a map using the key "major" for the major part, the key "minor" for the minor part and the key "patch" for the patch part. @return map representation of the string
[ "Returns", "the", "string", "as", "a", "map", "using", "the", "key", "major", "for", "the", "major", "part", "the", "key", "minor", "for", "the", "minor", "part", "and", "the", "key", "patch", "for", "the", "patch", "part", "." ]
6d845bcc482aa9344d016e80c0c3455aeae13a13
https://github.com/vdmeer/skb-java-base/blob/6d845bcc482aa9344d016e80c0c3455aeae13a13/src/main/java/de/vandermeer/skb/base/strings/VersionString.java#L99-L105
150,168
hawkular/hawkular-bus
hawkular-bus-common/src/main/java/org/hawkular/bus/common/consumer/AbstractBasicMessageListener.java
AbstractBasicMessageListener.determineBasicMessageClass
@SuppressWarnings("unchecked") protected Class<T> determineBasicMessageClass() { // all of this is usually going to just return AbstractMessage.class - but in case there is a subclass hierarchy // that makes it more specific, this will help discover the message class. Class<?> thisClazz = this.getClass(); Type superClazz = thisClazz.getGenericSuperclass(); // we might be a internal generated class (like a MDB within a container) so walk up the hierarchy // to find our real paramaterized superclass while (superClazz instanceof Class) { superClazz = ((Class<?>) superClazz).getGenericSuperclass(); } ParameterizedType parameterizedType = (ParameterizedType) superClazz; Type actualTypeArgument = parameterizedType.getActualTypeArguments()[0]; Class<T> clazz; if (actualTypeArgument instanceof Class<?>) { clazz = (Class<T>) actualTypeArgument; } else { TypeVariable<?> typeVar = (TypeVariable<?>) actualTypeArgument; clazz = (Class<T>) typeVar.getBounds()[0]; } return clazz; }
java
@SuppressWarnings("unchecked") protected Class<T> determineBasicMessageClass() { // all of this is usually going to just return AbstractMessage.class - but in case there is a subclass hierarchy // that makes it more specific, this will help discover the message class. Class<?> thisClazz = this.getClass(); Type superClazz = thisClazz.getGenericSuperclass(); // we might be a internal generated class (like a MDB within a container) so walk up the hierarchy // to find our real paramaterized superclass while (superClazz instanceof Class) { superClazz = ((Class<?>) superClazz).getGenericSuperclass(); } ParameterizedType parameterizedType = (ParameterizedType) superClazz; Type actualTypeArgument = parameterizedType.getActualTypeArguments()[0]; Class<T> clazz; if (actualTypeArgument instanceof Class<?>) { clazz = (Class<T>) actualTypeArgument; } else { TypeVariable<?> typeVar = (TypeVariable<?>) actualTypeArgument; clazz = (Class<T>) typeVar.getBounds()[0]; } return clazz; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "Class", "<", "T", ">", "determineBasicMessageClass", "(", ")", "{", "// all of this is usually going to just return AbstractMessage.class - but in case there is a subclass hierarchy", "// that makes it more specific, this will help discover the message class.", "Class", "<", "?", ">", "thisClazz", "=", "this", ".", "getClass", "(", ")", ";", "Type", "superClazz", "=", "thisClazz", ".", "getGenericSuperclass", "(", ")", ";", "// we might be a internal generated class (like a MDB within a container) so walk up the hierarchy", "// to find our real paramaterized superclass", "while", "(", "superClazz", "instanceof", "Class", ")", "{", "superClazz", "=", "(", "(", "Class", "<", "?", ">", ")", "superClazz", ")", ".", "getGenericSuperclass", "(", ")", ";", "}", "ParameterizedType", "parameterizedType", "=", "(", "ParameterizedType", ")", "superClazz", ";", "Type", "actualTypeArgument", "=", "parameterizedType", ".", "getActualTypeArguments", "(", ")", "[", "0", "]", ";", "Class", "<", "T", ">", "clazz", ";", "if", "(", "actualTypeArgument", "instanceof", "Class", "<", "?", ">", ")", "{", "clazz", "=", "(", "Class", "<", "T", ">", ")", "actualTypeArgument", ";", "}", "else", "{", "TypeVariable", "<", "?", ">", "typeVar", "=", "(", "TypeVariable", "<", "?", ">", ")", "actualTypeArgument", ";", "clazz", "=", "(", "Class", "<", "T", ">", ")", "typeVar", ".", "getBounds", "(", ")", "[", "0", "]", ";", "}", "return", "clazz", ";", "}" ]
In order to decode the JSON, we need the class representation of the basic message type. This method uses reflection to try to get that type. Subclasses can override this if they want to provide the class representation themselves (e.g. in case the reflection cannot get it). Alternatively, subclasses can utilize the constructor {@link AbstractBasicMessageListener#AbstractBasicMessageListener(Class)} to tell this object what the class of T is. @return class of T
[ "In", "order", "to", "decode", "the", "JSON", "we", "need", "the", "class", "representation", "of", "the", "basic", "message", "type", ".", "This", "method", "uses", "reflection", "to", "try", "to", "get", "that", "type", "." ]
28d6b58bec81a50f8344d39f309b6971271ae627
https://github.com/hawkular/hawkular-bus/blob/28d6b58bec81a50f8344d39f309b6971271ae627/hawkular-bus-common/src/main/java/org/hawkular/bus/common/consumer/AbstractBasicMessageListener.java#L209-L231
150,169
diegossilveira/jcors
src/main/java/org/jcors/config/ConfigLoader.java
ConfigLoader.load
public static JCorsConfig load() { log.info("Initializing JCors..."); InputStream fileStream = findFileInClasspath(CONFIG_FILE_NAME); JCorsConfig config = new JCorsConfig(); if (fileStream != null) { config = loadFromFileStream(fileStream); Constraint.ensureNotNull(config, "It was not possible to get a valid configuration instance"); log.info(String.format("Configuration loaded from classpath file '%s'", CONFIG_FILE_NAME)); } else { log.info(String.format("No file '%s' found in classpath. Using default configurations.", CONFIG_FILE_NAME)); } log.info(config); return config; }
java
public static JCorsConfig load() { log.info("Initializing JCors..."); InputStream fileStream = findFileInClasspath(CONFIG_FILE_NAME); JCorsConfig config = new JCorsConfig(); if (fileStream != null) { config = loadFromFileStream(fileStream); Constraint.ensureNotNull(config, "It was not possible to get a valid configuration instance"); log.info(String.format("Configuration loaded from classpath file '%s'", CONFIG_FILE_NAME)); } else { log.info(String.format("No file '%s' found in classpath. Using default configurations.", CONFIG_FILE_NAME)); } log.info(config); return config; }
[ "public", "static", "JCorsConfig", "load", "(", ")", "{", "log", ".", "info", "(", "\"Initializing JCors...\"", ")", ";", "InputStream", "fileStream", "=", "findFileInClasspath", "(", "CONFIG_FILE_NAME", ")", ";", "JCorsConfig", "config", "=", "new", "JCorsConfig", "(", ")", ";", "if", "(", "fileStream", "!=", "null", ")", "{", "config", "=", "loadFromFileStream", "(", "fileStream", ")", ";", "Constraint", ".", "ensureNotNull", "(", "config", ",", "\"It was not possible to get a valid configuration instance\"", ")", ";", "log", ".", "info", "(", "String", ".", "format", "(", "\"Configuration loaded from classpath file '%s'\"", ",", "CONFIG_FILE_NAME", ")", ")", ";", "}", "else", "{", "log", ".", "info", "(", "String", ".", "format", "(", "\"No file '%s' found in classpath. Using default configurations.\"", ",", "CONFIG_FILE_NAME", ")", ")", ";", "}", "log", ".", "info", "(", "config", ")", ";", "return", "config", ";", "}" ]
Loads a configuration from jcors.xml in classpath. If this file is not found, uses a default configuration @return
[ "Loads", "a", "configuration", "from", "jcors", ".", "xml", "in", "classpath", ".", "If", "this", "file", "is", "not", "found", "uses", "a", "default", "configuration" ]
cd56a9e2055d629baa42f93b27dd5615ced9632f
https://github.com/diegossilveira/jcors/blob/cd56a9e2055d629baa42f93b27dd5615ced9632f/src/main/java/org/jcors/config/ConfigLoader.java#L33-L51
150,170
diegossilveira/jcors
src/main/java/org/jcors/config/ConfigLoader.java
ConfigLoader.findFileInClasspath
private static InputStream findFileInClasspath(String fileName) { InputStream is = null; try { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); is = classLoader.getResourceAsStream(fileName); return is; } catch (Exception ex) { log.error(String.format("Error while reading file '%s' from classpath", fileName), ex); return null; } }
java
private static InputStream findFileInClasspath(String fileName) { InputStream is = null; try { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); is = classLoader.getResourceAsStream(fileName); return is; } catch (Exception ex) { log.error(String.format("Error while reading file '%s' from classpath", fileName), ex); return null; } }
[ "private", "static", "InputStream", "findFileInClasspath", "(", "String", "fileName", ")", "{", "InputStream", "is", "=", "null", ";", "try", "{", "ClassLoader", "classLoader", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "is", "=", "classLoader", ".", "getResourceAsStream", "(", "fileName", ")", ";", "return", "is", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "error", "(", "String", ".", "format", "(", "\"Error while reading file '%s' from classpath\"", ",", "fileName", ")", ",", "ex", ")", ";", "return", "null", ";", "}", "}" ]
Finds a file by name in classpath @param fileName @return
[ "Finds", "a", "file", "by", "name", "in", "classpath" ]
cd56a9e2055d629baa42f93b27dd5615ced9632f
https://github.com/diegossilveira/jcors/blob/cd56a9e2055d629baa42f93b27dd5615ced9632f/src/main/java/org/jcors/config/ConfigLoader.java#L59-L75
150,171
diegossilveira/jcors
src/main/java/org/jcors/config/ConfigLoader.java
ConfigLoader.loadFromFileStream
private static JCorsConfig loadFromFileStream(InputStream fileStream) { try { JAXBContext context = JAXBContext.newInstance(ConfigBuilder.class); Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setSchema(loadXmlSchema()); ConfigBuilder configBuilder = (ConfigBuilder) unmarshaller.unmarshal(fileStream); Constraint.ensureNotNull(configBuilder, "It was not possible to get a valid configuration builder instance"); return configBuilder.buildConfig(); } catch (Exception e) { log.error("Failed loading configuration file", e); return null; } }
java
private static JCorsConfig loadFromFileStream(InputStream fileStream) { try { JAXBContext context = JAXBContext.newInstance(ConfigBuilder.class); Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setSchema(loadXmlSchema()); ConfigBuilder configBuilder = (ConfigBuilder) unmarshaller.unmarshal(fileStream); Constraint.ensureNotNull(configBuilder, "It was not possible to get a valid configuration builder instance"); return configBuilder.buildConfig(); } catch (Exception e) { log.error("Failed loading configuration file", e); return null; } }
[ "private", "static", "JCorsConfig", "loadFromFileStream", "(", "InputStream", "fileStream", ")", "{", "try", "{", "JAXBContext", "context", "=", "JAXBContext", ".", "newInstance", "(", "ConfigBuilder", ".", "class", ")", ";", "Unmarshaller", "unmarshaller", "=", "context", ".", "createUnmarshaller", "(", ")", ";", "unmarshaller", ".", "setSchema", "(", "loadXmlSchema", "(", ")", ")", ";", "ConfigBuilder", "configBuilder", "=", "(", "ConfigBuilder", ")", "unmarshaller", ".", "unmarshal", "(", "fileStream", ")", ";", "Constraint", ".", "ensureNotNull", "(", "configBuilder", ",", "\"It was not possible to get a valid configuration builder instance\"", ")", ";", "return", "configBuilder", ".", "buildConfig", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"Failed loading configuration file\"", ",", "e", ")", ";", "return", "null", ";", "}", "}" ]
Builds a configuration class based on XML file @param file @return
[ "Builds", "a", "configuration", "class", "based", "on", "XML", "file" ]
cd56a9e2055d629baa42f93b27dd5615ced9632f
https://github.com/diegossilveira/jcors/blob/cd56a9e2055d629baa42f93b27dd5615ced9632f/src/main/java/org/jcors/config/ConfigLoader.java#L83-L103
150,172
diegossilveira/jcors
src/main/java/org/jcors/config/ConfigLoader.java
ConfigLoader.loadXmlSchema
private static Schema loadXmlSchema() throws SAXException { InputStream schemaFileStream = findFileInClasspath(CONFIG_SCHEMA_FILE_NAME); Constraint.ensureNotNull(schemaFileStream, "JCors configuration schema not found"); SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); return schemaFactory.newSchema(new StreamSource(schemaFileStream)); }
java
private static Schema loadXmlSchema() throws SAXException { InputStream schemaFileStream = findFileInClasspath(CONFIG_SCHEMA_FILE_NAME); Constraint.ensureNotNull(schemaFileStream, "JCors configuration schema not found"); SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); return schemaFactory.newSchema(new StreamSource(schemaFileStream)); }
[ "private", "static", "Schema", "loadXmlSchema", "(", ")", "throws", "SAXException", "{", "InputStream", "schemaFileStream", "=", "findFileInClasspath", "(", "CONFIG_SCHEMA_FILE_NAME", ")", ";", "Constraint", ".", "ensureNotNull", "(", "schemaFileStream", ",", "\"JCors configuration schema not found\"", ")", ";", "SchemaFactory", "schemaFactory", "=", "SchemaFactory", ".", "newInstance", "(", "XMLConstants", ".", "W3C_XML_SCHEMA_NS_URI", ")", ";", "return", "schemaFactory", ".", "newSchema", "(", "new", "StreamSource", "(", "schemaFileStream", ")", ")", ";", "}" ]
Loads the XML validation schema from the classpath @return @throws SAXException
[ "Loads", "the", "XML", "validation", "schema", "from", "the", "classpath" ]
cd56a9e2055d629baa42f93b27dd5615ced9632f
https://github.com/diegossilveira/jcors/blob/cd56a9e2055d629baa42f93b27dd5615ced9632f/src/main/java/org/jcors/config/ConfigLoader.java#L111-L118
150,173
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/BanTransitiveDependencies.java
BanTransitiveDependencies.searchTree
private static boolean searchTree( DependencyNode node, int level, ArtifactMatcher excludes, StringBuilder message ) throws InvalidVersionSpecificationException { List<DependencyNode> children = node.getChildren(); /* * if the node is deeper than direct dependency and is empty, it is transitive. */ boolean hasTransitiveDependencies = level > 1; boolean excluded = false; /* * holds recursive message from children, will be appended to current message if this node has any transitive * descendants if message is null, don't generate recursive message. */ StringBuilder messageFromChildren = message == null ? null : new StringBuilder(); if ( excludes.match( node.getArtifact() ) ) { // is excluded, we don't care about descendants excluded = true; hasTransitiveDependencies = false; } else { for ( DependencyNode childNode : children ) { /* * if any of the children has transitive d. so does the parent */ hasTransitiveDependencies = ( searchTree( childNode, level + 1, excludes, messageFromChildren ) || hasTransitiveDependencies ); } } if ( ( excluded || hasTransitiveDependencies ) && message != null ) // then generate message { for ( int i = 0; i < level; i++ ) { message.append( " " ); } message.append( node.getArtifact() ); if ( excluded ) { message.append( " [excluded]\n" ); } if ( hasTransitiveDependencies ) { if ( level == 1 ) { message.append( " has transitive dependencies:" ); } message.append( "\n" ).append( messageFromChildren ); } } return hasTransitiveDependencies; }
java
private static boolean searchTree( DependencyNode node, int level, ArtifactMatcher excludes, StringBuilder message ) throws InvalidVersionSpecificationException { List<DependencyNode> children = node.getChildren(); /* * if the node is deeper than direct dependency and is empty, it is transitive. */ boolean hasTransitiveDependencies = level > 1; boolean excluded = false; /* * holds recursive message from children, will be appended to current message if this node has any transitive * descendants if message is null, don't generate recursive message. */ StringBuilder messageFromChildren = message == null ? null : new StringBuilder(); if ( excludes.match( node.getArtifact() ) ) { // is excluded, we don't care about descendants excluded = true; hasTransitiveDependencies = false; } else { for ( DependencyNode childNode : children ) { /* * if any of the children has transitive d. so does the parent */ hasTransitiveDependencies = ( searchTree( childNode, level + 1, excludes, messageFromChildren ) || hasTransitiveDependencies ); } } if ( ( excluded || hasTransitiveDependencies ) && message != null ) // then generate message { for ( int i = 0; i < level; i++ ) { message.append( " " ); } message.append( node.getArtifact() ); if ( excluded ) { message.append( " [excluded]\n" ); } if ( hasTransitiveDependencies ) { if ( level == 1 ) { message.append( " has transitive dependencies:" ); } message.append( "\n" ).append( messageFromChildren ); } } return hasTransitiveDependencies; }
[ "private", "static", "boolean", "searchTree", "(", "DependencyNode", "node", ",", "int", "level", ",", "ArtifactMatcher", "excludes", ",", "StringBuilder", "message", ")", "throws", "InvalidVersionSpecificationException", "{", "List", "<", "DependencyNode", ">", "children", "=", "node", ".", "getChildren", "(", ")", ";", "/*\n * if the node is deeper than direct dependency and is empty, it is transitive.\n */", "boolean", "hasTransitiveDependencies", "=", "level", ">", "1", ";", "boolean", "excluded", "=", "false", ";", "/*\n * holds recursive message from children, will be appended to current message if this node has any transitive\n * descendants if message is null, don't generate recursive message.\n */", "StringBuilder", "messageFromChildren", "=", "message", "==", "null", "?", "null", ":", "new", "StringBuilder", "(", ")", ";", "if", "(", "excludes", ".", "match", "(", "node", ".", "getArtifact", "(", ")", ")", ")", "{", "// is excluded, we don't care about descendants", "excluded", "=", "true", ";", "hasTransitiveDependencies", "=", "false", ";", "}", "else", "{", "for", "(", "DependencyNode", "childNode", ":", "children", ")", "{", "/*\n * if any of the children has transitive d. so does the parent\n */", "hasTransitiveDependencies", "=", "(", "searchTree", "(", "childNode", ",", "level", "+", "1", ",", "excludes", ",", "messageFromChildren", ")", "||", "hasTransitiveDependencies", ")", ";", "}", "}", "if", "(", "(", "excluded", "||", "hasTransitiveDependencies", ")", "&&", "message", "!=", "null", ")", "// then generate message", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "level", ";", "i", "++", ")", "{", "message", ".", "append", "(", "\" \"", ")", ";", "}", "message", ".", "append", "(", "node", ".", "getArtifact", "(", ")", ")", ";", "if", "(", "excluded", ")", "{", "message", ".", "append", "(", "\" [excluded]\\n\"", ")", ";", "}", "if", "(", "hasTransitiveDependencies", ")", "{", "if", "(", "level", "==", "1", ")", "{", "message", ".", "append", "(", "\" has transitive dependencies:\"", ")", ";", "}", "message", ".", "append", "(", "\"\\n\"", ")", ".", "append", "(", "messageFromChildren", ")", ";", "}", "}", "return", "hasTransitiveDependencies", ";", "}" ]
Searches dependency tree recursively for transitive dependencies that are not excluded, while generating nice info message along the way. @throws InvalidVersionSpecificationException
[ "Searches", "dependency", "tree", "recursively", "for", "transitive", "dependencies", "that", "are", "not", "excluded", "while", "generating", "nice", "info", "message", "along", "the", "way", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/BanTransitiveDependencies.java#L74-L137
150,174
jtrfp/javamod
src/main/java/de/quippy/javamod/multimedia/mp3/id3/NullsoftID3GenreTable.java
NullsoftID3GenreTable.getGenre
public static int getGenre(String str) { for (int i=0; i<GENRES.length; i++) if (GENRES[i].equalsIgnoreCase(str)) return i; return -1; }
java
public static int getGenre(String str) { for (int i=0; i<GENRES.length; i++) if (GENRES[i].equalsIgnoreCase(str)) return i; return -1; }
[ "public", "static", "int", "getGenre", "(", "String", "str", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "GENRES", ".", "length", ";", "i", "++", ")", "if", "(", "GENRES", "[", "i", "]", ".", "equalsIgnoreCase", "(", "str", ")", ")", "return", "i", ";", "return", "-", "1", ";", "}" ]
Tries to find the string provided in the table and returns the corresponding int code if successful. Returns -1 if the genres is not found in the table. @param str the genre to search for @return the integer code for the genre or -1 if the genre is not found
[ "Tries", "to", "find", "the", "string", "provided", "in", "the", "table", "and", "returns", "the", "corresponding", "int", "code", "if", "successful", ".", "Returns", "-", "1", "if", "the", "genres", "is", "not", "found", "in", "the", "table", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/javamod/multimedia/mp3/id3/NullsoftID3GenreTable.java#L68-L74
150,175
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/xml/dom/DOMUtil.java
DOMUtil.getChild
public static Element getChild(Element parent, String childName) { NodeList nodes = parent.getChildNodes(); for (int i = 0; i < nodes.getLength(); ++i) { Node node = nodes.item(i); if ((node instanceof Element) && node.getNodeName().equals(childName)) return (Element)node; } return null; }
java
public static Element getChild(Element parent, String childName) { NodeList nodes = parent.getChildNodes(); for (int i = 0; i < nodes.getLength(); ++i) { Node node = nodes.item(i); if ((node instanceof Element) && node.getNodeName().equals(childName)) return (Element)node; } return null; }
[ "public", "static", "Element", "getChild", "(", "Element", "parent", ",", "String", "childName", ")", "{", "NodeList", "nodes", "=", "parent", ".", "getChildNodes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nodes", ".", "getLength", "(", ")", ";", "++", "i", ")", "{", "Node", "node", "=", "nodes", ".", "item", "(", "i", ")", ";", "if", "(", "(", "node", "instanceof", "Element", ")", "&&", "node", ".", "getNodeName", "(", ")", ".", "equals", "(", "childName", ")", ")", "return", "(", "Element", ")", "node", ";", "}", "return", "null", ";", "}" ]
Return the first child of the given name, or null.
[ "Return", "the", "first", "child", "of", "the", "given", "name", "or", "null", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/xml/dom/DOMUtil.java#L17-L25
150,176
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/xml/dom/DOMUtil.java
DOMUtil.getChildren
public static List<Element> getChildren(Element parent, String childName) { ArrayList<Element> children = new ArrayList<Element>(); NodeList nodes = parent.getChildNodes(); for (int i = 0; i < nodes.getLength(); ++i) { Node node = nodes.item(i); if ((node instanceof Element) && node.getNodeName().equals(childName)) children.add((Element)node); } return children; }
java
public static List<Element> getChildren(Element parent, String childName) { ArrayList<Element> children = new ArrayList<Element>(); NodeList nodes = parent.getChildNodes(); for (int i = 0; i < nodes.getLength(); ++i) { Node node = nodes.item(i); if ((node instanceof Element) && node.getNodeName().equals(childName)) children.add((Element)node); } return children; }
[ "public", "static", "List", "<", "Element", ">", "getChildren", "(", "Element", "parent", ",", "String", "childName", ")", "{", "ArrayList", "<", "Element", ">", "children", "=", "new", "ArrayList", "<", "Element", ">", "(", ")", ";", "NodeList", "nodes", "=", "parent", ".", "getChildNodes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nodes", ".", "getLength", "(", ")", ";", "++", "i", ")", "{", "Node", "node", "=", "nodes", ".", "item", "(", "i", ")", ";", "if", "(", "(", "node", "instanceof", "Element", ")", "&&", "node", ".", "getNodeName", "(", ")", ".", "equals", "(", "childName", ")", ")", "children", ".", "add", "(", "(", "Element", ")", "node", ")", ";", "}", "return", "children", ";", "}" ]
Return the children with the given name.
[ "Return", "the", "children", "with", "the", "given", "name", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/xml/dom/DOMUtil.java#L28-L37
150,177
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/xml/dom/DOMUtil.java
DOMUtil.getInnerText
public static String getInnerText(Node node) { if (node instanceof Element) return ((Element)node).getTextContent(); if (node.getNodeType() == Node.TEXT_NODE) return node.getNodeValue(); if (node instanceof Text) return ((Text)node).getData(); return null; }
java
public static String getInnerText(Node node) { if (node instanceof Element) return ((Element)node).getTextContent(); if (node.getNodeType() == Node.TEXT_NODE) return node.getNodeValue(); if (node instanceof Text) return ((Text)node).getData(); return null; }
[ "public", "static", "String", "getInnerText", "(", "Node", "node", ")", "{", "if", "(", "node", "instanceof", "Element", ")", "return", "(", "(", "Element", ")", "node", ")", ".", "getTextContent", "(", ")", ";", "if", "(", "node", ".", "getNodeType", "(", ")", "==", "Node", ".", "TEXT_NODE", ")", "return", "node", ".", "getNodeValue", "(", ")", ";", "if", "(", "node", "instanceof", "Text", ")", "return", "(", "(", "Text", ")", "node", ")", ".", "getData", "(", ")", ";", "return", "null", ";", "}" ]
Return the inner text of a node.
[ "Return", "the", "inner", "text", "of", "a", "node", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/xml/dom/DOMUtil.java#L40-L49
150,178
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/xml/dom/DOMUtil.java
DOMUtil.getChildText
public static String getChildText(Element parent, String childName) { Element child = getChild(parent, childName); if (child == null) return null; return getInnerText(child); }
java
public static String getChildText(Element parent, String childName) { Element child = getChild(parent, childName); if (child == null) return null; return getInnerText(child); }
[ "public", "static", "String", "getChildText", "(", "Element", "parent", ",", "String", "childName", ")", "{", "Element", "child", "=", "getChild", "(", "parent", ",", "childName", ")", ";", "if", "(", "child", "==", "null", ")", "return", "null", ";", "return", "getInnerText", "(", "child", ")", ";", "}" ]
Return the inner text of the first child with the given name.
[ "Return", "the", "inner", "text", "of", "the", "first", "child", "with", "the", "given", "name", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/xml/dom/DOMUtil.java#L52-L56
150,179
jpaoletti/java-presentation-manager
modules/jpm-core/src/main/java/jpaoletti/jpm/core/message/MessageFactory.java
MessageFactory.warn
public static Message warn(Entity entity, String key, String... args) { return message(MessageType.WARN, entity, key, args); }
java
public static Message warn(Entity entity, String key, String... args) { return message(MessageType.WARN, entity, key, args); }
[ "public", "static", "Message", "warn", "(", "Entity", "entity", ",", "String", "key", ",", "String", "...", "args", ")", "{", "return", "message", "(", "MessageType", ".", "WARN", ",", "entity", ",", "key", ",", "args", ")", ";", "}" ]
Create an entity scoped warning message
[ "Create", "an", "entity", "scoped", "warning", "message" ]
d5aab55638383695db244744b4bfe27c5200e04f
https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-core/src/main/java/jpaoletti/jpm/core/message/MessageFactory.java#L47-L49
150,180
jpaoletti/java-presentation-manager
modules/jpm-core/src/main/java/jpaoletti/jpm/core/message/MessageFactory.java
MessageFactory.error
public static Message error(Entity entity, String key, String... args) { return message(MessageType.ERROR, entity, key, args); }
java
public static Message error(Entity entity, String key, String... args) { return message(MessageType.ERROR, entity, key, args); }
[ "public", "static", "Message", "error", "(", "Entity", "entity", ",", "String", "key", ",", "String", "...", "args", ")", "{", "return", "message", "(", "MessageType", ".", "ERROR", ",", "entity", ",", "key", ",", "args", ")", ";", "}" ]
Create an entity scoped error message
[ "Create", "an", "entity", "scoped", "error", "message" ]
d5aab55638383695db244744b4bfe27c5200e04f
https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-core/src/main/java/jpaoletti/jpm/core/message/MessageFactory.java#L54-L56
150,181
jpaoletti/java-presentation-manager
modules/jpm-core/src/main/java/jpaoletti/jpm/core/message/MessageFactory.java
MessageFactory.info
public static Message info(Entity entity, Field field, String key, String... args) { return message(MessageType.INFO, entity, field, key, args); }
java
public static Message info(Entity entity, Field field, String key, String... args) { return message(MessageType.INFO, entity, field, key, args); }
[ "public", "static", "Message", "info", "(", "Entity", "entity", ",", "Field", "field", ",", "String", "key", ",", "String", "...", "args", ")", "{", "return", "message", "(", "MessageType", ".", "INFO", ",", "entity", ",", "field", ",", "key", ",", "args", ")", ";", "}" ]
Create a field scoped information message
[ "Create", "a", "field", "scoped", "information", "message" ]
d5aab55638383695db244744b4bfe27c5200e04f
https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-core/src/main/java/jpaoletti/jpm/core/message/MessageFactory.java#L61-L63
150,182
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/application/LCCore.java
LCCore.initEnvironment
public static void initEnvironment() { // init logging system if not specified if (System.getProperty("org.apache.commons.logging.Log") == null) System.setProperty("org.apache.commons.logging.Log", "net.lecousin.framework.log.bridges.ApacheCommonsLogging"); // register protocols String protocols = System.getProperty("java.protocol.handler.pkgs"); if (protocols == null) protocols = ""; if (!protocols.contains("net.lecousin.framework.protocols")) { if (protocols.length() > 0) protocols += "|"; protocols += "net.lecousin.framework.protocols"; System.setProperty("java.protocol.handler.pkgs", protocols); } }
java
public static void initEnvironment() { // init logging system if not specified if (System.getProperty("org.apache.commons.logging.Log") == null) System.setProperty("org.apache.commons.logging.Log", "net.lecousin.framework.log.bridges.ApacheCommonsLogging"); // register protocols String protocols = System.getProperty("java.protocol.handler.pkgs"); if (protocols == null) protocols = ""; if (!protocols.contains("net.lecousin.framework.protocols")) { if (protocols.length() > 0) protocols += "|"; protocols += "net.lecousin.framework.protocols"; System.setProperty("java.protocol.handler.pkgs", protocols); } }
[ "public", "static", "void", "initEnvironment", "(", ")", "{", "// init logging system if not specified\r", "if", "(", "System", ".", "getProperty", "(", "\"org.apache.commons.logging.Log\"", ")", "==", "null", ")", "System", ".", "setProperty", "(", "\"org.apache.commons.logging.Log\"", ",", "\"net.lecousin.framework.log.bridges.ApacheCommonsLogging\"", ")", ";", "// register protocols\r", "String", "protocols", "=", "System", ".", "getProperty", "(", "\"java.protocol.handler.pkgs\"", ")", ";", "if", "(", "protocols", "==", "null", ")", "protocols", "=", "\"\"", ";", "if", "(", "!", "protocols", ".", "contains", "(", "\"net.lecousin.framework.protocols\"", ")", ")", "{", "if", "(", "protocols", ".", "length", "(", ")", ">", "0", ")", "protocols", "+=", "\"|\"", ";", "protocols", "+=", "\"net.lecousin.framework.protocols\"", ";", "System", ".", "setProperty", "(", "\"java.protocol.handler.pkgs\"", ",", "protocols", ")", ";", "}", "}" ]
Initialize properties.
[ "Initialize", "properties", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/application/LCCore.java#L81-L94
150,183
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/application/LCCore.java
LCCore.stop
public static MutableBoolean stop(boolean forceJvmToStop) { if (stop != null) { new Exception("LCCore already stopped", stop).printStackTrace(System.err); return new MutableBoolean(true); } stop = new Exception("LCCore stop requested here"); MutableBoolean stopped = new MutableBoolean(false); new Thread("Stopping LCCore") { @Override public void run() { synchronized (toDoInMainThread) { toDoInMainThread.notify(); } if (instance != null) instance.stop(); if (forceJvmToStop) { System.out.println("Stop JVM."); System.exit(0); } synchronized (stopped) { stopped.set(true); stopped.notifyAll(); } } }.start(); return stopped; }
java
public static MutableBoolean stop(boolean forceJvmToStop) { if (stop != null) { new Exception("LCCore already stopped", stop).printStackTrace(System.err); return new MutableBoolean(true); } stop = new Exception("LCCore stop requested here"); MutableBoolean stopped = new MutableBoolean(false); new Thread("Stopping LCCore") { @Override public void run() { synchronized (toDoInMainThread) { toDoInMainThread.notify(); } if (instance != null) instance.stop(); if (forceJvmToStop) { System.out.println("Stop JVM."); System.exit(0); } synchronized (stopped) { stopped.set(true); stopped.notifyAll(); } } }.start(); return stopped; }
[ "public", "static", "MutableBoolean", "stop", "(", "boolean", "forceJvmToStop", ")", "{", "if", "(", "stop", "!=", "null", ")", "{", "new", "Exception", "(", "\"LCCore already stopped\"", ",", "stop", ")", ".", "printStackTrace", "(", "System", ".", "err", ")", ";", "return", "new", "MutableBoolean", "(", "true", ")", ";", "}", "stop", "=", "new", "Exception", "(", "\"LCCore stop requested here\"", ")", ";", "MutableBoolean", "stopped", "=", "new", "MutableBoolean", "(", "false", ")", ";", "new", "Thread", "(", "\"Stopping LCCore\"", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "synchronized", "(", "toDoInMainThread", ")", "{", "toDoInMainThread", ".", "notify", "(", ")", ";", "}", "if", "(", "instance", "!=", "null", ")", "instance", ".", "stop", "(", ")", ";", "if", "(", "forceJvmToStop", ")", "{", "System", ".", "out", ".", "println", "(", "\"Stop JVM.\"", ")", ";", "System", ".", "exit", "(", "0", ")", ";", "}", "synchronized", "(", "stopped", ")", "{", "stopped", ".", "set", "(", "true", ")", ";", "stopped", ".", "notifyAll", "(", ")", ";", "}", "}", "}", ".", "start", "(", ")", ";", "return", "stopped", ";", "}" ]
Stop the environement.
[ "Stop", "the", "environement", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/application/LCCore.java#L137-L162
150,184
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/application/LCCore.java
LCCore.replaceMainThreadExecutor
public static void replaceMainThreadExecutor(MainThreadExecutor executor) { MainThreadExecutor previous; synchronized (LCCore.class) { previous = mainThreadExecutor; mainThreadExecutor = executor; } do { Runnable toExecute = previous.pop(); if (toExecute == null) break; executor.execute(toExecute); } while (true); }
java
public static void replaceMainThreadExecutor(MainThreadExecutor executor) { MainThreadExecutor previous; synchronized (LCCore.class) { previous = mainThreadExecutor; mainThreadExecutor = executor; } do { Runnable toExecute = previous.pop(); if (toExecute == null) break; executor.execute(toExecute); } while (true); }
[ "public", "static", "void", "replaceMainThreadExecutor", "(", "MainThreadExecutor", "executor", ")", "{", "MainThreadExecutor", "previous", ";", "synchronized", "(", "LCCore", ".", "class", ")", "{", "previous", "=", "mainThreadExecutor", ";", "mainThreadExecutor", "=", "executor", ";", "}", "do", "{", "Runnable", "toExecute", "=", "previous", ".", "pop", "(", ")", ";", "if", "(", "toExecute", "==", "null", ")", "break", ";", "executor", ".", "execute", "(", "toExecute", ")", ";", "}", "while", "(", "true", ")", ";", "}" ]
Replace the main thread executor.
[ "Replace", "the", "main", "thread", "executor", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/application/LCCore.java#L232-L243
150,185
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java
EnforcerRuleUtils.readModel
private Model readModel ( File pom ) throws IOException, XmlPullParserException { Reader reader = ReaderFactory.newXmlReader( pom ); MavenXpp3Reader xpp3 = new MavenXpp3Reader(); Model model = null; try { model = xpp3.read( reader ); } finally { reader.close(); reader = null; } return model; }
java
private Model readModel ( File pom ) throws IOException, XmlPullParserException { Reader reader = ReaderFactory.newXmlReader( pom ); MavenXpp3Reader xpp3 = new MavenXpp3Reader(); Model model = null; try { model = xpp3.read( reader ); } finally { reader.close(); reader = null; } return model; }
[ "private", "Model", "readModel", "(", "File", "pom", ")", "throws", "IOException", ",", "XmlPullParserException", "{", "Reader", "reader", "=", "ReaderFactory", ".", "newXmlReader", "(", "pom", ")", ";", "MavenXpp3Reader", "xpp3", "=", "new", "MavenXpp3Reader", "(", ")", ";", "Model", "model", "=", "null", ";", "try", "{", "model", "=", "xpp3", ".", "read", "(", "reader", ")", ";", "}", "finally", "{", "reader", ".", "close", "(", ")", ";", "reader", "=", "null", ";", "}", "return", "model", ";", "}" ]
Gets the pom model for this file. @param pom the pom @return the model @throws IOException Signals that an I/O exception has occurred. @throws XmlPullParserException the xml pull parser exception
[ "Gets", "the", "pom", "model", "for", "this", "file", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java#L141-L157
150,186
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java
EnforcerRuleUtils.getPomModel
private Model getPomModel ( String groupId, String artifactId, String version, File pom ) throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException { Model model = null; // do we want to look in the reactor like the // project builder? Would require @aggregator goal // which causes problems in maven core right now // because we also need dependency resolution in // other // rules. (MNG-2277) // look in the location specified by pom first. boolean found = false; try { model = readModel( pom ); // i found a model, lets make sure it's the one // I want found = checkIfModelMatches( groupId, artifactId, version, model ); } catch ( IOException e ) { // nothing here, but lets look in the repo // before giving up. } catch ( XmlPullParserException e ) { // nothing here, but lets look in the repo // before giving up. } // i didn't find it in the local file system, go // look in the repo if ( !found ) { Artifact pomArtifact = factory.createArtifact( groupId, artifactId, version, null, "pom" ); resolver.resolve( pomArtifact, remoteRepositories, local ); model = readModel( pomArtifact.getFile() ); } return model; }
java
private Model getPomModel ( String groupId, String artifactId, String version, File pom ) throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException { Model model = null; // do we want to look in the reactor like the // project builder? Would require @aggregator goal // which causes problems in maven core right now // because we also need dependency resolution in // other // rules. (MNG-2277) // look in the location specified by pom first. boolean found = false; try { model = readModel( pom ); // i found a model, lets make sure it's the one // I want found = checkIfModelMatches( groupId, artifactId, version, model ); } catch ( IOException e ) { // nothing here, but lets look in the repo // before giving up. } catch ( XmlPullParserException e ) { // nothing here, but lets look in the repo // before giving up. } // i didn't find it in the local file system, go // look in the repo if ( !found ) { Artifact pomArtifact = factory.createArtifact( groupId, artifactId, version, null, "pom" ); resolver.resolve( pomArtifact, remoteRepositories, local ); model = readModel( pomArtifact.getFile() ); } return model; }
[ "private", "Model", "getPomModel", "(", "String", "groupId", ",", "String", "artifactId", ",", "String", "version", ",", "File", "pom", ")", "throws", "ArtifactResolutionException", ",", "ArtifactNotFoundException", ",", "IOException", ",", "XmlPullParserException", "{", "Model", "model", "=", "null", ";", "// do we want to look in the reactor like the", "// project builder? Would require @aggregator goal", "// which causes problems in maven core right now", "// because we also need dependency resolution in", "// other", "// rules. (MNG-2277)", "// look in the location specified by pom first.", "boolean", "found", "=", "false", ";", "try", "{", "model", "=", "readModel", "(", "pom", ")", ";", "// i found a model, lets make sure it's the one", "// I want", "found", "=", "checkIfModelMatches", "(", "groupId", ",", "artifactId", ",", "version", ",", "model", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// nothing here, but lets look in the repo", "// before giving up.", "}", "catch", "(", "XmlPullParserException", "e", ")", "{", "// nothing here, but lets look in the repo", "// before giving up.", "}", "// i didn't find it in the local file system, go", "// look in the repo", "if", "(", "!", "found", ")", "{", "Artifact", "pomArtifact", "=", "factory", ".", "createArtifact", "(", "groupId", ",", "artifactId", ",", "version", ",", "null", ",", "\"pom\"", ")", ";", "resolver", ".", "resolve", "(", "pomArtifact", ",", "remoteRepositories", ",", "local", ")", ";", "model", "=", "readModel", "(", "pomArtifact", ".", "getFile", "(", ")", ")", ";", "}", "return", "model", ";", "}" ]
This method gets the model for the defined artifact. Looks first in the filesystem, then tries to get it from the repo. @param groupId the group id @param artifactId the artifact id @param version the version @param pom the pom @return the pom model @throws ArtifactResolutionException the artifact resolution exception @throws ArtifactNotFoundException the artifact not found exception @throws XmlPullParserException the xml pull parser exception @throws IOException Signals that an I/O exception has occurred.
[ "This", "method", "gets", "the", "model", "for", "the", "defined", "artifact", ".", "Looks", "first", "in", "the", "filesystem", "then", "tries", "to", "get", "it", "from", "the", "repo", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java#L176-L219
150,187
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java
EnforcerRuleUtils.getModelsRecursively
public List<Model> getModelsRecursively ( String groupId, String artifactId, String version, File pom ) throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException { List<Model> models = null; Model model = getPomModel( groupId, artifactId, version, pom ); Parent parent = model.getParent(); // recurse into the parent if ( parent != null ) { // get the relative path String relativePath = parent.getRelativePath(); if ( StringUtils.isEmpty( relativePath ) ) { relativePath = "../pom.xml"; } // calculate the recursive path File parentPom = new File( pom.getParent(), relativePath ); // if relative path is a directory, append pom.xml if ( parentPom.isDirectory() ) { parentPom = new File( parentPom, "pom.xml" ); } models = getModelsRecursively( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), parentPom ); } else { // only create it here since I'm not at the top models = new ArrayList<Model>(); } models.add( model ); return models; }
java
public List<Model> getModelsRecursively ( String groupId, String artifactId, String version, File pom ) throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException { List<Model> models = null; Model model = getPomModel( groupId, artifactId, version, pom ); Parent parent = model.getParent(); // recurse into the parent if ( parent != null ) { // get the relative path String relativePath = parent.getRelativePath(); if ( StringUtils.isEmpty( relativePath ) ) { relativePath = "../pom.xml"; } // calculate the recursive path File parentPom = new File( pom.getParent(), relativePath ); // if relative path is a directory, append pom.xml if ( parentPom.isDirectory() ) { parentPom = new File( parentPom, "pom.xml" ); } models = getModelsRecursively( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), parentPom ); } else { // only create it here since I'm not at the top models = new ArrayList<Model>(); } models.add( model ); return models; }
[ "public", "List", "<", "Model", ">", "getModelsRecursively", "(", "String", "groupId", ",", "String", "artifactId", ",", "String", "version", ",", "File", "pom", ")", "throws", "ArtifactResolutionException", ",", "ArtifactNotFoundException", ",", "IOException", ",", "XmlPullParserException", "{", "List", "<", "Model", ">", "models", "=", "null", ";", "Model", "model", "=", "getPomModel", "(", "groupId", ",", "artifactId", ",", "version", ",", "pom", ")", ";", "Parent", "parent", "=", "model", ".", "getParent", "(", ")", ";", "// recurse into the parent", "if", "(", "parent", "!=", "null", ")", "{", "// get the relative path", "String", "relativePath", "=", "parent", ".", "getRelativePath", "(", ")", ";", "if", "(", "StringUtils", ".", "isEmpty", "(", "relativePath", ")", ")", "{", "relativePath", "=", "\"../pom.xml\"", ";", "}", "// calculate the recursive path", "File", "parentPom", "=", "new", "File", "(", "pom", ".", "getParent", "(", ")", ",", "relativePath", ")", ";", "// if relative path is a directory, append pom.xml", "if", "(", "parentPom", ".", "isDirectory", "(", ")", ")", "{", "parentPom", "=", "new", "File", "(", "parentPom", ",", "\"pom.xml\"", ")", ";", "}", "models", "=", "getModelsRecursively", "(", "parent", ".", "getGroupId", "(", ")", ",", "parent", ".", "getArtifactId", "(", ")", ",", "parent", ".", "getVersion", "(", ")", ",", "parentPom", ")", ";", "}", "else", "{", "// only create it here since I'm not at the top", "models", "=", "new", "ArrayList", "<", "Model", ">", "(", ")", ";", "}", "models", ".", "add", "(", "model", ")", ";", "return", "models", ";", "}" ]
This method loops through all the parents, getting each pom model and then its parent. @param groupId the group id @param artifactId the artifact id @param version the version @param pom the pom @return the models recursively @throws ArtifactResolutionException the artifact resolution exception @throws ArtifactNotFoundException the artifact not found exception @throws IOException Signals that an I/O exception has occurred. @throws XmlPullParserException the xml pull parser exception
[ "This", "method", "loops", "through", "all", "the", "parents", "getting", "each", "pom", "model", "and", "then", "its", "parent", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java#L237-L273
150,188
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java
EnforcerRuleUtils.checkIfModelMatches
protected boolean checkIfModelMatches ( String groupId, String artifactId, String version, Model model ) { // try these first. String modelGroup = model.getGroupId(); String modelArtifactId = model.getArtifactId(); String modelVersion = model.getVersion(); try { if ( StringUtils.isEmpty( modelGroup ) ) { modelGroup = model.getParent().getGroupId(); } else { // MENFORCER-30, handle cases where the value is a property like ${project.parent.groupId} modelGroup = (String) helper.evaluate( modelGroup ); } if ( StringUtils.isEmpty( modelVersion ) ) { modelVersion = model.getParent().getVersion(); } else { // MENFORCER-30, handle cases where the value is a property like ${project.parent.version} modelVersion = (String) helper.evaluate( modelVersion ); } // Is this only required for Maven2? modelArtifactId = (String) helper.evaluate( modelArtifactId ); } catch ( NullPointerException e ) { // this is probably bad. I don't have a valid // group or version and I can't find a // parent???? // lets see if it's what we're looking for // anyway. } catch ( ExpressionEvaluationException e ) { // as above } return ( StringUtils.equals( groupId, modelGroup ) && StringUtils.equals( version, modelVersion ) && StringUtils .equals( artifactId, modelArtifactId ) ); }
java
protected boolean checkIfModelMatches ( String groupId, String artifactId, String version, Model model ) { // try these first. String modelGroup = model.getGroupId(); String modelArtifactId = model.getArtifactId(); String modelVersion = model.getVersion(); try { if ( StringUtils.isEmpty( modelGroup ) ) { modelGroup = model.getParent().getGroupId(); } else { // MENFORCER-30, handle cases where the value is a property like ${project.parent.groupId} modelGroup = (String) helper.evaluate( modelGroup ); } if ( StringUtils.isEmpty( modelVersion ) ) { modelVersion = model.getParent().getVersion(); } else { // MENFORCER-30, handle cases where the value is a property like ${project.parent.version} modelVersion = (String) helper.evaluate( modelVersion ); } // Is this only required for Maven2? modelArtifactId = (String) helper.evaluate( modelArtifactId ); } catch ( NullPointerException e ) { // this is probably bad. I don't have a valid // group or version and I can't find a // parent???? // lets see if it's what we're looking for // anyway. } catch ( ExpressionEvaluationException e ) { // as above } return ( StringUtils.equals( groupId, modelGroup ) && StringUtils.equals( version, modelVersion ) && StringUtils .equals( artifactId, modelArtifactId ) ); }
[ "protected", "boolean", "checkIfModelMatches", "(", "String", "groupId", ",", "String", "artifactId", ",", "String", "version", ",", "Model", "model", ")", "{", "// try these first.", "String", "modelGroup", "=", "model", ".", "getGroupId", "(", ")", ";", "String", "modelArtifactId", "=", "model", ".", "getArtifactId", "(", ")", ";", "String", "modelVersion", "=", "model", ".", "getVersion", "(", ")", ";", "try", "{", "if", "(", "StringUtils", ".", "isEmpty", "(", "modelGroup", ")", ")", "{", "modelGroup", "=", "model", ".", "getParent", "(", ")", ".", "getGroupId", "(", ")", ";", "}", "else", "{", "// MENFORCER-30, handle cases where the value is a property like ${project.parent.groupId}", "modelGroup", "=", "(", "String", ")", "helper", ".", "evaluate", "(", "modelGroup", ")", ";", "}", "if", "(", "StringUtils", ".", "isEmpty", "(", "modelVersion", ")", ")", "{", "modelVersion", "=", "model", ".", "getParent", "(", ")", ".", "getVersion", "(", ")", ";", "}", "else", "{", "// MENFORCER-30, handle cases where the value is a property like ${project.parent.version}", "modelVersion", "=", "(", "String", ")", "helper", ".", "evaluate", "(", "modelVersion", ")", ";", "}", "// Is this only required for Maven2?", "modelArtifactId", "=", "(", "String", ")", "helper", ".", "evaluate", "(", "modelArtifactId", ")", ";", "}", "catch", "(", "NullPointerException", "e", ")", "{", "// this is probably bad. I don't have a valid", "// group or version and I can't find a", "// parent????", "// lets see if it's what we're looking for", "// anyway.", "}", "catch", "(", "ExpressionEvaluationException", "e", ")", "{", "// as above", "}", "return", "(", "StringUtils", ".", "equals", "(", "groupId", ",", "modelGroup", ")", "&&", "StringUtils", ".", "equals", "(", "version", ",", "modelVersion", ")", "&&", "StringUtils", ".", "equals", "(", "artifactId", ",", "modelArtifactId", ")", ")", ";", "}" ]
Make sure the model is the one I'm expecting. @param groupId the group id @param artifactId the artifact id @param version the version @param model Model being checked. @return true, if check if model matches
[ "Make", "sure", "the", "model", "is", "the", "one", "I", "m", "expecting", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java#L285-L331
150,189
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseDeps.java
RequireReleaseDeps.execute
public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException { boolean callSuper; MavenProject project = null; if ( onlyWhenRelease ) { // get the project project = getProject( helper ); // only call super if this project is a release callSuper = !project.getArtifact().isSnapshot(); } else { callSuper = true; } if ( callSuper ) { super.execute( helper ); if ( failWhenParentIsSnapshot ) { if ( project == null ) { project = getProject( helper ); } Artifact parentArtifact = project.getParentArtifact(); if ( parentArtifact != null && parentArtifact.isSnapshot() ) { throw new EnforcerRuleException( "Parent Cannot be a snapshot: " + parentArtifact.getId() ); } } } }
java
public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException { boolean callSuper; MavenProject project = null; if ( onlyWhenRelease ) { // get the project project = getProject( helper ); // only call super if this project is a release callSuper = !project.getArtifact().isSnapshot(); } else { callSuper = true; } if ( callSuper ) { super.execute( helper ); if ( failWhenParentIsSnapshot ) { if ( project == null ) { project = getProject( helper ); } Artifact parentArtifact = project.getParentArtifact(); if ( parentArtifact != null && parentArtifact.isSnapshot() ) { throw new EnforcerRuleException( "Parent Cannot be a snapshot: " + parentArtifact.getId() ); } } } }
[ "public", "void", "execute", "(", "EnforcerRuleHelper", "helper", ")", "throws", "EnforcerRuleException", "{", "boolean", "callSuper", ";", "MavenProject", "project", "=", "null", ";", "if", "(", "onlyWhenRelease", ")", "{", "// get the project", "project", "=", "getProject", "(", "helper", ")", ";", "// only call super if this project is a release", "callSuper", "=", "!", "project", ".", "getArtifact", "(", ")", ".", "isSnapshot", "(", ")", ";", "}", "else", "{", "callSuper", "=", "true", ";", "}", "if", "(", "callSuper", ")", "{", "super", ".", "execute", "(", "helper", ")", ";", "if", "(", "failWhenParentIsSnapshot", ")", "{", "if", "(", "project", "==", "null", ")", "{", "project", "=", "getProject", "(", "helper", ")", ";", "}", "Artifact", "parentArtifact", "=", "project", ".", "getParentArtifact", "(", ")", ";", "if", "(", "parentArtifact", "!=", "null", "&&", "parentArtifact", ".", "isSnapshot", "(", ")", ")", "{", "throw", "new", "EnforcerRuleException", "(", "\"Parent Cannot be a snapshot: \"", "+", "parentArtifact", ".", "getId", "(", ")", ")", ";", "}", "}", "}", "}" ]
Override parent to allow optional ignore of this rule. @param helper the enforcerRuleHelper @throws EnforcerRuleException when an exception occurs
[ "Override", "parent", "to", "allow", "optional", "ignore", "of", "this", "rule", "." ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseDeps.java#L95-L128
150,190
jpaoletti/java-presentation-manager
modules/jpm-core/src/main/java/jpaoletti/jpm/converter/Converter.java
Converter.getNestedProperty
public Object getNestedProperty(Object obj, String propertyName) { if (obj != null && propertyName != null) { return PresentationManager.getPm().get(obj, propertyName); } return null; }
java
public Object getNestedProperty(Object obj, String propertyName) { if (obj != null && propertyName != null) { return PresentationManager.getPm().get(obj, propertyName); } return null; }
[ "public", "Object", "getNestedProperty", "(", "Object", "obj", ",", "String", "propertyName", ")", "{", "if", "(", "obj", "!=", "null", "&&", "propertyName", "!=", "null", ")", "{", "return", "PresentationManager", ".", "getPm", "(", ")", ".", "get", "(", "obj", ",", "propertyName", ")", ";", "}", "return", "null", ";", "}" ]
Getter for a nested property in the given object. @param obj The object @param propertyName The name of the property to get @return The property value
[ "Getter", "for", "a", "nested", "property", "in", "the", "given", "object", "." ]
d5aab55638383695db244744b4bfe27c5200e04f
https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-core/src/main/java/jpaoletti/jpm/converter/Converter.java#L111-L116
150,191
jpaoletti/java-presentation-manager
modules/jpm-core/src/main/java/jpaoletti/jpm/converter/Converter.java
Converter.visualize
public String visualize(Object obj) throws ConverterException { Integer pad = 0; String padc = getConfig("pad-count", "0"); try { pad = Integer.parseInt(padc); } catch (Exception e) { } char padch = getConfig("pad-char", " ").charAt(0); String padd = getConfig("pad-direction", "left"); String prefix = getConfig("prefix"); String suffix = getConfig("suffix"); String res = obj != null ? obj.toString() : ""; if (padd.compareToIgnoreCase("left") == 0) { res = Utils.padleft(res, pad, padch); } else { res = Utils.padright(res, pad, padch); } if (prefix != null) { res = prefix + res; } if (suffix != null) { res = res + suffix; } return res; }
java
public String visualize(Object obj) throws ConverterException { Integer pad = 0; String padc = getConfig("pad-count", "0"); try { pad = Integer.parseInt(padc); } catch (Exception e) { } char padch = getConfig("pad-char", " ").charAt(0); String padd = getConfig("pad-direction", "left"); String prefix = getConfig("prefix"); String suffix = getConfig("suffix"); String res = obj != null ? obj.toString() : ""; if (padd.compareToIgnoreCase("left") == 0) { res = Utils.padleft(res, pad, padch); } else { res = Utils.padright(res, pad, padch); } if (prefix != null) { res = prefix + res; } if (suffix != null) { res = res + suffix; } return res; }
[ "public", "String", "visualize", "(", "Object", "obj", ")", "throws", "ConverterException", "{", "Integer", "pad", "=", "0", ";", "String", "padc", "=", "getConfig", "(", "\"pad-count\"", ",", "\"0\"", ")", ";", "try", "{", "pad", "=", "Integer", ".", "parseInt", "(", "padc", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "char", "padch", "=", "getConfig", "(", "\"pad-char\"", ",", "\" \"", ")", ".", "charAt", "(", "0", ")", ";", "String", "padd", "=", "getConfig", "(", "\"pad-direction\"", ",", "\"left\"", ")", ";", "String", "prefix", "=", "getConfig", "(", "\"prefix\"", ")", ";", "String", "suffix", "=", "getConfig", "(", "\"suffix\"", ")", ";", "String", "res", "=", "obj", "!=", "null", "?", "obj", ".", "toString", "(", ")", ":", "\"\"", ";", "if", "(", "padd", ".", "compareToIgnoreCase", "(", "\"left\"", ")", "==", "0", ")", "{", "res", "=", "Utils", ".", "padleft", "(", "res", ",", "pad", ",", "padch", ")", ";", "}", "else", "{", "res", "=", "Utils", ".", "padright", "(", "res", ",", "pad", ",", "padch", ")", ";", "}", "if", "(", "prefix", "!=", "null", ")", "{", "res", "=", "prefix", "+", "res", ";", "}", "if", "(", "suffix", "!=", "null", ")", "{", "res", "=", "res", "+", "suffix", ";", "}", "return", "res", ";", "}" ]
Visualization with some standard properties. @param obj The object to visualize @param extra Some extra text. Not used at the moment. @return The string representation of the given object @throws ConverterException when an exception occurs trying to convert.
[ "Visualization", "with", "some", "standard", "properties", "." ]
d5aab55638383695db244744b4bfe27c5200e04f
https://github.com/jpaoletti/java-presentation-manager/blob/d5aab55638383695db244744b4bfe27c5200e04f/modules/jpm-core/src/main/java/jpaoletti/jpm/converter/Converter.java#L155-L180
150,192
diegossilveira/jcors
src/main/java/org/jcors/config/JCorsConfig.java
JCorsConfig.addAllowedOrigin
public void addAllowedOrigin(String origin) { Constraint.ensureNotEmpty(origin, String.format("Invalid origin '%s'", origin)); allowedOrigins.add(origin); }
java
public void addAllowedOrigin(String origin) { Constraint.ensureNotEmpty(origin, String.format("Invalid origin '%s'", origin)); allowedOrigins.add(origin); }
[ "public", "void", "addAllowedOrigin", "(", "String", "origin", ")", "{", "Constraint", ".", "ensureNotEmpty", "(", "origin", ",", "String", ".", "format", "(", "\"Invalid origin '%s'\"", ",", "origin", ")", ")", ";", "allowedOrigins", ".", "add", "(", "origin", ")", ";", "}" ]
Add an origin allowed by the resource @param origin
[ "Add", "an", "origin", "allowed", "by", "the", "resource" ]
cd56a9e2055d629baa42f93b27dd5615ced9632f
https://github.com/diegossilveira/jcors/blob/cd56a9e2055d629baa42f93b27dd5615ced9632f/src/main/java/org/jcors/config/JCorsConfig.java#L108-L112
150,193
diegossilveira/jcors
src/main/java/org/jcors/config/JCorsConfig.java
JCorsConfig.addAllowedHeader
public void addAllowedHeader(String header) { Constraint.ensureNotEmpty(header, String.format("Invalid header '%s'", header)); allowedHeaders.add(header.toLowerCase()); }
java
public void addAllowedHeader(String header) { Constraint.ensureNotEmpty(header, String.format("Invalid header '%s'", header)); allowedHeaders.add(header.toLowerCase()); }
[ "public", "void", "addAllowedHeader", "(", "String", "header", ")", "{", "Constraint", ".", "ensureNotEmpty", "(", "header", ",", "String", ".", "format", "(", "\"Invalid header '%s'\"", ",", "header", ")", ")", ";", "allowedHeaders", ".", "add", "(", "header", ".", "toLowerCase", "(", ")", ")", ";", "}" ]
Add a header allowed by the resource @param header
[ "Add", "a", "header", "allowed", "by", "the", "resource" ]
cd56a9e2055d629baa42f93b27dd5615ced9632f
https://github.com/diegossilveira/jcors/blob/cd56a9e2055d629baa42f93b27dd5615ced9632f/src/main/java/org/jcors/config/JCorsConfig.java#L162-L166
150,194
diegossilveira/jcors
src/main/java/org/jcors/config/JCorsConfig.java
JCorsConfig.getAllowedHeaders
public Collection<String> getAllowedHeaders(Collection<String> requestHeaders) { Constraint.ensureNotNull(requestHeaders, "Null headers"); Set<String> rtAllowedHeaders = new HashSet<String>(allowedHeaders); rtAllowedHeaders.addAll(requestHeaders); return rtAllowedHeaders; }
java
public Collection<String> getAllowedHeaders(Collection<String> requestHeaders) { Constraint.ensureNotNull(requestHeaders, "Null headers"); Set<String> rtAllowedHeaders = new HashSet<String>(allowedHeaders); rtAllowedHeaders.addAll(requestHeaders); return rtAllowedHeaders; }
[ "public", "Collection", "<", "String", ">", "getAllowedHeaders", "(", "Collection", "<", "String", ">", "requestHeaders", ")", "{", "Constraint", ".", "ensureNotNull", "(", "requestHeaders", ",", "\"Null headers\"", ")", ";", "Set", "<", "String", ">", "rtAllowedHeaders", "=", "new", "HashSet", "<", "String", ">", "(", "allowedHeaders", ")", ";", "rtAllowedHeaders", ".", "addAll", "(", "requestHeaders", ")", ";", "return", "rtAllowedHeaders", ";", "}" ]
Return all headers allowed by the resource, including the preflight request headers @param requestHeaders @return
[ "Return", "all", "headers", "allowed", "by", "the", "resource", "including", "the", "preflight", "request", "headers" ]
cd56a9e2055d629baa42f93b27dd5615ced9632f
https://github.com/diegossilveira/jcors/blob/cd56a9e2055d629baa42f93b27dd5615ced9632f/src/main/java/org/jcors/config/JCorsConfig.java#L174-L181
150,195
diegossilveira/jcors
src/main/java/org/jcors/config/JCorsConfig.java
JCorsConfig.isMethodAllowed
public boolean isMethodAllowed(String method) { return HttpMethod.isValidMethod(method) && (allowedMethods.isEmpty() || allowedMethods.contains(method)); }
java
public boolean isMethodAllowed(String method) { return HttpMethod.isValidMethod(method) && (allowedMethods.isEmpty() || allowedMethods.contains(method)); }
[ "public", "boolean", "isMethodAllowed", "(", "String", "method", ")", "{", "return", "HttpMethod", ".", "isValidMethod", "(", "method", ")", "&&", "(", "allowedMethods", ".", "isEmpty", "(", ")", "||", "allowedMethods", ".", "contains", "(", "method", ")", ")", ";", "}" ]
Check if the method is allowed by the resource This check is case-sensitive @param method @return
[ "Check", "if", "the", "method", "is", "allowed", "by", "the", "resource", "This", "check", "is", "case", "-", "sensitive" ]
cd56a9e2055d629baa42f93b27dd5615ced9632f
https://github.com/diegossilveira/jcors/blob/cd56a9e2055d629baa42f93b27dd5615ced9632f/src/main/java/org/jcors/config/JCorsConfig.java#L189-L192
150,196
diegossilveira/jcors
src/main/java/org/jcors/config/JCorsConfig.java
JCorsConfig.addAllowedMethod
public void addAllowedMethod(String method) { Constraint.ensureNotEmpty(method, String.format("Invalid method '%s'", method)); Constraint.ensureTrue(HttpMethod.isValidMethod(method), String.format("Invalid method '%s'", method)); allowedMethods.add(method.toUpperCase()); }
java
public void addAllowedMethod(String method) { Constraint.ensureNotEmpty(method, String.format("Invalid method '%s'", method)); Constraint.ensureTrue(HttpMethod.isValidMethod(method), String.format("Invalid method '%s'", method)); allowedMethods.add(method.toUpperCase()); }
[ "public", "void", "addAllowedMethod", "(", "String", "method", ")", "{", "Constraint", ".", "ensureNotEmpty", "(", "method", ",", "String", ".", "format", "(", "\"Invalid method '%s'\"", ",", "method", ")", ")", ";", "Constraint", ".", "ensureTrue", "(", "HttpMethod", ".", "isValidMethod", "(", "method", ")", ",", "String", ".", "format", "(", "\"Invalid method '%s'\"", ",", "method", ")", ")", ";", "allowedMethods", ".", "add", "(", "method", ".", "toUpperCase", "(", ")", ")", ";", "}" ]
Add a method allowed by the resource @param method
[ "Add", "a", "method", "allowed", "by", "the", "resource" ]
cd56a9e2055d629baa42f93b27dd5615ced9632f
https://github.com/diegossilveira/jcors/blob/cd56a9e2055d629baa42f93b27dd5615ced9632f/src/main/java/org/jcors/config/JCorsConfig.java#L199-L204
150,197
diegossilveira/jcors
src/main/java/org/jcors/config/JCorsConfig.java
JCorsConfig.getAllowedMethods
public Collection<String> getAllowedMethods(String requestMethod) { Constraint.ensureNotEmpty(requestMethod, String.format("Invalid method '%s'", requestMethod)); Set<String> rtAllowedMethods = new HashSet<String>(allowedMethods); rtAllowedMethods.add(requestMethod.toUpperCase()); return rtAllowedMethods; }
java
public Collection<String> getAllowedMethods(String requestMethod) { Constraint.ensureNotEmpty(requestMethod, String.format("Invalid method '%s'", requestMethod)); Set<String> rtAllowedMethods = new HashSet<String>(allowedMethods); rtAllowedMethods.add(requestMethod.toUpperCase()); return rtAllowedMethods; }
[ "public", "Collection", "<", "String", ">", "getAllowedMethods", "(", "String", "requestMethod", ")", "{", "Constraint", ".", "ensureNotEmpty", "(", "requestMethod", ",", "String", ".", "format", "(", "\"Invalid method '%s'\"", ",", "requestMethod", ")", ")", ";", "Set", "<", "String", ">", "rtAllowedMethods", "=", "new", "HashSet", "<", "String", ">", "(", "allowedMethods", ")", ";", "rtAllowedMethods", ".", "add", "(", "requestMethod", ".", "toUpperCase", "(", ")", ")", ";", "return", "rtAllowedMethods", ";", "}" ]
Return all methods allowed by the resource, including the preflight request method @param requestMethod @return
[ "Return", "all", "methods", "allowed", "by", "the", "resource", "including", "the", "preflight", "request", "method" ]
cd56a9e2055d629baa42f93b27dd5615ced9632f
https://github.com/diegossilveira/jcors/blob/cd56a9e2055d629baa42f93b27dd5615ced9632f/src/main/java/org/jcors/config/JCorsConfig.java#L212-L219
150,198
GerdHolz/TOVAL
src/de/invation/code/toval/os/SolarisUtils.java
SolarisUtils.registerFileExtension
@Override public boolean registerFileExtension(String fileTypeName, String fileTypeExtension, String application) throws OSException { throw new UnsupportedOperationException("Not supported yet."); }
java
@Override public boolean registerFileExtension(String fileTypeName, String fileTypeExtension, String application) throws OSException { throw new UnsupportedOperationException("Not supported yet."); }
[ "@", "Override", "public", "boolean", "registerFileExtension", "(", "String", "fileTypeName", ",", "String", "fileTypeExtension", ",", "String", "application", ")", "throws", "OSException", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Not supported yet.\"", ")", ";", "}" ]
Registers a new file extension in the operating system. @param fileTypeName Name of the file extension. Must be atomic, e.g. <code>foocorp.fooapp.v1</code>. @param fileTypeExtension File extension with leading dot, e.g. <code>.bar</code>. @param application Path to the application, which should open the new file extension. @return <code>true</code> if registration was successful, <code>false</code> otherwise. @throws OSException
[ "Registers", "a", "new", "file", "extension", "in", "the", "operating", "system", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/os/SolarisUtils.java#L118-L121
150,199
jtrfp/javamod
src/main/java/de/quippy/ogg/jorbis/VorbisFile.java
VorbisFile.fetch_headers
int fetch_headers(Info vi, Comment vc, int[] serialno, Page og_ptr){ Page og=new Page(); Packet op=new Packet(); int ret; if(og_ptr==null){ ret=get_next_page(og, CHUNKSIZE); if(ret==OV_EREAD) return OV_EREAD; if(ret<0) return OV_ENOTVORBIS; og_ptr=og; } if(serialno!=null) serialno[0]=og_ptr.serialno(); os.init(og_ptr.serialno()); // extract the initial header from the first page and verify that the // Ogg bitstream is in fact Vorbis data vi.init(); vc.init(); int i=0; while(i<3){ os.pagein(og_ptr); while(i<3){ int result=os.packetout(op); if(result==0) break; if(result==-1){ vi.clear(); vc.clear(); os.clear(); return -1; } if(vi.synthesis_headerin(vc, op)!=0){ vi.clear(); vc.clear(); os.clear(); return -1; } i++; } if(i<3) if(get_next_page(og_ptr, 1)<0){ vi.clear(); vc.clear(); os.clear(); return -1; } } return 0; }
java
int fetch_headers(Info vi, Comment vc, int[] serialno, Page og_ptr){ Page og=new Page(); Packet op=new Packet(); int ret; if(og_ptr==null){ ret=get_next_page(og, CHUNKSIZE); if(ret==OV_EREAD) return OV_EREAD; if(ret<0) return OV_ENOTVORBIS; og_ptr=og; } if(serialno!=null) serialno[0]=og_ptr.serialno(); os.init(og_ptr.serialno()); // extract the initial header from the first page and verify that the // Ogg bitstream is in fact Vorbis data vi.init(); vc.init(); int i=0; while(i<3){ os.pagein(og_ptr); while(i<3){ int result=os.packetout(op); if(result==0) break; if(result==-1){ vi.clear(); vc.clear(); os.clear(); return -1; } if(vi.synthesis_headerin(vc, op)!=0){ vi.clear(); vc.clear(); os.clear(); return -1; } i++; } if(i<3) if(get_next_page(og_ptr, 1)<0){ vi.clear(); vc.clear(); os.clear(); return -1; } } return 0; }
[ "int", "fetch_headers", "(", "Info", "vi", ",", "Comment", "vc", ",", "int", "[", "]", "serialno", ",", "Page", "og_ptr", ")", "{", "Page", "og", "=", "new", "Page", "(", ")", ";", "Packet", "op", "=", "new", "Packet", "(", ")", ";", "int", "ret", ";", "if", "(", "og_ptr", "==", "null", ")", "{", "ret", "=", "get_next_page", "(", "og", ",", "CHUNKSIZE", ")", ";", "if", "(", "ret", "==", "OV_EREAD", ")", "return", "OV_EREAD", ";", "if", "(", "ret", "<", "0", ")", "return", "OV_ENOTVORBIS", ";", "og_ptr", "=", "og", ";", "}", "if", "(", "serialno", "!=", "null", ")", "serialno", "[", "0", "]", "=", "og_ptr", ".", "serialno", "(", ")", ";", "os", ".", "init", "(", "og_ptr", ".", "serialno", "(", ")", ")", ";", "// extract the initial header from the first page and verify that the", "// Ogg bitstream is in fact Vorbis data", "vi", ".", "init", "(", ")", ";", "vc", ".", "init", "(", ")", ";", "int", "i", "=", "0", ";", "while", "(", "i", "<", "3", ")", "{", "os", ".", "pagein", "(", "og_ptr", ")", ";", "while", "(", "i", "<", "3", ")", "{", "int", "result", "=", "os", ".", "packetout", "(", "op", ")", ";", "if", "(", "result", "==", "0", ")", "break", ";", "if", "(", "result", "==", "-", "1", ")", "{", "vi", ".", "clear", "(", ")", ";", "vc", ".", "clear", "(", ")", ";", "os", ".", "clear", "(", ")", ";", "return", "-", "1", ";", "}", "if", "(", "vi", ".", "synthesis_headerin", "(", "vc", ",", "op", ")", "!=", "0", ")", "{", "vi", ".", "clear", "(", ")", ";", "vc", ".", "clear", "(", ")", ";", "os", ".", "clear", "(", ")", ";", "return", "-", "1", ";", "}", "i", "++", ";", "}", "if", "(", "i", "<", "3", ")", "if", "(", "get_next_page", "(", "og_ptr", ",", "1", ")", "<", "0", ")", "{", "vi", ".", "clear", "(", ")", ";", "vc", ".", "clear", "(", ")", ";", "os", ".", "clear", "(", ")", ";", "return", "-", "1", ";", "}", "}", "return", "0", ";", "}" ]
non-streaming input sources
[ "non", "-", "streaming", "input", "sources" ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/ogg/jorbis/VorbisFile.java#L258-L313