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
151,000
isisaddons-legacy/isis-module-publishmq
dom/jdo/src/main/java/org/isisaddons/module/publishmq/dom/jdo/events/PublishedEventRepository.java
PublishedEventRepository.findByTargetAndFromAndTo
@Programmatic public List<PublishedEvent> findByTargetAndFromAndTo( final Object publishedObject, final LocalDate from, final LocalDate to) { final Bookmark bookmark = bookmarkService.bookmarkFor(publishedObject); return findByTargetAndFromAndTo(bookmark, from, to); }
java
@Programmatic public List<PublishedEvent> findByTargetAndFromAndTo( final Object publishedObject, final LocalDate from, final LocalDate to) { final Bookmark bookmark = bookmarkService.bookmarkFor(publishedObject); return findByTargetAndFromAndTo(bookmark, from, to); }
[ "@", "Programmatic", "public", "List", "<", "PublishedEvent", ">", "findByTargetAndFromAndTo", "(", "final", "Object", "publishedObject", ",", "final", "LocalDate", "from", ",", "final", "LocalDate", "to", ")", "{", "final", "Bookmark", "bookmark", "=", "bookmarkService", ".", "bookmarkFor", "(", "publishedObject", ")", ";", "return", "findByTargetAndFromAndTo", "(", "bookmark", ",", "from", ",", "to", ")", ";", "}" ]
region > findByTargetAndFromAndTo
[ "region", ">", "findByTargetAndFromAndTo" ]
b1a424f95b26a2a0369aac706c2e30074b7f6e43
https://github.com/isisaddons-legacy/isis-module-publishmq/blob/b1a424f95b26a2a0369aac706c2e30074b7f6e43/dom/jdo/src/main/java/org/isisaddons/module/publishmq/dom/jdo/events/PublishedEventRepository.java#L75-L83
151,001
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/util/CommandLineUtil.java
CommandLineUtil.getOptionValue
public static String getOptionValue(String[] args, String optionName) { String opt = "-" + optionName + "="; for (String arg : args) { if (arg.startsWith(opt)) return arg.substring(opt.length()); } return null; }
java
public static String getOptionValue(String[] args, String optionName) { String opt = "-" + optionName + "="; for (String arg : args) { if (arg.startsWith(opt)) return arg.substring(opt.length()); } return null; }
[ "public", "static", "String", "getOptionValue", "(", "String", "[", "]", "args", ",", "String", "optionName", ")", "{", "String", "opt", "=", "\"-\"", "+", "optionName", "+", "\"=\"", ";", "for", "(", "String", "arg", ":", "args", ")", "{", "if", "(", "arg", ".", "startsWith", "(", "opt", ")", ")", "return", "arg", ".", "substring", "(", "opt", ".", "length", "(", ")", ")", ";", "}", "return", "null", ";", "}" ]
Search for an argument "-&lt;option&gt;=&lt;value&gt;" where option is the given option name, and return the value.
[ "Search", "for", "an", "argument", "-", "&lt", ";", "option&gt", ";", "=", "&lt", ";", "value&gt", ";", "where", "option", "is", "the", "given", "option", "name", "and", "return", "the", "value", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/util/CommandLineUtil.java#L11-L18
151,002
GerdHolz/TOVAL
src/de/invation/code/toval/os/LinuxUtils.java
LinuxUtils.registerFileExtension
@Override public boolean registerFileExtension(String mimeTypeName, String fileTypeExtension, String application) throws OSException { // TODO create mime-info in /usr/share/mime/packages // TODO add MIME type to .desktop file // not possible due to missing permissions? throw new UnsupportedOperationException("Not supported."); }
java
@Override public boolean registerFileExtension(String mimeTypeName, String fileTypeExtension, String application) throws OSException { // TODO create mime-info in /usr/share/mime/packages // TODO add MIME type to .desktop file // not possible due to missing permissions? throw new UnsupportedOperationException("Not supported."); }
[ "@", "Override", "public", "boolean", "registerFileExtension", "(", "String", "mimeTypeName", ",", "String", "fileTypeExtension", ",", "String", "application", ")", "throws", "OSException", "{", "// TODO create mime-info in /usr/share/mime/packages", "// TODO add MIME type to .desktop file", "// not possible due to missing permissions?", "throw", "new", "UnsupportedOperationException", "(", "\"Not supported.\"", ")", ";", "}" ]
Registers a new file extension. @param mimeTypeName MIME type 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", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/os/LinuxUtils.java#L141-L147
151,003
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/io/TemporaryFiles.java
TemporaryFiles.get
public static TemporaryFiles get(Application app) { TemporaryFiles instance = app.getInstance(TemporaryFiles.class); if (instance == null) { File dir = null; String path = app.getProperty(Application.PROPERTY_TMP_DIRECTORY); if (path != null) { dir = new File(path); if (!dir.exists()) if (!dir.mkdirs()) dir = null; } if (dir == null) { path = app.getProperty("java.io.tmpdir"); if (path != null) { dir = new File(path); if (!dir.exists()) if (!dir.mkdirs()) dir = null; } } instance = new TemporaryFiles(/*app, */dir); } return instance; }
java
public static TemporaryFiles get(Application app) { TemporaryFiles instance = app.getInstance(TemporaryFiles.class); if (instance == null) { File dir = null; String path = app.getProperty(Application.PROPERTY_TMP_DIRECTORY); if (path != null) { dir = new File(path); if (!dir.exists()) if (!dir.mkdirs()) dir = null; } if (dir == null) { path = app.getProperty("java.io.tmpdir"); if (path != null) { dir = new File(path); if (!dir.exists()) if (!dir.mkdirs()) dir = null; } } instance = new TemporaryFiles(/*app, */dir); } return instance; }
[ "public", "static", "TemporaryFiles", "get", "(", "Application", "app", ")", "{", "TemporaryFiles", "instance", "=", "app", ".", "getInstance", "(", "TemporaryFiles", ".", "class", ")", ";", "if", "(", "instance", "==", "null", ")", "{", "File", "dir", "=", "null", ";", "String", "path", "=", "app", ".", "getProperty", "(", "Application", ".", "PROPERTY_TMP_DIRECTORY", ")", ";", "if", "(", "path", "!=", "null", ")", "{", "dir", "=", "new", "File", "(", "path", ")", ";", "if", "(", "!", "dir", ".", "exists", "(", ")", ")", "if", "(", "!", "dir", ".", "mkdirs", "(", ")", ")", "dir", "=", "null", ";", "}", "if", "(", "dir", "==", "null", ")", "{", "path", "=", "app", ".", "getProperty", "(", "\"java.io.tmpdir\"", ")", ";", "if", "(", "path", "!=", "null", ")", "{", "dir", "=", "new", "File", "(", "path", ")", ";", "if", "(", "!", "dir", ".", "exists", "(", ")", ")", "if", "(", "!", "dir", ".", "mkdirs", "(", ")", ")", "dir", "=", "null", ";", "}", "}", "instance", "=", "new", "TemporaryFiles", "(", "/*app, */", "dir", ")", ";", "}", "return", "instance", ";", "}" ]
Get the instance for the given application.
[ "Get", "the", "instance", "for", "the", "given", "application", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/io/TemporaryFiles.java#L23-L46
151,004
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/io/TemporaryFiles.java
TemporaryFiles.setTemporaryDirectory
public void setTemporaryDirectory(File dir) throws IOException { if (dir != null) { if (!dir.exists() || !dir.isDirectory()) if (!dir.mkdirs()) throw new IOException("Unable to create temporary directory: " + dir.getAbsolutePath()); } tempDir = dir; }
java
public void setTemporaryDirectory(File dir) throws IOException { if (dir != null) { if (!dir.exists() || !dir.isDirectory()) if (!dir.mkdirs()) throw new IOException("Unable to create temporary directory: " + dir.getAbsolutePath()); } tempDir = dir; }
[ "public", "void", "setTemporaryDirectory", "(", "File", "dir", ")", "throws", "IOException", "{", "if", "(", "dir", "!=", "null", ")", "{", "if", "(", "!", "dir", ".", "exists", "(", ")", "||", "!", "dir", ".", "isDirectory", "(", ")", ")", "if", "(", "!", "dir", ".", "mkdirs", "(", ")", ")", "throw", "new", "IOException", "(", "\"Unable to create temporary directory: \"", "+", "dir", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "tempDir", "=", "dir", ";", "}" ]
Set the directory into which create temporary files.
[ "Set", "the", "directory", "into", "which", "create", "temporary", "files", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/io/TemporaryFiles.java#L68-L75
151,005
oaqa/uima-ecd
src/main/java/edu/cmu/lti/oaqa/framework/types/CurrentExecution.java
CurrentExecution.getIdHash
public String getIdHash() { if (CurrentExecution_Type.featOkTst && ((CurrentExecution_Type)jcasType).casFeat_idHash == null) jcasType.jcas.throwFeatMissing("idHash", "edu.cmu.lti.oaqa.framework.types.CurrentExecution"); return jcasType.ll_cas.ll_getStringValue(addr, ((CurrentExecution_Type)jcasType).casFeatCode_idHash);}
java
public String getIdHash() { if (CurrentExecution_Type.featOkTst && ((CurrentExecution_Type)jcasType).casFeat_idHash == null) jcasType.jcas.throwFeatMissing("idHash", "edu.cmu.lti.oaqa.framework.types.CurrentExecution"); return jcasType.ll_cas.ll_getStringValue(addr, ((CurrentExecution_Type)jcasType).casFeatCode_idHash);}
[ "public", "String", "getIdHash", "(", ")", "{", "if", "(", "CurrentExecution_Type", ".", "featOkTst", "&&", "(", "(", "CurrentExecution_Type", ")", "jcasType", ")", ".", "casFeat_idHash", "==", "null", ")", "jcasType", ".", "jcas", ".", "throwFeatMissing", "(", "\"idHash\"", ",", "\"edu.cmu.lti.oaqa.framework.types.CurrentExecution\"", ")", ";", "return", "jcasType", ".", "ll_cas", ".", "ll_getStringValue", "(", "addr", ",", "(", "(", "CurrentExecution_Type", ")", "jcasType", ")", ".", "casFeatCode_idHash", ")", ";", "}" ]
getter for idHash - gets @generated
[ "getter", "for", "idHash", "-", "gets" ]
09a0ae26647490b43affc36ab3a01100702b989f
https://github.com/oaqa/uima-ecd/blob/09a0ae26647490b43affc36ab3a01100702b989f/src/main/java/edu/cmu/lti/oaqa/framework/types/CurrentExecution.java#L70-L73
151,006
oaqa/uima-ecd
src/main/java/edu/cmu/lti/oaqa/framework/types/CurrentExecution.java
CurrentExecution.setIdHash
public void setIdHash(String v) { if (CurrentExecution_Type.featOkTst && ((CurrentExecution_Type)jcasType).casFeat_idHash == null) jcasType.jcas.throwFeatMissing("idHash", "edu.cmu.lti.oaqa.framework.types.CurrentExecution"); jcasType.ll_cas.ll_setStringValue(addr, ((CurrentExecution_Type)jcasType).casFeatCode_idHash, v);}
java
public void setIdHash(String v) { if (CurrentExecution_Type.featOkTst && ((CurrentExecution_Type)jcasType).casFeat_idHash == null) jcasType.jcas.throwFeatMissing("idHash", "edu.cmu.lti.oaqa.framework.types.CurrentExecution"); jcasType.ll_cas.ll_setStringValue(addr, ((CurrentExecution_Type)jcasType).casFeatCode_idHash, v);}
[ "public", "void", "setIdHash", "(", "String", "v", ")", "{", "if", "(", "CurrentExecution_Type", ".", "featOkTst", "&&", "(", "(", "CurrentExecution_Type", ")", "jcasType", ")", ".", "casFeat_idHash", "==", "null", ")", "jcasType", ".", "jcas", ".", "throwFeatMissing", "(", "\"idHash\"", ",", "\"edu.cmu.lti.oaqa.framework.types.CurrentExecution\"", ")", ";", "jcasType", ".", "ll_cas", ".", "ll_setStringValue", "(", "addr", ",", "(", "(", "CurrentExecution_Type", ")", "jcasType", ")", ".", "casFeatCode_idHash", ",", "v", ")", ";", "}" ]
setter for idHash - sets @generated
[ "setter", "for", "idHash", "-", "sets" ]
09a0ae26647490b43affc36ab3a01100702b989f
https://github.com/oaqa/uima-ecd/blob/09a0ae26647490b43affc36ab3a01100702b989f/src/main/java/edu/cmu/lti/oaqa/framework/types/CurrentExecution.java#L77-L80
151,007
agaricusb/SpecialSourceMP
src/main/java/net/md_5/specialsource/mavenplugin/InstallRemappedFileMojo.java
InstallRemappedFileMojo.validateArtifactInformation
private void validateArtifactInformation() throws MojoExecutionException { Model model = generateModel(); ModelValidationResult result = modelValidator.validate( model ); if ( result.getMessageCount() > 0 ) { throw new MojoExecutionException( "The artifact information is incomplete or not valid:\n" + result.render( " " ) ); } }
java
private void validateArtifactInformation() throws MojoExecutionException { Model model = generateModel(); ModelValidationResult result = modelValidator.validate( model ); if ( result.getMessageCount() > 0 ) { throw new MojoExecutionException( "The artifact information is incomplete or not valid:\n" + result.render( " " ) ); } }
[ "private", "void", "validateArtifactInformation", "(", ")", "throws", "MojoExecutionException", "{", "Model", "model", "=", "generateModel", "(", ")", ";", "ModelValidationResult", "result", "=", "modelValidator", ".", "validate", "(", "model", ")", ";", "if", "(", "result", ".", "getMessageCount", "(", ")", ">", "0", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"The artifact information is incomplete or not valid:\\n\"", "+", "result", ".", "render", "(", "\" \"", ")", ")", ";", "}", "}" ]
Validates the user-supplied artifact information. @throws MojoExecutionException If any artifact coordinate is invalid.
[ "Validates", "the", "user", "-", "supplied", "artifact", "information", "." ]
350daa04831fb93a51a57a30009c572ade0a88bf
https://github.com/agaricusb/SpecialSourceMP/blob/350daa04831fb93a51a57a30009c572ade0a88bf/src/main/java/net/md_5/specialsource/mavenplugin/InstallRemappedFileMojo.java#L402-L414
151,008
agaricusb/SpecialSourceMP
src/main/java/net/md_5/specialsource/mavenplugin/InstallRemappedFileMojo.java
InstallRemappedFileMojo.generateModel
private Model generateModel() { Model model = new Model(); model.setModelVersion( "4.0.0" ); model.setGroupId( groupId ); model.setArtifactId( artifactId ); model.setVersion( version ); model.setPackaging( packaging ); model.setDescription( "POM was created from specialsource-maven-plugin" ); return model; }
java
private Model generateModel() { Model model = new Model(); model.setModelVersion( "4.0.0" ); model.setGroupId( groupId ); model.setArtifactId( artifactId ); model.setVersion( version ); model.setPackaging( packaging ); model.setDescription( "POM was created from specialsource-maven-plugin" ); return model; }
[ "private", "Model", "generateModel", "(", ")", "{", "Model", "model", "=", "new", "Model", "(", ")", ";", "model", ".", "setModelVersion", "(", "\"4.0.0\"", ")", ";", "model", ".", "setGroupId", "(", "groupId", ")", ";", "model", ".", "setArtifactId", "(", "artifactId", ")", ";", "model", ".", "setVersion", "(", "version", ")", ";", "model", ".", "setPackaging", "(", "packaging", ")", ";", "model", ".", "setDescription", "(", "\"POM was created from specialsource-maven-plugin\"", ")", ";", "return", "model", ";", "}" ]
Generates a minimal model from the user-supplied artifact information. @return The generated model, never <code>null</code>.
[ "Generates", "a", "minimal", "model", "from", "the", "user", "-", "supplied", "artifact", "information", "." ]
350daa04831fb93a51a57a30009c572ade0a88bf
https://github.com/agaricusb/SpecialSourceMP/blob/350daa04831fb93a51a57a30009c572ade0a88bf/src/main/java/net/md_5/specialsource/mavenplugin/InstallRemappedFileMojo.java#L422-L436
151,009
agaricusb/SpecialSourceMP
src/main/java/net/md_5/specialsource/mavenplugin/InstallRemappedFileMojo.java
InstallRemappedFileMojo.installChecksums
protected void installChecksums( Collection metadataFiles ) throws MojoExecutionException { for ( Iterator it = metadataFiles.iterator(); it.hasNext(); ) { File metadataFile = (File) it.next(); installChecksums( metadataFile ); } }
java
protected void installChecksums( Collection metadataFiles ) throws MojoExecutionException { for ( Iterator it = metadataFiles.iterator(); it.hasNext(); ) { File metadataFile = (File) it.next(); installChecksums( metadataFile ); } }
[ "protected", "void", "installChecksums", "(", "Collection", "metadataFiles", ")", "throws", "MojoExecutionException", "{", "for", "(", "Iterator", "it", "=", "metadataFiles", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "File", "metadataFile", "=", "(", "File", ")", "it", ".", "next", "(", ")", ";", "installChecksums", "(", "metadataFile", ")", ";", "}", "}" ]
Installs the checksums for the specified metadata files. @param metadataFiles The collection of metadata files to install checksums for, must not be <code>null</code>. @throws MojoExecutionException If the checksums could not be installed.
[ "Installs", "the", "checksums", "for", "the", "specified", "metadata", "files", "." ]
350daa04831fb93a51a57a30009c572ade0a88bf
https://github.com/agaricusb/SpecialSourceMP/blob/350daa04831fb93a51a57a30009c572ade0a88bf/src/main/java/net/md_5/specialsource/mavenplugin/InstallRemappedFileMojo.java#L539-L547
151,010
agaricusb/SpecialSourceMP
src/main/java/net/md_5/specialsource/mavenplugin/InstallRemappedFileMojo.java
InstallRemappedFileMojo.installChecksum
private void installChecksum( File originalFile, File installedFile, Digester digester, String ext ) throws MojoExecutionException { String checksum; getLog().debug( "Calculating " + digester.getAlgorithm() + " checksum for " + originalFile ); try { checksum = digester.calc( originalFile ); } catch ( DigesterException e ) { throw new MojoExecutionException( "Failed to calculate " + digester.getAlgorithm() + " checksum for " + originalFile, e ); } File checksumFile = new File( installedFile.getAbsolutePath() + ext ); getLog().debug( "Installing checksum to " + checksumFile ); try { checksumFile.getParentFile().mkdirs(); FileUtils.fileWrite( checksumFile.getAbsolutePath(), "UTF-8", checksum ); } catch ( IOException e ) { throw new MojoExecutionException( "Failed to install checksum to " + checksumFile, e ); } }
java
private void installChecksum( File originalFile, File installedFile, Digester digester, String ext ) throws MojoExecutionException { String checksum; getLog().debug( "Calculating " + digester.getAlgorithm() + " checksum for " + originalFile ); try { checksum = digester.calc( originalFile ); } catch ( DigesterException e ) { throw new MojoExecutionException( "Failed to calculate " + digester.getAlgorithm() + " checksum for " + originalFile, e ); } File checksumFile = new File( installedFile.getAbsolutePath() + ext ); getLog().debug( "Installing checksum to " + checksumFile ); try { checksumFile.getParentFile().mkdirs(); FileUtils.fileWrite( checksumFile.getAbsolutePath(), "UTF-8", checksum ); } catch ( IOException e ) { throw new MojoExecutionException( "Failed to install checksum to " + checksumFile, e ); } }
[ "private", "void", "installChecksum", "(", "File", "originalFile", ",", "File", "installedFile", ",", "Digester", "digester", ",", "String", "ext", ")", "throws", "MojoExecutionException", "{", "String", "checksum", ";", "getLog", "(", ")", ".", "debug", "(", "\"Calculating \"", "+", "digester", ".", "getAlgorithm", "(", ")", "+", "\" checksum for \"", "+", "originalFile", ")", ";", "try", "{", "checksum", "=", "digester", ".", "calc", "(", "originalFile", ")", ";", "}", "catch", "(", "DigesterException", "e", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"Failed to calculate \"", "+", "digester", ".", "getAlgorithm", "(", ")", "+", "\" checksum for \"", "+", "originalFile", ",", "e", ")", ";", "}", "File", "checksumFile", "=", "new", "File", "(", "installedFile", ".", "getAbsolutePath", "(", ")", "+", "ext", ")", ";", "getLog", "(", ")", ".", "debug", "(", "\"Installing checksum to \"", "+", "checksumFile", ")", ";", "try", "{", "checksumFile", ".", "getParentFile", "(", ")", ".", "mkdirs", "(", ")", ";", "FileUtils", ".", "fileWrite", "(", "checksumFile", ".", "getAbsolutePath", "(", ")", ",", "\"UTF-8\"", ",", "checksum", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"Failed to install checksum to \"", "+", "checksumFile", ",", "e", ")", ";", "}", "}" ]
Installs a checksum for the specified file. @param originalFile The path to the file from which the checksum is generated, must not be <code>null</code>. @param installedFile The base path from which the path to the checksum files is derived by appending the given file extension, must not be <code>null</code>. @param digester The checksum algorithm to use, must not be <code>null</code>. @param ext The file extension (including the leading dot) to use for the checksum file, must not be <code>null</code>. @throws MojoExecutionException If the checksum could not be installed.
[ "Installs", "a", "checksum", "for", "the", "specified", "file", "." ]
350daa04831fb93a51a57a30009c572ade0a88bf
https://github.com/agaricusb/SpecialSourceMP/blob/350daa04831fb93a51a57a30009c572ade0a88bf/src/main/java/net/md_5/specialsource/mavenplugin/InstallRemappedFileMojo.java#L578-L604
151,011
adamfisk/dnsjava-fork
src/org/xbill/DNS/TSIG.java
TSIG.generate
public TSIGRecord generate(Message m, byte [] b, int error, TSIGRecord old) { Date timeSigned; if (error != Rcode.BADTIME) timeSigned = new Date(); else timeSigned = old.getTimeSigned(); int fudge; HMAC hmac = null; if (error == Rcode.NOERROR || error == Rcode.BADTIME) hmac = new HMAC(digest, digestBlockLength, key); fudge = Options.intValue("tsigfudge"); if (fudge < 0 || fudge > 0x7FFF) fudge = FUDGE; if (old != null) { DNSOutput out = new DNSOutput(); out.writeU16(old.getSignature().length); if (hmac != null) { hmac.update(out.toByteArray()); hmac.update(old.getSignature()); } } /* Digest the message */ if (hmac != null) hmac.update(b); DNSOutput out = new DNSOutput(); name.toWireCanonical(out); out.writeU16(DClass.ANY); /* class */ out.writeU32(0); /* ttl */ alg.toWireCanonical(out); long time = timeSigned.getTime() / 1000; int timeHigh = (int) (time >> 32); long timeLow = (time & 0xFFFFFFFFL); out.writeU16(timeHigh); out.writeU32(timeLow); out.writeU16(fudge); out.writeU16(error); out.writeU16(0); /* No other data */ if (hmac != null) hmac.update(out.toByteArray()); byte [] signature; if (hmac != null) signature = hmac.sign(); else signature = new byte[0]; byte [] other = null; if (error == Rcode.BADTIME) { out = new DNSOutput(); time = new Date().getTime() / 1000; timeHigh = (int) (time >> 32); timeLow = (time & 0xFFFFFFFFL); out.writeU16(timeHigh); out.writeU32(timeLow); other = out.toByteArray(); } return (new TSIGRecord(name, DClass.ANY, 0, alg, timeSigned, fudge, signature, m.getHeader().getID(), error, other)); }
java
public TSIGRecord generate(Message m, byte [] b, int error, TSIGRecord old) { Date timeSigned; if (error != Rcode.BADTIME) timeSigned = new Date(); else timeSigned = old.getTimeSigned(); int fudge; HMAC hmac = null; if (error == Rcode.NOERROR || error == Rcode.BADTIME) hmac = new HMAC(digest, digestBlockLength, key); fudge = Options.intValue("tsigfudge"); if (fudge < 0 || fudge > 0x7FFF) fudge = FUDGE; if (old != null) { DNSOutput out = new DNSOutput(); out.writeU16(old.getSignature().length); if (hmac != null) { hmac.update(out.toByteArray()); hmac.update(old.getSignature()); } } /* Digest the message */ if (hmac != null) hmac.update(b); DNSOutput out = new DNSOutput(); name.toWireCanonical(out); out.writeU16(DClass.ANY); /* class */ out.writeU32(0); /* ttl */ alg.toWireCanonical(out); long time = timeSigned.getTime() / 1000; int timeHigh = (int) (time >> 32); long timeLow = (time & 0xFFFFFFFFL); out.writeU16(timeHigh); out.writeU32(timeLow); out.writeU16(fudge); out.writeU16(error); out.writeU16(0); /* No other data */ if (hmac != null) hmac.update(out.toByteArray()); byte [] signature; if (hmac != null) signature = hmac.sign(); else signature = new byte[0]; byte [] other = null; if (error == Rcode.BADTIME) { out = new DNSOutput(); time = new Date().getTime() / 1000; timeHigh = (int) (time >> 32); timeLow = (time & 0xFFFFFFFFL); out.writeU16(timeHigh); out.writeU32(timeLow); other = out.toByteArray(); } return (new TSIGRecord(name, DClass.ANY, 0, alg, timeSigned, fudge, signature, m.getHeader().getID(), error, other)); }
[ "public", "TSIGRecord", "generate", "(", "Message", "m", ",", "byte", "[", "]", "b", ",", "int", "error", ",", "TSIGRecord", "old", ")", "{", "Date", "timeSigned", ";", "if", "(", "error", "!=", "Rcode", ".", "BADTIME", ")", "timeSigned", "=", "new", "Date", "(", ")", ";", "else", "timeSigned", "=", "old", ".", "getTimeSigned", "(", ")", ";", "int", "fudge", ";", "HMAC", "hmac", "=", "null", ";", "if", "(", "error", "==", "Rcode", ".", "NOERROR", "||", "error", "==", "Rcode", ".", "BADTIME", ")", "hmac", "=", "new", "HMAC", "(", "digest", ",", "digestBlockLength", ",", "key", ")", ";", "fudge", "=", "Options", ".", "intValue", "(", "\"tsigfudge\"", ")", ";", "if", "(", "fudge", "<", "0", "||", "fudge", ">", "0x7FFF", ")", "fudge", "=", "FUDGE", ";", "if", "(", "old", "!=", "null", ")", "{", "DNSOutput", "out", "=", "new", "DNSOutput", "(", ")", ";", "out", ".", "writeU16", "(", "old", ".", "getSignature", "(", ")", ".", "length", ")", ";", "if", "(", "hmac", "!=", "null", ")", "{", "hmac", ".", "update", "(", "out", ".", "toByteArray", "(", ")", ")", ";", "hmac", ".", "update", "(", "old", ".", "getSignature", "(", ")", ")", ";", "}", "}", "/* Digest the message */", "if", "(", "hmac", "!=", "null", ")", "hmac", ".", "update", "(", "b", ")", ";", "DNSOutput", "out", "=", "new", "DNSOutput", "(", ")", ";", "name", ".", "toWireCanonical", "(", "out", ")", ";", "out", ".", "writeU16", "(", "DClass", ".", "ANY", ")", ";", "/* class */", "out", ".", "writeU32", "(", "0", ")", ";", "/* ttl */", "alg", ".", "toWireCanonical", "(", "out", ")", ";", "long", "time", "=", "timeSigned", ".", "getTime", "(", ")", "/", "1000", ";", "int", "timeHigh", "=", "(", "int", ")", "(", "time", ">>", "32", ")", ";", "long", "timeLow", "=", "(", "time", "&", "0xFFFFFFFF", "L", ")", ";", "out", ".", "writeU16", "(", "timeHigh", ")", ";", "out", ".", "writeU32", "(", "timeLow", ")", ";", "out", ".", "writeU16", "(", "fudge", ")", ";", "out", ".", "writeU16", "(", "error", ")", ";", "out", ".", "writeU16", "(", "0", ")", ";", "/* No other data */", "if", "(", "hmac", "!=", "null", ")", "hmac", ".", "update", "(", "out", ".", "toByteArray", "(", ")", ")", ";", "byte", "[", "]", "signature", ";", "if", "(", "hmac", "!=", "null", ")", "signature", "=", "hmac", ".", "sign", "(", ")", ";", "else", "signature", "=", "new", "byte", "[", "0", "]", ";", "byte", "[", "]", "other", "=", "null", ";", "if", "(", "error", "==", "Rcode", ".", "BADTIME", ")", "{", "out", "=", "new", "DNSOutput", "(", ")", ";", "time", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", "/", "1000", ";", "timeHigh", "=", "(", "int", ")", "(", "time", ">>", "32", ")", ";", "timeLow", "=", "(", "time", "&", "0xFFFFFFFF", "L", ")", ";", "out", ".", "writeU16", "(", "timeHigh", ")", ";", "out", ".", "writeU32", "(", "timeLow", ")", ";", "other", "=", "out", ".", "toByteArray", "(", ")", ";", "}", "return", "(", "new", "TSIGRecord", "(", "name", ",", "DClass", ".", "ANY", ",", "0", ",", "alg", ",", "timeSigned", ",", "fudge", ",", "signature", ",", "m", ".", "getHeader", "(", ")", ".", "getID", "(", ")", ",", "error", ",", "other", ")", ")", ";", "}" ]
Generates a TSIG record with a specific error for a message that has been rendered. @param m The message @param b The rendered message @param error The error @param old If this message is a response, the TSIG from the request @return The TSIG record to be added to the message
[ "Generates", "a", "TSIG", "record", "with", "a", "specific", "error", "for", "a", "message", "that", "has", "been", "rendered", "." ]
69510a1cad0518badb19a6615724313bebc61f90
https://github.com/adamfisk/dnsjava-fork/blob/69510a1cad0518badb19a6615724313bebc61f90/src/org/xbill/DNS/TSIG.java#L210-L276
151,012
hawkular/hawkular-inventory
hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/model/ContentHash.java
ContentHash.of
public static String of(Entity.Blueprint entity, CanonicalPath entityPath) { return ComputeHash.of(InventoryStructure.of(entity).build(), entityPath, false, true, false).getContentHash(); }
java
public static String of(Entity.Blueprint entity, CanonicalPath entityPath) { return ComputeHash.of(InventoryStructure.of(entity).build(), entityPath, false, true, false).getContentHash(); }
[ "public", "static", "String", "of", "(", "Entity", ".", "Blueprint", "entity", ",", "CanonicalPath", "entityPath", ")", "{", "return", "ComputeHash", ".", "of", "(", "InventoryStructure", ".", "of", "(", "entity", ")", ".", "build", "(", ")", ",", "entityPath", ",", "false", ",", "true", ",", "false", ")", ".", "getContentHash", "(", ")", ";", "}" ]
The entity path is currently only required for resources, which base their content hash on the resource type path which can be specified using a relative or canonical path in the blueprint. For the content hash to be consistent we need to convert to just a single representation of the path. @param entity the entity to produce the hash of @param entityPath the canonical path of the entity (can be null for all but resources) @return the content hash of the entity
[ "The", "entity", "path", "is", "currently", "only", "required", "for", "resources", "which", "base", "their", "content", "hash", "on", "the", "resource", "type", "path", "which", "can", "be", "specified", "using", "a", "relative", "or", "canonical", "path", "in", "the", "blueprint", ".", "For", "the", "content", "hash", "to", "be", "consistent", "we", "need", "to", "convert", "to", "just", "a", "single", "representation", "of", "the", "path", "." ]
f56dc10323dca21777feb5b609a9e9cc70ffaf62
https://github.com/hawkular/hawkular-inventory/blob/f56dc10323dca21777feb5b609a9e9cc70ffaf62/hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/model/ContentHash.java#L54-L56
151,013
lkwg82/enforcer-rules
src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVersion.java
RequireJavaVersion.normalizeJDKVersion
public static String normalizeJDKVersion( String theJdkVersion ) { theJdkVersion = theJdkVersion.replaceAll( "_|-", "." ); String tokenArray[] = StringUtils.split( theJdkVersion, "." ); List<String> tokens = Arrays.asList( tokenArray ); StringBuffer buffer = new StringBuffer( theJdkVersion.length() ); Iterator<String> iter = tokens.iterator(); for ( int i = 0; i < tokens.size() && i < 4; i++ ) { String section = (String) iter.next(); section = section.replaceAll( "[^0-9]", "" ); if ( StringUtils.isNotEmpty( section ) ) { buffer.append( Integer.parseInt( section ) ); if ( i != 2 ) { buffer.append( '.' ); } else { buffer.append( '-' ); } } } String version = buffer.toString(); version = StringUtils.stripEnd( version, "-" ); return StringUtils.stripEnd( version, "." ); }
java
public static String normalizeJDKVersion( String theJdkVersion ) { theJdkVersion = theJdkVersion.replaceAll( "_|-", "." ); String tokenArray[] = StringUtils.split( theJdkVersion, "." ); List<String> tokens = Arrays.asList( tokenArray ); StringBuffer buffer = new StringBuffer( theJdkVersion.length() ); Iterator<String> iter = tokens.iterator(); for ( int i = 0; i < tokens.size() && i < 4; i++ ) { String section = (String) iter.next(); section = section.replaceAll( "[^0-9]", "" ); if ( StringUtils.isNotEmpty( section ) ) { buffer.append( Integer.parseInt( section ) ); if ( i != 2 ) { buffer.append( '.' ); } else { buffer.append( '-' ); } } } String version = buffer.toString(); version = StringUtils.stripEnd( version, "-" ); return StringUtils.stripEnd( version, "." ); }
[ "public", "static", "String", "normalizeJDKVersion", "(", "String", "theJdkVersion", ")", "{", "theJdkVersion", "=", "theJdkVersion", ".", "replaceAll", "(", "\"_|-\"", ",", "\".\"", ")", ";", "String", "tokenArray", "[", "]", "=", "StringUtils", ".", "split", "(", "theJdkVersion", ",", "\".\"", ")", ";", "List", "<", "String", ">", "tokens", "=", "Arrays", ".", "asList", "(", "tokenArray", ")", ";", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", "theJdkVersion", ".", "length", "(", ")", ")", ";", "Iterator", "<", "String", ">", "iter", "=", "tokens", ".", "iterator", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "tokens", ".", "size", "(", ")", "&&", "i", "<", "4", ";", "i", "++", ")", "{", "String", "section", "=", "(", "String", ")", "iter", ".", "next", "(", ")", ";", "section", "=", "section", ".", "replaceAll", "(", "\"[^0-9]\"", ",", "\"\"", ")", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "section", ")", ")", "{", "buffer", ".", "append", "(", "Integer", ".", "parseInt", "(", "section", ")", ")", ";", "if", "(", "i", "!=", "2", ")", "{", "buffer", ".", "append", "(", "'", "'", ")", ";", "}", "else", "{", "buffer", ".", "append", "(", "'", "'", ")", ";", "}", "}", "}", "String", "version", "=", "buffer", ".", "toString", "(", ")", ";", "version", "=", "StringUtils", ".", "stripEnd", "(", "version", ",", "\"-\"", ")", ";", "return", "StringUtils", ".", "stripEnd", "(", "version", ",", "\".\"", ")", ";", "}" ]
Converts a jdk string from 1.5.0-11b12 to a single 3 digit version like 1.5.0-11 @param theJdkVersion to be converted. @return the converted string.
[ "Converts", "a", "jdk", "string", "from", "1", ".", "5", ".", "0", "-", "11b12", "to", "a", "single", "3", "digit", "version", "like", "1", ".", "5", ".", "0", "-", "11" ]
fa2d309af7907b17fc8eaf386f8056d77b654749
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVersion.java#L74-L106
151,014
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/event/SimpleEvent.java
SimpleEvent.fire
public void fire() { ArrayList<Runnable> listeners; synchronized (this) { if (this.listeners == null) return; listeners = new ArrayList<>(this.listeners); } for (int i = 0; i < listeners.size(); ++i) listeners.get(i).run(); }
java
public void fire() { ArrayList<Runnable> listeners; synchronized (this) { if (this.listeners == null) return; listeners = new ArrayList<>(this.listeners); } for (int i = 0; i < listeners.size(); ++i) listeners.get(i).run(); }
[ "public", "void", "fire", "(", ")", "{", "ArrayList", "<", "Runnable", ">", "listeners", ";", "synchronized", "(", "this", ")", "{", "if", "(", "this", ".", "listeners", "==", "null", ")", "return", ";", "listeners", "=", "new", "ArrayList", "<>", "(", "this", ".", "listeners", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeners", ".", "size", "(", ")", ";", "++", "i", ")", "listeners", ".", "get", "(", "i", ")", ".", "run", "(", ")", ";", "}" ]
Fire this event, or in other words call the listeners.
[ "Fire", "this", "event", "or", "in", "other", "words", "call", "the", "listeners", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/event/SimpleEvent.java#L30-L38
151,015
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/io/buffering/ByteBuffersIO.java
ByteBuffersIO.createSingleByteArray
public byte[] createSingleByteArray() { byte[] buf = new byte[totalSize]; int pos = 0; for (Triple<byte[],Integer,Integer> t : buffers) { System.arraycopy(t.getValue1(), t.getValue2().intValue(), buf, pos, t.getValue3().intValue()); pos += t.getValue3().intValue(); } return buf; }
java
public byte[] createSingleByteArray() { byte[] buf = new byte[totalSize]; int pos = 0; for (Triple<byte[],Integer,Integer> t : buffers) { System.arraycopy(t.getValue1(), t.getValue2().intValue(), buf, pos, t.getValue3().intValue()); pos += t.getValue3().intValue(); } return buf; }
[ "public", "byte", "[", "]", "createSingleByteArray", "(", ")", "{", "byte", "[", "]", "buf", "=", "new", "byte", "[", "totalSize", "]", ";", "int", "pos", "=", "0", ";", "for", "(", "Triple", "<", "byte", "[", "]", ",", "Integer", ",", "Integer", ">", "t", ":", "buffers", ")", "{", "System", ".", "arraycopy", "(", "t", ".", "getValue1", "(", ")", ",", "t", ".", "getValue2", "(", ")", ".", "intValue", "(", ")", ",", "buf", ",", "pos", ",", "t", ".", "getValue3", "(", ")", ".", "intValue", "(", ")", ")", ";", "pos", "+=", "t", ".", "getValue3", "(", ")", ".", "intValue", "(", ")", ";", "}", "return", "buf", ";", "}" ]
Merge the byte arrays of this class into a single one and return it.
[ "Merge", "the", "byte", "arrays", "of", "this", "class", "into", "a", "single", "one", "and", "return", "it", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/io/buffering/ByteBuffersIO.java#L51-L59
151,016
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/io/buffering/ByteBuffersIO.java
ByteBuffersIO.addBuffer
public synchronized void addBuffer(byte[] buf, int off, int len) { if (copyBuffers) { byte[] b = new byte[len]; System.arraycopy(buf, off, b, 0, len); buf = b; off = 0; } buffers.add(new Triple<>(buf, Integer.valueOf(off), Integer.valueOf(len))); totalSize += len; }
java
public synchronized void addBuffer(byte[] buf, int off, int len) { if (copyBuffers) { byte[] b = new byte[len]; System.arraycopy(buf, off, b, 0, len); buf = b; off = 0; } buffers.add(new Triple<>(buf, Integer.valueOf(off), Integer.valueOf(len))); totalSize += len; }
[ "public", "synchronized", "void", "addBuffer", "(", "byte", "[", "]", "buf", ",", "int", "off", ",", "int", "len", ")", "{", "if", "(", "copyBuffers", ")", "{", "byte", "[", "]", "b", "=", "new", "byte", "[", "len", "]", ";", "System", ".", "arraycopy", "(", "buf", ",", "off", ",", "b", ",", "0", ",", "len", ")", ";", "buf", "=", "b", ";", "off", "=", "0", ";", "}", "buffers", ".", "add", "(", "new", "Triple", "<>", "(", "buf", ",", "Integer", ".", "valueOf", "(", "off", ")", ",", "Integer", ".", "valueOf", "(", "len", ")", ")", ")", ";", "totalSize", "+=", "len", ";", "}" ]
Append the given buffer.
[ "Append", "the", "given", "buffer", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/io/buffering/ByteBuffersIO.java#L62-L71
151,017
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/util/PropertiesUtil.java
PropertiesUtil.resolve
public static String resolve(String value, Map<String, String> properties) { do { int i = value.indexOf("${"); if (i < 0) return value; int j = value.indexOf('}', i + 2); if (j < 0) return value; String name = value.substring(i + 2, j); String val = properties.get(name); if (val == null) val = ""; value = value.substring(0, i) + val + value.substring(j + 1); } while (true); }
java
public static String resolve(String value, Map<String, String> properties) { do { int i = value.indexOf("${"); if (i < 0) return value; int j = value.indexOf('}', i + 2); if (j < 0) return value; String name = value.substring(i + 2, j); String val = properties.get(name); if (val == null) val = ""; value = value.substring(0, i) + val + value.substring(j + 1); } while (true); }
[ "public", "static", "String", "resolve", "(", "String", "value", ",", "Map", "<", "String", ",", "String", ">", "properties", ")", "{", "do", "{", "int", "i", "=", "value", ".", "indexOf", "(", "\"${\"", ")", ";", "if", "(", "i", "<", "0", ")", "return", "value", ";", "int", "j", "=", "value", ".", "indexOf", "(", "'", "'", ",", "i", "+", "2", ")", ";", "if", "(", "j", "<", "0", ")", "return", "value", ";", "String", "name", "=", "value", ".", "substring", "(", "i", "+", "2", ",", "j", ")", ";", "String", "val", "=", "properties", ".", "get", "(", "name", ")", ";", "if", "(", "val", "==", "null", ")", "val", "=", "\"\"", ";", "value", "=", "value", ".", "substring", "(", "0", ",", "i", ")", "+", "val", "+", "value", ".", "substring", "(", "j", "+", "1", ")", ";", "}", "while", "(", "true", ")", ";", "}" ]
Resolve the given value with the given properties.
[ "Resolve", "the", "given", "value", "with", "the", "given", "properties", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/util/PropertiesUtil.java#L34-L45
151,018
livetribe/livetribe-slp
core/src/main/java/org/livetribe/slp/spi/ServiceInfoCache.java
ServiceInfoCache.put
public Result<T> put(T service) { check(service); ServiceType serviceType = service.resolveServiceType(); T previous = null; lock(); try { ServiceType existingServiceType = keysToServiceTypes.get(service.getKey()); if (existingServiceType != null && !existingServiceType.equals(serviceType)) throw new ServiceLocationException("Invalid registration of service " + service.getKey() + ": already registered under service type " + existingServiceType + ", cannot be registered also under service type " + serviceType, SLPError.INVALID_REGISTRATION); keysToServiceTypes.put(service.getKey(), serviceType); previous = keysToServiceInfos.put(service.getKey(), service); service.setRegistered(true); if (previous != null) previous.setRegistered(false); } finally { unlock(); } notifyServiceAdded(previous, service); return new Result<T>(previous, service); }
java
public Result<T> put(T service) { check(service); ServiceType serviceType = service.resolveServiceType(); T previous = null; lock(); try { ServiceType existingServiceType = keysToServiceTypes.get(service.getKey()); if (existingServiceType != null && !existingServiceType.equals(serviceType)) throw new ServiceLocationException("Invalid registration of service " + service.getKey() + ": already registered under service type " + existingServiceType + ", cannot be registered also under service type " + serviceType, SLPError.INVALID_REGISTRATION); keysToServiceTypes.put(service.getKey(), serviceType); previous = keysToServiceInfos.put(service.getKey(), service); service.setRegistered(true); if (previous != null) previous.setRegistered(false); } finally { unlock(); } notifyServiceAdded(previous, service); return new Result<T>(previous, service); }
[ "public", "Result", "<", "T", ">", "put", "(", "T", "service", ")", "{", "check", "(", "service", ")", ";", "ServiceType", "serviceType", "=", "service", ".", "resolveServiceType", "(", ")", ";", "T", "previous", "=", "null", ";", "lock", "(", ")", ";", "try", "{", "ServiceType", "existingServiceType", "=", "keysToServiceTypes", ".", "get", "(", "service", ".", "getKey", "(", ")", ")", ";", "if", "(", "existingServiceType", "!=", "null", "&&", "!", "existingServiceType", ".", "equals", "(", "serviceType", ")", ")", "throw", "new", "ServiceLocationException", "(", "\"Invalid registration of service \"", "+", "service", ".", "getKey", "(", ")", "+", "\": already registered under service type \"", "+", "existingServiceType", "+", "\", cannot be registered also under service type \"", "+", "serviceType", ",", "SLPError", ".", "INVALID_REGISTRATION", ")", ";", "keysToServiceTypes", ".", "put", "(", "service", ".", "getKey", "(", ")", ",", "serviceType", ")", ";", "previous", "=", "keysToServiceInfos", ".", "put", "(", "service", ".", "getKey", "(", ")", ",", "service", ")", ";", "service", ".", "setRegistered", "(", "true", ")", ";", "if", "(", "previous", "!=", "null", ")", "previous", ".", "setRegistered", "(", "false", ")", ";", "}", "finally", "{", "unlock", "(", ")", ";", "}", "notifyServiceAdded", "(", "previous", ",", "service", ")", ";", "return", "new", "Result", "<", "T", ">", "(", "previous", ",", "service", ")", ";", "}" ]
Adds the given service to this cache replacing an eventually existing entry. @param service The service to cache @return a result whose previous is the replaced service and where current is the given service
[ "Adds", "the", "given", "service", "to", "this", "cache", "replacing", "an", "eventually", "existing", "entry", "." ]
6cc13dbe81feab133fe3dd291ca081cbc6e1f591
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/spi/ServiceInfoCache.java#L119-L146
151,019
livetribe/livetribe-slp
core/src/main/java/org/livetribe/slp/spi/ServiceInfoCache.java
ServiceInfoCache.addAttributes
public Result<T> addAttributes(ServiceInfo.Key key, Attributes attributes) { T previous = null; T current = null; lock(); try { previous = get(key); // Updating a service that does not exist must fail (RFC 2608, 9.3) if (previous == null) throw new ServiceLocationException("Could not find service to update " + key, SLPError.INVALID_UPDATE); current = (T)previous.addAttributes(attributes); keysToServiceInfos.put(current.getKey(), current); current.setRegistered(true); previous.setRegistered(false); } finally { unlock(); } notifyServiceUpdated(previous, current); return new Result<T>(previous, current); }
java
public Result<T> addAttributes(ServiceInfo.Key key, Attributes attributes) { T previous = null; T current = null; lock(); try { previous = get(key); // Updating a service that does not exist must fail (RFC 2608, 9.3) if (previous == null) throw new ServiceLocationException("Could not find service to update " + key, SLPError.INVALID_UPDATE); current = (T)previous.addAttributes(attributes); keysToServiceInfos.put(current.getKey(), current); current.setRegistered(true); previous.setRegistered(false); } finally { unlock(); } notifyServiceUpdated(previous, current); return new Result<T>(previous, current); }
[ "public", "Result", "<", "T", ">", "addAttributes", "(", "ServiceInfo", ".", "Key", "key", ",", "Attributes", "attributes", ")", "{", "T", "previous", "=", "null", ";", "T", "current", "=", "null", ";", "lock", "(", ")", ";", "try", "{", "previous", "=", "get", "(", "key", ")", ";", "// Updating a service that does not exist must fail (RFC 2608, 9.3)", "if", "(", "previous", "==", "null", ")", "throw", "new", "ServiceLocationException", "(", "\"Could not find service to update \"", "+", "key", ",", "SLPError", ".", "INVALID_UPDATE", ")", ";", "current", "=", "(", "T", ")", "previous", ".", "addAttributes", "(", "attributes", ")", ";", "keysToServiceInfos", ".", "put", "(", "current", ".", "getKey", "(", ")", ",", "current", ")", ";", "current", ".", "setRegistered", "(", "true", ")", ";", "previous", ".", "setRegistered", "(", "false", ")", ";", "}", "finally", "{", "unlock", "(", ")", ";", "}", "notifyServiceUpdated", "(", "previous", ",", "current", ")", ";", "return", "new", "Result", "<", "T", ">", "(", "previous", ",", "current", ")", ";", "}" ]
Updates an existing ServiceInfo identified by the given Key, adding the given attributes. @param key the service's key @param attributes the attributes to add @return a result whose previous is the service prior the update and where current is the current service
[ "Updates", "an", "existing", "ServiceInfo", "identified", "by", "the", "given", "Key", "adding", "the", "given", "attributes", "." ]
6cc13dbe81feab133fe3dd291ca081cbc6e1f591
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/spi/ServiceInfoCache.java#L185-L210
151,020
livetribe/livetribe-slp
core/src/main/java/org/livetribe/slp/spi/ServiceInfoCache.java
ServiceInfoCache.purge
public List<T> purge() { List<T> result = new ArrayList<T>(); long now = System.currentTimeMillis(); lock(); try { for (T serviceInfo : getServiceInfos()) { if (serviceInfo.isExpiredAsOf(now)) { T purged = remove(serviceInfo.getKey()).getPrevious(); if (purged != null) result.add(purged); } } return result; } finally { unlock(); } }
java
public List<T> purge() { List<T> result = new ArrayList<T>(); long now = System.currentTimeMillis(); lock(); try { for (T serviceInfo : getServiceInfos()) { if (serviceInfo.isExpiredAsOf(now)) { T purged = remove(serviceInfo.getKey()).getPrevious(); if (purged != null) result.add(purged); } } return result; } finally { unlock(); } }
[ "public", "List", "<", "T", ">", "purge", "(", ")", "{", "List", "<", "T", ">", "result", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "long", "now", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "lock", "(", ")", ";", "try", "{", "for", "(", "T", "serviceInfo", ":", "getServiceInfos", "(", ")", ")", "{", "if", "(", "serviceInfo", ".", "isExpiredAsOf", "(", "now", ")", ")", "{", "T", "purged", "=", "remove", "(", "serviceInfo", ".", "getKey", "(", ")", ")", ".", "getPrevious", "(", ")", ";", "if", "(", "purged", "!=", "null", ")", "result", ".", "add", "(", "purged", ")", ";", "}", "}", "return", "result", ";", "}", "finally", "{", "unlock", "(", ")", ";", "}", "}" ]
Purges from this cache entries whose registration time plus their lifetime is less than the current time; that is, entries that should have been renewed but for some reason they have not been. @return The list of purged entries.
[ "Purges", "from", "this", "cache", "entries", "whose", "registration", "time", "plus", "their", "lifetime", "is", "less", "than", "the", "current", "time", ";", "that", "is", "entries", "that", "should", "have", "been", "renewed", "but", "for", "some", "reason", "they", "have", "not", "been", "." ]
6cc13dbe81feab133fe3dd291ca081cbc6e1f591
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/spi/ServiceInfoCache.java#L347-L368
151,021
hawkular/hawkular-inventory
hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/Query.java
Query.filters
private static Filter[] filters(QueryFragment... fragments) { Filter[] ret = new Filter[fragments.length]; for (int i = 0; i < fragments.length; ++i) { ret[i] = fragments[i].getFilter(); } return ret; }
java
private static Filter[] filters(QueryFragment... fragments) { Filter[] ret = new Filter[fragments.length]; for (int i = 0; i < fragments.length; ++i) { ret[i] = fragments[i].getFilter(); } return ret; }
[ "private", "static", "Filter", "[", "]", "filters", "(", "QueryFragment", "...", "fragments", ")", "{", "Filter", "[", "]", "ret", "=", "new", "Filter", "[", "fragments", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "fragments", ".", "length", ";", "++", "i", ")", "{", "ret", "[", "i", "]", "=", "fragments", "[", "i", "]", ".", "getFilter", "(", ")", ";", "}", "return", "ret", ";", "}" ]
Converts the list of applicators to the list of filters. @param fragments the list of applicators @return the list of corresponding filters
[ "Converts", "the", "list", "of", "applicators", "to", "the", "list", "of", "filters", "." ]
f56dc10323dca21777feb5b609a9e9cc70ffaf62
https://github.com/hawkular/hawkular-inventory/blob/f56dc10323dca21777feb5b609a9e9cc70ffaf62/hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/Query.java#L54-L62
151,022
hawkular/hawkular-inventory
hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/Query.java
Builder.branch
public Builder branch() { if (fragments.isEmpty()) { fragments.add(new PathFragment(new NoopFilter())); } Builder child = new Builder(); child.parent = this; children.add(child); return child; }
java
public Builder branch() { if (fragments.isEmpty()) { fragments.add(new PathFragment(new NoopFilter())); } Builder child = new Builder(); child.parent = this; children.add(child); return child; }
[ "public", "Builder", "branch", "(", ")", "{", "if", "(", "fragments", ".", "isEmpty", "(", ")", ")", "{", "fragments", ".", "add", "(", "new", "PathFragment", "(", "new", "NoopFilter", "(", ")", ")", ")", ";", "}", "Builder", "child", "=", "new", "Builder", "(", ")", ";", "child", ".", "parent", "=", "this", ";", "children", ".", "add", "(", "child", ")", ";", "return", "child", ";", "}" ]
Creates a new branch in the tree and returns a builder of that branch. @return a new builder instance for building the child
[ "Creates", "a", "new", "branch", "in", "the", "tree", "and", "returns", "a", "builder", "of", "that", "branch", "." ]
f56dc10323dca21777feb5b609a9e9cc70ffaf62
https://github.com/hawkular/hawkular-inventory/blob/f56dc10323dca21777feb5b609a9e9cc70ffaf62/hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/Query.java#L250-L260
151,023
hawkular/hawkular-inventory
hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/Query.java
Builder.done
public Builder done() { if (done) { return parent; } this.tree.fragments = fragments.toArray(new QueryFragment[fragments.size()]); if (parent != null) { parent.tree.subTrees.add(this.tree); parent.children.remove(this); } //done will remove the child from the children, so we'd get concurrent modification exceptions //avoid that stupidly by working on a copy of children new ArrayList<>(children).forEach(Query.Builder::done); done = true; return parent; }
java
public Builder done() { if (done) { return parent; } this.tree.fragments = fragments.toArray(new QueryFragment[fragments.size()]); if (parent != null) { parent.tree.subTrees.add(this.tree); parent.children.remove(this); } //done will remove the child from the children, so we'd get concurrent modification exceptions //avoid that stupidly by working on a copy of children new ArrayList<>(children).forEach(Query.Builder::done); done = true; return parent; }
[ "public", "Builder", "done", "(", ")", "{", "if", "(", "done", ")", "{", "return", "parent", ";", "}", "this", ".", "tree", ".", "fragments", "=", "fragments", ".", "toArray", "(", "new", "QueryFragment", "[", "fragments", ".", "size", "(", ")", "]", ")", ";", "if", "(", "parent", "!=", "null", ")", "{", "parent", ".", "tree", ".", "subTrees", ".", "add", "(", "this", ".", "tree", ")", ";", "parent", ".", "children", ".", "remove", "(", "this", ")", ";", "}", "//done will remove the child from the children, so we'd get concurrent modification exceptions", "//avoid that stupidly by working on a copy of children", "new", "ArrayList", "<>", "(", "children", ")", ".", "forEach", "(", "Query", ".", "Builder", "::", "done", ")", ";", "done", "=", "true", ";", "return", "parent", ";", "}" ]
Concludes the work on a branch and returns a builder of the parent "node", if any. @return the parent builder
[ "Concludes", "the", "work", "on", "a", "branch", "and", "returns", "a", "builder", "of", "the", "parent", "node", "if", "any", "." ]
f56dc10323dca21777feb5b609a9e9cc70ffaf62
https://github.com/hawkular/hawkular-inventory/blob/f56dc10323dca21777feb5b609a9e9cc70ffaf62/hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/Query.java#L266-L284
151,024
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElementBase.java
XElementBase.parseDateTime
public static OffsetDateTime parseDateTime(String date) throws ParseException { return DATE_TIME_OPTIONAL_OFFSET.withZone(ZoneOffset.UTC).parse(date, OffsetDateTime::from); }
java
public static OffsetDateTime parseDateTime(String date) throws ParseException { return DATE_TIME_OPTIONAL_OFFSET.withZone(ZoneOffset.UTC).parse(date, OffsetDateTime::from); }
[ "public", "static", "OffsetDateTime", "parseDateTime", "(", "String", "date", ")", "throws", "ParseException", "{", "return", "DATE_TIME_OPTIONAL_OFFSET", ".", "withZone", "(", "ZoneOffset", ".", "UTC", ")", ".", "parse", "(", "date", ",", "OffsetDateTime", "::", "from", ")", ";", "}" ]
Parse an XSD dateTime. @param date the date string @return the date @throws ParseException format exception
[ "Parse", "an", "XSD", "dateTime", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElementBase.java#L59-L61
151,025
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElementBase.java
XElementBase.sanitize
public static String sanitize(String s) { if (s != null) { StringBuilder b = new StringBuilder(s.length()); for (int i = 0, count = s.length(); i < count; i++) { char c = s.charAt(i); switch (c) { case '<': b.append("&lt;"); break; case '>': b.append("&gt;"); break; case '\'': b.append("&#39;"); break; case '"': b.append("&quot;"); break; case '&': b.append("&amp;"); break; default: b.append(c); } } return b.toString(); } return ""; }
java
public static String sanitize(String s) { if (s != null) { StringBuilder b = new StringBuilder(s.length()); for (int i = 0, count = s.length(); i < count; i++) { char c = s.charAt(i); switch (c) { case '<': b.append("&lt;"); break; case '>': b.append("&gt;"); break; case '\'': b.append("&#39;"); break; case '"': b.append("&quot;"); break; case '&': b.append("&amp;"); break; default: b.append(c); } } return b.toString(); } return ""; }
[ "public", "static", "String", "sanitize", "(", "String", "s", ")", "{", "if", "(", "s", "!=", "null", ")", "{", "StringBuilder", "b", "=", "new", "StringBuilder", "(", "s", ".", "length", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ",", "count", "=", "s", ".", "length", "(", ")", ";", "i", "<", "count", ";", "i", "++", ")", "{", "char", "c", "=", "s", ".", "charAt", "(", "i", ")", ";", "switch", "(", "c", ")", "{", "case", "'", "'", ":", "b", ".", "append", "(", "\"&lt;\"", ")", ";", "break", ";", "case", "'", "'", ":", "b", ".", "append", "(", "\"&gt;\"", ")", ";", "break", ";", "case", "'", "'", ":", "b", ".", "append", "(", "\"&#39;\"", ")", ";", "break", ";", "case", "'", "'", ":", "b", ".", "append", "(", "\"&quot;\"", ")", ";", "break", ";", "case", "'", "'", ":", "b", ".", "append", "(", "\"&amp;\"", ")", ";", "break", ";", "default", ":", "b", ".", "append", "(", "c", ")", ";", "}", "}", "return", "b", ".", "toString", "(", ")", ";", "}", "return", "\"\"", ";", "}" ]
Converts all sensitive characters to its HTML entity equivalent. @param s the string to convert, can be null @return the converted string, or an empty string
[ "Converts", "all", "sensitive", "characters", "to", "its", "HTML", "entity", "equivalent", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElementBase.java#L67-L95
151,026
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElementBase.java
XElementBase.doubleValue
public double doubleValue(String name) { String s = childValue(name); if (s != null) { return Double.parseDouble(s); } throw new IllegalArgumentException(this + ": content: " + name); }
java
public double doubleValue(String name) { String s = childValue(name); if (s != null) { return Double.parseDouble(s); } throw new IllegalArgumentException(this + ": content: " + name); }
[ "public", "double", "doubleValue", "(", "String", "name", ")", "{", "String", "s", "=", "childValue", "(", "name", ")", ";", "if", "(", "s", "!=", "null", ")", "{", "return", "Double", ".", "parseDouble", "(", "s", ")", ";", "}", "throw", "new", "IllegalArgumentException", "(", "this", "+", "\": content: \"", "+", "name", ")", ";", "}" ]
Returns a double value of the supplied child or throws an exception if missing. @param name the child element name @return the value
[ "Returns", "a", "double", "value", "of", "the", "supplied", "child", "or", "throws", "an", "exception", "if", "missing", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElementBase.java#L164-L170
151,027
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElementBase.java
XElementBase.setValue
public final void setValue(Object value) { if (value instanceof Date) { content = formatDateTime((Date)value); } else if (value != null) { content = value.toString(); } else { content = null; } }
java
public final void setValue(Object value) { if (value instanceof Date) { content = formatDateTime((Date)value); } else if (value != null) { content = value.toString(); } else { content = null; } }
[ "public", "final", "void", "setValue", "(", "Object", "value", ")", "{", "if", "(", "value", "instanceof", "Date", ")", "{", "content", "=", "formatDateTime", "(", "(", "Date", ")", "value", ")", ";", "}", "else", "if", "(", "value", "!=", "null", ")", "{", "content", "=", "value", ".", "toString", "(", ")", ";", "}", "else", "{", "content", "=", "null", ";", "}", "}" ]
Sets or clears the content of this element. @param value the value set or null to clear
[ "Sets", "or", "clears", "the", "content", "of", "this", "element", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElementBase.java#L194-L203
151,028
jtrfp/javamod
src/main/java/de/quippy/jflac/util/CRC8.java
CRC8.updateBlock
public static byte updateBlock(byte[] data, int len, byte crc) { for (int i = 0; i < len; i++) crc = CRC8_TABLE[crc ^ data[i]]; return crc; }
java
public static byte updateBlock(byte[] data, int len, byte crc) { for (int i = 0; i < len; i++) crc = CRC8_TABLE[crc ^ data[i]]; return crc; }
[ "public", "static", "byte", "updateBlock", "(", "byte", "[", "]", "data", ",", "int", "len", ",", "byte", "crc", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "crc", "=", "CRC8_TABLE", "[", "crc", "^", "data", "[", "i", "]", "]", ";", "return", "crc", ";", "}" ]
Update the CRC value with data from a byte array. @param data The byte array @param len The byte array length @param crc The starting CRC value @return The updated CRC value
[ "Update", "the", "CRC", "value", "with", "data", "from", "a", "byte", "array", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/jflac/util/CRC8.java#L308-L312
151,029
jtrfp/javamod
src/main/java/de/quippy/jflac/util/CRC8.java
CRC8.calc
public static byte calc(byte[] data, int len) { byte crc = 0; for (int i = 0; i < len; i++) crc = CRC8_TABLE[(crc ^ data[i]) & 0xff]; return crc; }
java
public static byte calc(byte[] data, int len) { byte crc = 0; for (int i = 0; i < len; i++) crc = CRC8_TABLE[(crc ^ data[i]) & 0xff]; return crc; }
[ "public", "static", "byte", "calc", "(", "byte", "[", "]", "data", ",", "int", "len", ")", "{", "byte", "crc", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "crc", "=", "CRC8_TABLE", "[", "(", "crc", "^", "data", "[", "i", "]", ")", "&", "0xff", "]", ";", "return", "crc", ";", "}" ]
Calculate the CRC value with data from a byte array. @param data The byte array @param len The byte array length @return The calculated CRC value
[ "Calculate", "the", "CRC", "value", "with", "data", "from", "a", "byte", "array", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/jflac/util/CRC8.java#L321-L328
151,030
jtrfp/javamod
src/main/java/de/quippy/javamod/mixer/dsp/AudioProcessor.java
AudioProcessor.writeSampleData
public int writeSampleData(final byte [] newSampleData, final int offset, int length) { synchronized(lock) { System.arraycopy(newSampleData, offset, resultSampleBuffer, 0, length); int anzSamples = writeIntoFloatArrayBuffer(length); if (dspEnabled) { // call the callbacks for digital signal processing // ... anzSamples = callEffects(sampleBuffer, currentWritePosition, anzSamples); // and recalc from the float array... length = readFromFloatArrayBuffer(anzSamples); } currentWritePosition = (currentWritePosition + anzSamples) % sampleBufferSize; return length; } }
java
public int writeSampleData(final byte [] newSampleData, final int offset, int length) { synchronized(lock) { System.arraycopy(newSampleData, offset, resultSampleBuffer, 0, length); int anzSamples = writeIntoFloatArrayBuffer(length); if (dspEnabled) { // call the callbacks for digital signal processing // ... anzSamples = callEffects(sampleBuffer, currentWritePosition, anzSamples); // and recalc from the float array... length = readFromFloatArrayBuffer(anzSamples); } currentWritePosition = (currentWritePosition + anzSamples) % sampleBufferSize; return length; } }
[ "public", "int", "writeSampleData", "(", "final", "byte", "[", "]", "newSampleData", ",", "final", "int", "offset", ",", "int", "length", ")", "{", "synchronized", "(", "lock", ")", "{", "System", ".", "arraycopy", "(", "newSampleData", ",", "offset", ",", "resultSampleBuffer", ",", "0", ",", "length", ")", ";", "int", "anzSamples", "=", "writeIntoFloatArrayBuffer", "(", "length", ")", ";", "if", "(", "dspEnabled", ")", "{", "// call the callbacks for digital signal processing", "// ...", "anzSamples", "=", "callEffects", "(", "sampleBuffer", ",", "currentWritePosition", ",", "anzSamples", ")", ";", "// and recalc from the float array...", "length", "=", "readFromFloatArrayBuffer", "(", "anzSamples", ")", ";", "}", "currentWritePosition", "=", "(", "currentWritePosition", "+", "anzSamples", ")", "%", "sampleBufferSize", ";", "return", "length", ";", "}", "}" ]
This method will write the sample data to the dsp buffer It will convert all sampledata to a stereo or mono float of 1.0<=x<=-1.0 @since 23.12.2011 @param newSampleData @param offset @param length
[ "This", "method", "will", "write", "the", "sample", "data", "to", "the", "dsp", "buffer", "It", "will", "convert", "all", "sampledata", "to", "a", "stereo", "or", "mono", "float", "of", "1", ".", "0<", "=", "x<", "=", "-", "1", ".", "0" ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/javamod/mixer/dsp/AudioProcessor.java#L409-L426
151,031
GerdHolz/TOVAL
src/de/invation/code/toval/misc/MapUtils.java
MapUtils.getFormat
private static String getFormat(Map<?, ?> map, int keyPrecision, int valuePrecision) { StringBuilder builder = new StringBuilder(); builder.append('{'); int mappings = map.keySet().size(); int c = 0; for (Object key : map.keySet()) { c++; builder.append(FormatUtils.getIndexedFormat(c, FormatUtils.getFormat(key, keyPrecision).substring(1))); builder.append(VALUE_MAPPING); builder.append( FormatUtils.getIndexedFormat(mappings + c, FormatUtils.getFormat(map.get(key), valuePrecision).substring(1))); if (c < mappings) builder.append(VALUE_SEPARATION); } builder.append('}'); return builder.toString(); }
java
private static String getFormat(Map<?, ?> map, int keyPrecision, int valuePrecision) { StringBuilder builder = new StringBuilder(); builder.append('{'); int mappings = map.keySet().size(); int c = 0; for (Object key : map.keySet()) { c++; builder.append(FormatUtils.getIndexedFormat(c, FormatUtils.getFormat(key, keyPrecision).substring(1))); builder.append(VALUE_MAPPING); builder.append( FormatUtils.getIndexedFormat(mappings + c, FormatUtils.getFormat(map.get(key), valuePrecision).substring(1))); if (c < mappings) builder.append(VALUE_SEPARATION); } builder.append('}'); return builder.toString(); }
[ "private", "static", "String", "getFormat", "(", "Map", "<", "?", ",", "?", ">", "map", ",", "int", "keyPrecision", ",", "int", "valuePrecision", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "builder", ".", "append", "(", "'", "'", ")", ";", "int", "mappings", "=", "map", ".", "keySet", "(", ")", ".", "size", "(", ")", ";", "int", "c", "=", "0", ";", "for", "(", "Object", "key", ":", "map", ".", "keySet", "(", ")", ")", "{", "c", "++", ";", "builder", ".", "append", "(", "FormatUtils", ".", "getIndexedFormat", "(", "c", ",", "FormatUtils", ".", "getFormat", "(", "key", ",", "keyPrecision", ")", ".", "substring", "(", "1", ")", ")", ")", ";", "builder", ".", "append", "(", "VALUE_MAPPING", ")", ";", "builder", ".", "append", "(", "FormatUtils", ".", "getIndexedFormat", "(", "mappings", "+", "c", ",", "FormatUtils", ".", "getFormat", "(", "map", ".", "get", "(", "key", ")", ",", "valuePrecision", ")", ".", "substring", "(", "1", ")", ")", ")", ";", "if", "(", "c", "<", "mappings", ")", "builder", ".", "append", "(", "VALUE_SEPARATION", ")", ";", "}", "builder", ".", "append", "(", "'", "'", ")", ";", "return", "builder", ".", "toString", "(", ")", ";", "}" ]
Returns a format-String that can be used to generate a String representation of a map using the String.format method. @param map Map for which a String representation is desired @param keyPrecision Desired precision for <code>Float</code> and <code>Double</code> elements @param valuePrecision Desired precision for <code>Float</code> and <code>Double</code> elements @return Format-String for <code>map</code> @see String#format(String, Object...)
[ "Returns", "a", "format", "-", "String", "that", "can", "be", "used", "to", "generate", "a", "String", "representation", "of", "a", "map", "using", "the", "String", ".", "format", "method", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/misc/MapUtils.java#L70-L86
151,032
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/memory/Cache.java
Cache.get
public synchronized Value get(Key key, CloseableListenable user) { Data<Value> data = map.get(key); if (data == null) return null; data.users.add(user); if (user != null) user.addCloseListener(new Listener<CloseableListenable>() { @Override public void fire(CloseableListenable event) { event.removeCloseListener(this); free(data.value, event); } }); return data.value; }
java
public synchronized Value get(Key key, CloseableListenable user) { Data<Value> data = map.get(key); if (data == null) return null; data.users.add(user); if (user != null) user.addCloseListener(new Listener<CloseableListenable>() { @Override public void fire(CloseableListenable event) { event.removeCloseListener(this); free(data.value, event); } }); return data.value; }
[ "public", "synchronized", "Value", "get", "(", "Key", "key", ",", "CloseableListenable", "user", ")", "{", "Data", "<", "Value", ">", "data", "=", "map", ".", "get", "(", "key", ")", ";", "if", "(", "data", "==", "null", ")", "return", "null", ";", "data", ".", "users", ".", "add", "(", "user", ")", ";", "if", "(", "user", "!=", "null", ")", "user", ".", "addCloseListener", "(", "new", "Listener", "<", "CloseableListenable", ">", "(", ")", "{", "@", "Override", "public", "void", "fire", "(", "CloseableListenable", "event", ")", "{", "event", ".", "removeCloseListener", "(", "this", ")", ";", "free", "(", "data", ".", "value", ",", "event", ")", ";", "}", "}", ")", ";", "return", "data", ".", "value", ";", "}" ]
Return the cached data corresponding to the given key, or null if it does not exist. The given user is added as using the cached data. Once closed, the user is automatically removed from the list of users.
[ "Return", "the", "cached", "data", "corresponding", "to", "the", "given", "key", "or", "null", "if", "it", "does", "not", "exist", ".", "The", "given", "user", "is", "added", "as", "using", "the", "cached", "data", ".", "Once", "closed", "the", "user", "is", "automatically", "removed", "from", "the", "list", "of", "users", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/memory/Cache.java#L51-L64
151,033
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/memory/Cache.java
Cache.free
public synchronized void free(Value value, CloseableListenable user) { Data<Value> data = values.get(value); if (data == null) return; data.lastUsage = System.currentTimeMillis(); data.users.remove(user); }
java
public synchronized void free(Value value, CloseableListenable user) { Data<Value> data = values.get(value); if (data == null) return; data.lastUsage = System.currentTimeMillis(); data.users.remove(user); }
[ "public", "synchronized", "void", "free", "(", "Value", "value", ",", "CloseableListenable", "user", ")", "{", "Data", "<", "Value", ">", "data", "=", "values", ".", "get", "(", "value", ")", ";", "if", "(", "data", "==", "null", ")", "return", ";", "data", ".", "lastUsage", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "data", ".", "users", ".", "remove", "(", "user", ")", ";", "}" ]
Signal that the given cached data is not anymore used by the given user.
[ "Signal", "that", "the", "given", "cached", "data", "is", "not", "anymore", "used", "by", "the", "given", "user", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/memory/Cache.java#L67-L72
151,034
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/memory/Cache.java
Cache.put
public synchronized void put(Key key, Value value, CloseableListenable firstUser) { if (map.containsKey(key)) throw new IllegalStateException("Cannot put a value in Cache with an existing key: " + key); if (values.containsKey(value)) throw new IllegalStateException("Cannot put 2 times the same value in Cache: " + value); Data<Value> data = new Data<Value>(); data.value = value; data.lastUsage = System.currentTimeMillis(); data.users.add(firstUser); map.put(key, data); values.put(value, data); }
java
public synchronized void put(Key key, Value value, CloseableListenable firstUser) { if (map.containsKey(key)) throw new IllegalStateException("Cannot put a value in Cache with an existing key: " + key); if (values.containsKey(value)) throw new IllegalStateException("Cannot put 2 times the same value in Cache: " + value); Data<Value> data = new Data<Value>(); data.value = value; data.lastUsage = System.currentTimeMillis(); data.users.add(firstUser); map.put(key, data); values.put(value, data); }
[ "public", "synchronized", "void", "put", "(", "Key", "key", ",", "Value", "value", ",", "CloseableListenable", "firstUser", ")", "{", "if", "(", "map", ".", "containsKey", "(", "key", ")", ")", "throw", "new", "IllegalStateException", "(", "\"Cannot put a value in Cache with an existing key: \"", "+", "key", ")", ";", "if", "(", "values", ".", "containsKey", "(", "value", ")", ")", "throw", "new", "IllegalStateException", "(", "\"Cannot put 2 times the same value in Cache: \"", "+", "value", ")", ";", "Data", "<", "Value", ">", "data", "=", "new", "Data", "<", "Value", ">", "(", ")", ";", "data", ".", "value", "=", "value", ";", "data", ".", "lastUsage", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "data", ".", "users", ".", "add", "(", "firstUser", ")", ";", "map", ".", "put", "(", "key", ",", "data", ")", ";", "values", ".", "put", "(", "value", ",", "data", ")", ";", "}" ]
Add the given data to this cache, and add the given first user to it.
[ "Add", "the", "given", "data", "to", "this", "cache", "and", "add", "the", "given", "first", "user", "to", "it", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/memory/Cache.java#L75-L86
151,035
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/adapter/AdapterRegistry.java
AdapterRegistry.adapt
@SuppressWarnings("unchecked") public <Input,Output> Output adapt(Input input, Class<Output> outputType) throws Exception { Class<?> inputType = input.getClass(); Adapter a = findAdapter(input, inputType, outputType); if (a == null) return null; return (Output)a.adapt(input); }
java
@SuppressWarnings("unchecked") public <Input,Output> Output adapt(Input input, Class<Output> outputType) throws Exception { Class<?> inputType = input.getClass(); Adapter a = findAdapter(input, inputType, outputType); if (a == null) return null; return (Output)a.adapt(input); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "Input", ",", "Output", ">", "Output", "adapt", "(", "Input", "input", ",", "Class", "<", "Output", ">", "outputType", ")", "throws", "Exception", "{", "Class", "<", "?", ">", "inputType", "=", "input", ".", "getClass", "(", ")", ";", "Adapter", "a", "=", "findAdapter", "(", "input", ",", "inputType", ",", "outputType", ")", ";", "if", "(", "a", "==", "null", ")", "return", "null", ";", "return", "(", "Output", ")", "a", ".", "adapt", "(", "input", ")", ";", "}" ]
Find an adapter that can adapt the given input into the given output type, and adapt it or return null if no available adapter can be found.
[ "Find", "an", "adapter", "that", "can", "adapt", "the", "given", "input", "into", "the", "given", "output", "type", "and", "adapt", "it", "or", "return", "null", "if", "no", "available", "adapter", "can", "be", "found", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/adapter/AdapterRegistry.java#L56-L62
151,036
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/adapter/AdapterRegistry.java
AdapterRegistry.canAdapt
public boolean canAdapt(Object input, Class<?> outputType) { Class<?> inputType = input.getClass(); Adapter a = findAdapter(input, inputType, outputType); return a != null; }
java
public boolean canAdapt(Object input, Class<?> outputType) { Class<?> inputType = input.getClass(); Adapter a = findAdapter(input, inputType, outputType); return a != null; }
[ "public", "boolean", "canAdapt", "(", "Object", "input", ",", "Class", "<", "?", ">", "outputType", ")", "{", "Class", "<", "?", ">", "inputType", "=", "input", ".", "getClass", "(", ")", ";", "Adapter", "a", "=", "findAdapter", "(", "input", ",", "inputType", ",", "outputType", ")", ";", "return", "a", "!=", "null", ";", "}" ]
Return true if an adapter can be found to adapt the given input into the given output type.
[ "Return", "true", "if", "an", "adapter", "can", "be", "found", "to", "adapt", "the", "given", "input", "into", "the", "given", "output", "type", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/adapter/AdapterRegistry.java#L65-L69
151,037
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/adapter/AdapterRegistry.java
AdapterRegistry.findAdapter
@SuppressWarnings("unchecked") public <Input,Output> Adapter<Input,Output> findAdapter(Object in, Class<Input> input, Class<Output> output) { ArrayList<Adapter> acceptInput = new ArrayList<>(); ArrayList<Adapter> matching = new ArrayList<>(); for (Adapter a : adapters) { if (!a.getInputType().isAssignableFrom(input)) continue; if (!a.canAdapt(in)) continue; acceptInput.add(a); if (output.equals(a.getOutputType())) return a; if (output.isAssignableFrom(a.getOutputType())) matching.add(a); } if (acceptInput.isEmpty()) return null; if (matching.size() == 1) return matching.get(0); if (!matching.isEmpty()) return getBest(matching); LinkedList<LinkedList<Adapter>> paths = findPathsTo(input, acceptInput, output); LinkedList<Adapter> best = null; while (!paths.isEmpty()) { LinkedList<Adapter> path = paths.removeFirst(); if (best != null && best.size() <= path.size()) continue; Object o = in; boolean valid = true; int i = 0; for (Adapter a : path) { if (!a.canAdapt(o)) { valid = false; break; } if (i == path.size() - 1) break; // we are on the last, so no need to do it i++; try { o = a.adapt(o); } catch (Exception e) { valid = false; break; } } if (valid) best = path; } if (best == null) return null; return new LinkedAdapter(best); }
java
@SuppressWarnings("unchecked") public <Input,Output> Adapter<Input,Output> findAdapter(Object in, Class<Input> input, Class<Output> output) { ArrayList<Adapter> acceptInput = new ArrayList<>(); ArrayList<Adapter> matching = new ArrayList<>(); for (Adapter a : adapters) { if (!a.getInputType().isAssignableFrom(input)) continue; if (!a.canAdapt(in)) continue; acceptInput.add(a); if (output.equals(a.getOutputType())) return a; if (output.isAssignableFrom(a.getOutputType())) matching.add(a); } if (acceptInput.isEmpty()) return null; if (matching.size() == 1) return matching.get(0); if (!matching.isEmpty()) return getBest(matching); LinkedList<LinkedList<Adapter>> paths = findPathsTo(input, acceptInput, output); LinkedList<Adapter> best = null; while (!paths.isEmpty()) { LinkedList<Adapter> path = paths.removeFirst(); if (best != null && best.size() <= path.size()) continue; Object o = in; boolean valid = true; int i = 0; for (Adapter a : path) { if (!a.canAdapt(o)) { valid = false; break; } if (i == path.size() - 1) break; // we are on the last, so no need to do it i++; try { o = a.adapt(o); } catch (Exception e) { valid = false; break; } } if (valid) best = path; } if (best == null) return null; return new LinkedAdapter(best); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "Input", ",", "Output", ">", "Adapter", "<", "Input", ",", "Output", ">", "findAdapter", "(", "Object", "in", ",", "Class", "<", "Input", ">", "input", ",", "Class", "<", "Output", ">", "output", ")", "{", "ArrayList", "<", "Adapter", ">", "acceptInput", "=", "new", "ArrayList", "<>", "(", ")", ";", "ArrayList", "<", "Adapter", ">", "matching", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "Adapter", "a", ":", "adapters", ")", "{", "if", "(", "!", "a", ".", "getInputType", "(", ")", ".", "isAssignableFrom", "(", "input", ")", ")", "continue", ";", "if", "(", "!", "a", ".", "canAdapt", "(", "in", ")", ")", "continue", ";", "acceptInput", ".", "add", "(", "a", ")", ";", "if", "(", "output", ".", "equals", "(", "a", ".", "getOutputType", "(", ")", ")", ")", "return", "a", ";", "if", "(", "output", ".", "isAssignableFrom", "(", "a", ".", "getOutputType", "(", ")", ")", ")", "matching", ".", "add", "(", "a", ")", ";", "}", "if", "(", "acceptInput", ".", "isEmpty", "(", ")", ")", "return", "null", ";", "if", "(", "matching", ".", "size", "(", ")", "==", "1", ")", "return", "matching", ".", "get", "(", "0", ")", ";", "if", "(", "!", "matching", ".", "isEmpty", "(", ")", ")", "return", "getBest", "(", "matching", ")", ";", "LinkedList", "<", "LinkedList", "<", "Adapter", ">", ">", "paths", "=", "findPathsTo", "(", "input", ",", "acceptInput", ",", "output", ")", ";", "LinkedList", "<", "Adapter", ">", "best", "=", "null", ";", "while", "(", "!", "paths", ".", "isEmpty", "(", ")", ")", "{", "LinkedList", "<", "Adapter", ">", "path", "=", "paths", ".", "removeFirst", "(", ")", ";", "if", "(", "best", "!=", "null", "&&", "best", ".", "size", "(", ")", "<=", "path", ".", "size", "(", ")", ")", "continue", ";", "Object", "o", "=", "in", ";", "boolean", "valid", "=", "true", ";", "int", "i", "=", "0", ";", "for", "(", "Adapter", "a", ":", "path", ")", "{", "if", "(", "!", "a", ".", "canAdapt", "(", "o", ")", ")", "{", "valid", "=", "false", ";", "break", ";", "}", "if", "(", "i", "==", "path", ".", "size", "(", ")", "-", "1", ")", "break", ";", "// we are on the last, so no need to do it\r", "i", "++", ";", "try", "{", "o", "=", "a", ".", "adapt", "(", "o", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "valid", "=", "false", ";", "break", ";", "}", "}", "if", "(", "valid", ")", "best", "=", "path", ";", "}", "if", "(", "best", "==", "null", ")", "return", "null", ";", "return", "new", "LinkedAdapter", "(", "best", ")", ";", "}" ]
Search for an adapter.
[ "Search", "for", "an", "adapter", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/adapter/AdapterRegistry.java#L72-L119
151,038
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/concurrent/synch/SynchronizationPoint.java
SynchronizationPoint.unblock
public final void unblock() { if (Threading.debugSynchronization) ThreadingDebugHelper.unblocked(this); ArrayList<Runnable> listeners; synchronized (this) { if (unblocked) return; unblocked = true; if (listenersInline == null) { this.notifyAll(); return; } listeners = listenersInline; listenersInline = new ArrayList<>(2); } Logger log = LCCore.getApplication().getLoggerFactory().getLogger(SynchronizationPoint.class); while (true) { if (!log.debug()) for (int i = 0; i < listeners.size(); ++i) try { listeners.get(i).run(); } catch (Throwable t) { log.error( "Exception thrown by an inline listener of SynchronizationPoint", t); } else for (int i = 0; i < listeners.size(); ++i) { long start = System.nanoTime(); try { listeners.get(i).run(); } catch (Throwable t) { log.error( "Exception thrown by an inline listener of SynchronizationPoint", t); } long time = System.nanoTime() - start; if (time > 1000000) // more than 1ms log.debug("Listener took " + (time / 1000000.0d) + "ms: " + listeners.get(i)); } synchronized (this) { if (listenersInline.isEmpty()) { listenersInline = null; listeners = null; this.notifyAll(); break; } listeners.clear(); ArrayList<Runnable> tmp = listeners; listeners = listenersInline; listenersInline = tmp; } } }
java
public final void unblock() { if (Threading.debugSynchronization) ThreadingDebugHelper.unblocked(this); ArrayList<Runnable> listeners; synchronized (this) { if (unblocked) return; unblocked = true; if (listenersInline == null) { this.notifyAll(); return; } listeners = listenersInline; listenersInline = new ArrayList<>(2); } Logger log = LCCore.getApplication().getLoggerFactory().getLogger(SynchronizationPoint.class); while (true) { if (!log.debug()) for (int i = 0; i < listeners.size(); ++i) try { listeners.get(i).run(); } catch (Throwable t) { log.error( "Exception thrown by an inline listener of SynchronizationPoint", t); } else for (int i = 0; i < listeners.size(); ++i) { long start = System.nanoTime(); try { listeners.get(i).run(); } catch (Throwable t) { log.error( "Exception thrown by an inline listener of SynchronizationPoint", t); } long time = System.nanoTime() - start; if (time > 1000000) // more than 1ms log.debug("Listener took " + (time / 1000000.0d) + "ms: " + listeners.get(i)); } synchronized (this) { if (listenersInline.isEmpty()) { listenersInline = null; listeners = null; this.notifyAll(); break; } listeners.clear(); ArrayList<Runnable> tmp = listeners; listeners = listenersInline; listenersInline = tmp; } } }
[ "public", "final", "void", "unblock", "(", ")", "{", "if", "(", "Threading", ".", "debugSynchronization", ")", "ThreadingDebugHelper", ".", "unblocked", "(", "this", ")", ";", "ArrayList", "<", "Runnable", ">", "listeners", ";", "synchronized", "(", "this", ")", "{", "if", "(", "unblocked", ")", "return", ";", "unblocked", "=", "true", ";", "if", "(", "listenersInline", "==", "null", ")", "{", "this", ".", "notifyAll", "(", ")", ";", "return", ";", "}", "listeners", "=", "listenersInline", ";", "listenersInline", "=", "new", "ArrayList", "<>", "(", "2", ")", ";", "}", "Logger", "log", "=", "LCCore", ".", "getApplication", "(", ")", ".", "getLoggerFactory", "(", ")", ".", "getLogger", "(", "SynchronizationPoint", ".", "class", ")", ";", "while", "(", "true", ")", "{", "if", "(", "!", "log", ".", "debug", "(", ")", ")", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeners", ".", "size", "(", ")", ";", "++", "i", ")", "try", "{", "listeners", ".", "get", "(", "i", ")", ".", "run", "(", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "log", ".", "error", "(", "\"Exception thrown by an inline listener of SynchronizationPoint\"", ",", "t", ")", ";", "}", "else", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeners", ".", "size", "(", ")", ";", "++", "i", ")", "{", "long", "start", "=", "System", ".", "nanoTime", "(", ")", ";", "try", "{", "listeners", ".", "get", "(", "i", ")", ".", "run", "(", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "log", ".", "error", "(", "\"Exception thrown by an inline listener of SynchronizationPoint\"", ",", "t", ")", ";", "}", "long", "time", "=", "System", ".", "nanoTime", "(", ")", "-", "start", ";", "if", "(", "time", ">", "1000000", ")", "// more than 1ms\r", "log", ".", "debug", "(", "\"Listener took \"", "+", "(", "time", "/", "1000000.0d", ")", "+", "\"ms: \"", "+", "listeners", ".", "get", "(", "i", ")", ")", ";", "}", "synchronized", "(", "this", ")", "{", "if", "(", "listenersInline", ".", "isEmpty", "(", ")", ")", "{", "listenersInline", "=", "null", ";", "listeners", "=", "null", ";", "this", ".", "notifyAll", "(", ")", ";", "break", ";", "}", "listeners", ".", "clear", "(", ")", ";", "ArrayList", "<", "Runnable", ">", "tmp", "=", "listeners", ";", "listeners", "=", "listenersInline", ";", "listenersInline", "=", "tmp", ";", "}", "}", "}" ]
Unblock this synchronization point without error.
[ "Unblock", "this", "synchronization", "point", "without", "error", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/concurrent/synch/SynchronizationPoint.java#L67-L110
151,039
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/io/buffering/SimpleBufferedReadable.java
SimpleBufferedReadable.stop
public void stop() { AsyncWork<Integer,IOException> currentRead = readTask; if (currentRead != null && !currentRead.isUnblocked()) { currentRead.cancel(new CancelException("SimpleBufferedReadable.stop")); currentRead.block(0); } }
java
public void stop() { AsyncWork<Integer,IOException> currentRead = readTask; if (currentRead != null && !currentRead.isUnblocked()) { currentRead.cancel(new CancelException("SimpleBufferedReadable.stop")); currentRead.block(0); } }
[ "public", "void", "stop", "(", ")", "{", "AsyncWork", "<", "Integer", ",", "IOException", ">", "currentRead", "=", "readTask", ";", "if", "(", "currentRead", "!=", "null", "&&", "!", "currentRead", ".", "isUnblocked", "(", ")", ")", "{", "currentRead", ".", "cancel", "(", "new", "CancelException", "(", "\"SimpleBufferedReadable.stop\"", ")", ")", ";", "currentRead", ".", "block", "(", "0", ")", ";", "}", "}" ]
Stop any pending read, and block until they are cancelled or done.
[ "Stop", "any", "pending", "read", "and", "block", "until", "they", "are", "cancelled", "or", "done", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/io/buffering/SimpleBufferedReadable.java#L107-L113
151,040
GerdHolz/TOVAL
src/de/invation/code/toval/os/LinuxMIMEDatabase.java
LinuxMIMEDatabase.getExtensionMimeMap
public final Map<String, Set<String>> getExtensionMimeMap() throws OSException { initializeMimeExtensionArrays(); return Collections.unmodifiableMap(extensionMime); }
java
public final Map<String, Set<String>> getExtensionMimeMap() throws OSException { initializeMimeExtensionArrays(); return Collections.unmodifiableMap(extensionMime); }
[ "public", "final", "Map", "<", "String", ",", "Set", "<", "String", ">", ">", "getExtensionMimeMap", "(", ")", "throws", "OSException", "{", "initializeMimeExtensionArrays", "(", ")", ";", "return", "Collections", ".", "unmodifiableMap", "(", "extensionMime", ")", ";", "}" ]
Creates a map with file extensions as keys pointing on sets of MIME types associated with them. @return Map of file extensions pointing on MIME types @throws OSException
[ "Creates", "a", "map", "with", "file", "extensions", "as", "keys", "pointing", "on", "sets", "of", "MIME", "types", "associated", "with", "them", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/os/LinuxMIMEDatabase.java#L109-L112
151,041
GerdHolz/TOVAL
src/de/invation/code/toval/os/LinuxMIMEDatabase.java
LinuxMIMEDatabase.getMimeApps
public Map<String, Set<String>> getMimeApps() throws OSException { // lazy initialization if (mimeApps == null) { mimeApps = new HashMap<>(); for (String path : MIME_APPS_LISTS) { File mimeAppListFile = new File(path); if (mimeAppListFile.exists() && mimeAppListFile.isFile() && mimeAppListFile.canRead()) { try (BufferedReader br = new BufferedReader(new FileReader(mimeAppListFile))) { for (String line; (line = br.readLine()) != null;) { String mimeType = null; Set<String> apps = new HashSet<>(); Matcher extMatcher = MIME_TYPE_APPS_PATTERN.matcher(line); while (extMatcher.find()) { if (extMatcher.group(1) != null) { mimeType = extMatcher.group(1); } if (extMatcher.group(2) != null) { apps.add(extMatcher.group(2)); } } if (mimeType != null && apps.size() > 0) { mimeApps.put(mimeType, apps); } } } catch (IOException e) { throw new OSException(e); } } } } return Collections.unmodifiableMap(mimeApps); }
java
public Map<String, Set<String>> getMimeApps() throws OSException { // lazy initialization if (mimeApps == null) { mimeApps = new HashMap<>(); for (String path : MIME_APPS_LISTS) { File mimeAppListFile = new File(path); if (mimeAppListFile.exists() && mimeAppListFile.isFile() && mimeAppListFile.canRead()) { try (BufferedReader br = new BufferedReader(new FileReader(mimeAppListFile))) { for (String line; (line = br.readLine()) != null;) { String mimeType = null; Set<String> apps = new HashSet<>(); Matcher extMatcher = MIME_TYPE_APPS_PATTERN.matcher(line); while (extMatcher.find()) { if (extMatcher.group(1) != null) { mimeType = extMatcher.group(1); } if (extMatcher.group(2) != null) { apps.add(extMatcher.group(2)); } } if (mimeType != null && apps.size() > 0) { mimeApps.put(mimeType, apps); } } } catch (IOException e) { throw new OSException(e); } } } } return Collections.unmodifiableMap(mimeApps); }
[ "public", "Map", "<", "String", ",", "Set", "<", "String", ">", ">", "getMimeApps", "(", ")", "throws", "OSException", "{", "// lazy initialization", "if", "(", "mimeApps", "==", "null", ")", "{", "mimeApps", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "String", "path", ":", "MIME_APPS_LISTS", ")", "{", "File", "mimeAppListFile", "=", "new", "File", "(", "path", ")", ";", "if", "(", "mimeAppListFile", ".", "exists", "(", ")", "&&", "mimeAppListFile", ".", "isFile", "(", ")", "&&", "mimeAppListFile", ".", "canRead", "(", ")", ")", "{", "try", "(", "BufferedReader", "br", "=", "new", "BufferedReader", "(", "new", "FileReader", "(", "mimeAppListFile", ")", ")", ")", "{", "for", "(", "String", "line", ";", "(", "line", "=", "br", ".", "readLine", "(", ")", ")", "!=", "null", ";", ")", "{", "String", "mimeType", "=", "null", ";", "Set", "<", "String", ">", "apps", "=", "new", "HashSet", "<>", "(", ")", ";", "Matcher", "extMatcher", "=", "MIME_TYPE_APPS_PATTERN", ".", "matcher", "(", "line", ")", ";", "while", "(", "extMatcher", ".", "find", "(", ")", ")", "{", "if", "(", "extMatcher", ".", "group", "(", "1", ")", "!=", "null", ")", "{", "mimeType", "=", "extMatcher", ".", "group", "(", "1", ")", ";", "}", "if", "(", "extMatcher", ".", "group", "(", "2", ")", "!=", "null", ")", "{", "apps", ".", "add", "(", "extMatcher", ".", "group", "(", "2", ")", ")", ";", "}", "}", "if", "(", "mimeType", "!=", "null", "&&", "apps", ".", "size", "(", ")", ">", "0", ")", "{", "mimeApps", ".", "put", "(", "mimeType", ",", "apps", ")", ";", "}", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "OSException", "(", "e", ")", ";", "}", "}", "}", "}", "return", "Collections", ".", "unmodifiableMap", "(", "mimeApps", ")", ";", "}" ]
Creates a map of MIME types pointing on the associated application. @return Key-value-pairs of MIME types and the associated application. @throws OSException
[ "Creates", "a", "map", "of", "MIME", "types", "pointing", "on", "the", "associated", "application", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/os/LinuxMIMEDatabase.java#L120-L153
151,042
GerdHolz/TOVAL
src/de/invation/code/toval/os/LinuxMIMEDatabase.java
LinuxMIMEDatabase.getMimeExtensionMap
public final Map<String, Set<String>> getMimeExtensionMap() throws OSException { initializeMimeExtensionArrays(); return Collections.unmodifiableMap(mimeExtension); }
java
public final Map<String, Set<String>> getMimeExtensionMap() throws OSException { initializeMimeExtensionArrays(); return Collections.unmodifiableMap(mimeExtension); }
[ "public", "final", "Map", "<", "String", ",", "Set", "<", "String", ">", ">", "getMimeExtensionMap", "(", ")", "throws", "OSException", "{", "initializeMimeExtensionArrays", "(", ")", ";", "return", "Collections", ".", "unmodifiableMap", "(", "mimeExtension", ")", ";", "}" ]
Creates a map with MIME types as keys pointing on sets of associated file extensions. @return Map of MIME types pointing on sets of file extensions @throws OSException
[ "Creates", "a", "map", "with", "MIME", "types", "as", "keys", "pointing", "on", "sets", "of", "associated", "file", "extensions", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/os/LinuxMIMEDatabase.java#L162-L165
151,043
hawkular/hawkular-inventory
hawkular-inventory-api/src/main/java/org/hawkular/inventory/base/Traversal.java
Traversal.getSingle
protected BE getSingle(Query query, SegmentType entityType) { return inTx(tx -> Util.getSingle(tx, query, entityType)); }
java
protected BE getSingle(Query query, SegmentType entityType) { return inTx(tx -> Util.getSingle(tx, query, entityType)); }
[ "protected", "BE", "getSingle", "(", "Query", "query", ",", "SegmentType", "entityType", ")", "{", "return", "inTx", "(", "tx", "->", "Util", ".", "getSingle", "(", "tx", ",", "query", ",", "entityType", ")", ")", ";", "}" ]
A helper method to retrieve a single result from the query or throw an exception if the query yields no results. @param query the query to run @param entityType the expected type of the entity (used only for error reporting) @return the single result @throws EntityNotFoundException if the query doesn't return any results
[ "A", "helper", "method", "to", "retrieve", "a", "single", "result", "from", "the", "query", "or", "throw", "an", "exception", "if", "the", "query", "yields", "no", "results", "." ]
f56dc10323dca21777feb5b609a9e9cc70ffaf62
https://github.com/hawkular/hawkular-inventory/blob/f56dc10323dca21777feb5b609a9e9cc70ffaf62/hawkular-inventory-api/src/main/java/org/hawkular/inventory/base/Traversal.java#L62-L64
151,044
livetribe/livetribe-slp
core/src/main/java/org/livetribe/slp/settings/PropertiesSettings.java
PropertiesSettings.from
public static PropertiesSettings from(File file) throws IOException { FileInputStream stream = new FileInputStream(file); return from(stream); }
java
public static PropertiesSettings from(File file) throws IOException { FileInputStream stream = new FileInputStream(file); return from(stream); }
[ "public", "static", "PropertiesSettings", "from", "(", "File", "file", ")", "throws", "IOException", "{", "FileInputStream", "stream", "=", "new", "FileInputStream", "(", "file", ")", ";", "return", "from", "(", "stream", ")", ";", "}" ]
Creates a new PropertiesSettings from the given properties file. @param file the properties file to read @return a new PropertiesSettings @throws IOException if the properties file cannot be read
[ "Creates", "a", "new", "PropertiesSettings", "from", "the", "given", "properties", "file", "." ]
6cc13dbe81feab133fe3dd291ca081cbc6e1f591
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/settings/PropertiesSettings.java#L38-L42
151,045
livetribe/livetribe-slp
core/src/main/java/org/livetribe/slp/settings/PropertiesSettings.java
PropertiesSettings.from
public static PropertiesSettings from(String resource) throws IOException { return from(resource, Thread.currentThread().getContextClassLoader()); }
java
public static PropertiesSettings from(String resource) throws IOException { return from(resource, Thread.currentThread().getContextClassLoader()); }
[ "public", "static", "PropertiesSettings", "from", "(", "String", "resource", ")", "throws", "IOException", "{", "return", "from", "(", "resource", ",", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ")", ";", "}" ]
Creates a new PropertiesSettings from the given resource in the classpath of the context ClassLoader. @param resource the resource to read @return a new PropertiesSettings @throws IOException if the resource cannot be read @see #from(String, ClassLoader)
[ "Creates", "a", "new", "PropertiesSettings", "from", "the", "given", "resource", "in", "the", "classpath", "of", "the", "context", "ClassLoader", "." ]
6cc13dbe81feab133fe3dd291ca081cbc6e1f591
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/settings/PropertiesSettings.java#L52-L55
151,046
livetribe/livetribe-slp
core/src/main/java/org/livetribe/slp/settings/PropertiesSettings.java
PropertiesSettings.from
public static PropertiesSettings from(String resource, ClassLoader classLoader) throws IOException { URL url = classLoader.getResource(resource); return from(url); }
java
public static PropertiesSettings from(String resource, ClassLoader classLoader) throws IOException { URL url = classLoader.getResource(resource); return from(url); }
[ "public", "static", "PropertiesSettings", "from", "(", "String", "resource", ",", "ClassLoader", "classLoader", ")", "throws", "IOException", "{", "URL", "url", "=", "classLoader", ".", "getResource", "(", "resource", ")", ";", "return", "from", "(", "url", ")", ";", "}" ]
Creates a new PropertiesSettings from the given resource in the classpath of the given ClassLoader. @param resource the resource to read @param classLoader the ClassLoader to use to read the resource @return a new PropertiesSettings @throws IOException if the resource canno be read
[ "Creates", "a", "new", "PropertiesSettings", "from", "the", "given", "resource", "in", "the", "classpath", "of", "the", "given", "ClassLoader", "." ]
6cc13dbe81feab133fe3dd291ca081cbc6e1f591
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/settings/PropertiesSettings.java#L65-L69
151,047
livetribe/livetribe-slp
core/src/main/java/org/livetribe/slp/settings/PropertiesSettings.java
PropertiesSettings.from
public static PropertiesSettings from(URL url) throws IOException { InputStream stream = null; try { stream = url.openStream(); return from(stream); } finally { if (stream != null) stream.close(); } }
java
public static PropertiesSettings from(URL url) throws IOException { InputStream stream = null; try { stream = url.openStream(); return from(stream); } finally { if (stream != null) stream.close(); } }
[ "public", "static", "PropertiesSettings", "from", "(", "URL", "url", ")", "throws", "IOException", "{", "InputStream", "stream", "=", "null", ";", "try", "{", "stream", "=", "url", ".", "openStream", "(", ")", ";", "return", "from", "(", "stream", ")", ";", "}", "finally", "{", "if", "(", "stream", "!=", "null", ")", "stream", ".", "close", "(", ")", ";", "}", "}" ]
Creates a new PropertiesSettings from the given URL. @param url the URL to read @return a new PropertiesSettings @throws IOException if the URL cannot be read
[ "Creates", "a", "new", "PropertiesSettings", "from", "the", "given", "URL", "." ]
6cc13dbe81feab133fe3dd291ca081cbc6e1f591
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/settings/PropertiesSettings.java#L78-L90
151,048
livetribe/livetribe-slp
core/src/main/java/org/livetribe/slp/settings/PropertiesSettings.java
PropertiesSettings.from
public static PropertiesSettings from(InputStream stream) throws IOException { Properties properties = new Properties(); properties.load(stream); return from(properties); }
java
public static PropertiesSettings from(InputStream stream) throws IOException { Properties properties = new Properties(); properties.load(stream); return from(properties); }
[ "public", "static", "PropertiesSettings", "from", "(", "InputStream", "stream", ")", "throws", "IOException", "{", "Properties", "properties", "=", "new", "Properties", "(", ")", ";", "properties", ".", "load", "(", "stream", ")", ";", "return", "from", "(", "properties", ")", ";", "}" ]
Creates a new PropertiesSettings from the given input stream @param stream the stream to read @return a new PropertiesSettings @throws IOException if the stream cannot be read
[ "Creates", "a", "new", "PropertiesSettings", "from", "the", "given", "input", "stream" ]
6cc13dbe81feab133fe3dd291ca081cbc6e1f591
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/settings/PropertiesSettings.java#L99-L104
151,049
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.parseXML
public static XElement parseXML(File file) throws XMLStreamException { try (InputStream in = new FileInputStream(file)) { return parseXML(in); } catch (IOException ex) { throw new XMLStreamException(ex); } }
java
public static XElement parseXML(File file) throws XMLStreamException { try (InputStream in = new FileInputStream(file)) { return parseXML(in); } catch (IOException ex) { throw new XMLStreamException(ex); } }
[ "public", "static", "XElement", "parseXML", "(", "File", "file", ")", "throws", "XMLStreamException", "{", "try", "(", "InputStream", "in", "=", "new", "FileInputStream", "(", "file", ")", ")", "{", "return", "parseXML", "(", "in", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "new", "XMLStreamException", "(", "ex", ")", ";", "}", "}" ]
Parse an XML from the given local file. @param file the file object @return az XElement object @throws XMLStreamException on error
[ "Parse", "an", "XML", "from", "the", "given", "local", "file", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L44-L50
151,050
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.parseXML
public static XElement parseXML(InputStream in) throws XMLStreamException { XMLInputFactory inf = XMLInputFactory.newInstance(); XMLStreamReader ir = inf.createXMLStreamReader(in); return parseXML(ir); }
java
public static XElement parseXML(InputStream in) throws XMLStreamException { XMLInputFactory inf = XMLInputFactory.newInstance(); XMLStreamReader ir = inf.createXMLStreamReader(in); return parseXML(ir); }
[ "public", "static", "XElement", "parseXML", "(", "InputStream", "in", ")", "throws", "XMLStreamException", "{", "XMLInputFactory", "inf", "=", "XMLInputFactory", ".", "newInstance", "(", ")", ";", "XMLStreamReader", "ir", "=", "inf", ".", "createXMLStreamReader", "(", "in", ")", ";", "return", "parseXML", "(", "ir", ")", ";", "}" ]
Parse an XML document from the given input stream. Does not close the stream. @param in the input stream @return az XElement object @throws XMLStreamException on error
[ "Parse", "an", "XML", "document", "from", "the", "given", "input", "stream", ".", "Does", "not", "close", "the", "stream", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L58-L62
151,051
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.parseXML
public static XElement parseXML(ResultSet rs, int index) throws SQLException, IOException, XMLStreamException { try (InputStream is = rs.getBinaryStream(index)) { if (is != null) { return parseXML(is); } return null; } }
java
public static XElement parseXML(ResultSet rs, int index) throws SQLException, IOException, XMLStreamException { try (InputStream is = rs.getBinaryStream(index)) { if (is != null) { return parseXML(is); } return null; } }
[ "public", "static", "XElement", "parseXML", "(", "ResultSet", "rs", ",", "int", "index", ")", "throws", "SQLException", ",", "IOException", ",", "XMLStreamException", "{", "try", "(", "InputStream", "is", "=", "rs", ".", "getBinaryStream", "(", "index", ")", ")", "{", "if", "(", "is", "!=", "null", ")", "{", "return", "parseXML", "(", "is", ")", ";", "}", "return", "null", ";", "}", "}" ]
Reads the contents of a indexed column as an XML. @param rs the result set to read from @param index the column index @return the parsed XNElement or null if the column contained null @throws SQLException on SQL error @throws IOException on IO error @throws XMLStreamException on parsing error
[ "Reads", "the", "contents", "of", "a", "indexed", "column", "as", "an", "XML", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L83-L91
151,052
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.parseXML
public static XElement parseXML(ResultSet rs, String column) throws SQLException, IOException, XMLStreamException { try (InputStream is = rs.getBinaryStream(column)) { if (is != null) { return parseXML(is); } return null; } }
java
public static XElement parseXML(ResultSet rs, String column) throws SQLException, IOException, XMLStreamException { try (InputStream is = rs.getBinaryStream(column)) { if (is != null) { return parseXML(is); } return null; } }
[ "public", "static", "XElement", "parseXML", "(", "ResultSet", "rs", ",", "String", "column", ")", "throws", "SQLException", ",", "IOException", ",", "XMLStreamException", "{", "try", "(", "InputStream", "is", "=", "rs", ".", "getBinaryStream", "(", "column", ")", ")", "{", "if", "(", "is", "!=", "null", ")", "{", "return", "parseXML", "(", "is", ")", ";", "}", "return", "null", ";", "}", "}" ]
Reads the contents of a named column as an XML. @param rs the result set to read from @param column the column name @return the parsed XNElement or null if the column contained null @throws SQLException on SQL error @throws IOException on IO error @throws XMLStreamException on parsing error
[ "Reads", "the", "contents", "of", "a", "named", "column", "as", "an", "XML", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L101-L109
151,053
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.parseXML
public static XElement parseXML(String fileName) throws XMLStreamException { try (InputStream in = new FileInputStream(fileName)) { return parseXML(in); } catch (IOException ex) { throw new XMLStreamException(ex); } }
java
public static XElement parseXML(String fileName) throws XMLStreamException { try (InputStream in = new FileInputStream(fileName)) { return parseXML(in); } catch (IOException ex) { throw new XMLStreamException(ex); } }
[ "public", "static", "XElement", "parseXML", "(", "String", "fileName", ")", "throws", "XMLStreamException", "{", "try", "(", "InputStream", "in", "=", "new", "FileInputStream", "(", "fileName", ")", ")", "{", "return", "parseXML", "(", "in", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "new", "XMLStreamException", "(", "ex", ")", ";", "}", "}" ]
Parse an XML from the given local filename. @param fileName the file name @return az XElement object @throws XMLStreamException on error
[ "Parse", "an", "XML", "from", "the", "given", "local", "filename", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L116-L122
151,054
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.parseXML
public static XElement parseXML(URL u) throws XMLStreamException, IOException { try (InputStream in = u.openStream()) { return parseXML(in); } }
java
public static XElement parseXML(URL u) throws XMLStreamException, IOException { try (InputStream in = u.openStream()) { return parseXML(in); } }
[ "public", "static", "XElement", "parseXML", "(", "URL", "u", ")", "throws", "XMLStreamException", ",", "IOException", "{", "try", "(", "InputStream", "in", "=", "u", ".", "openStream", "(", ")", ")", "{", "return", "parseXML", "(", "in", ")", ";", "}", "}" ]
Parses an XML from the given URL. @param u the url @return the parsed XML @throws XMLStreamException on error @throws IOException on error
[ "Parses", "an", "XML", "from", "the", "given", "URL", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L130-L134
151,055
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.parseXMLGZ
public static XElement parseXMLGZ(File file) throws XMLStreamException { try (GZIPInputStream gin = new GZIPInputStream(new BufferedInputStream(new FileInputStream(file), 64 * 1024))) { return parseXML(gin); } catch (IOException ex) { throw new XMLStreamException(ex); } }
java
public static XElement parseXMLGZ(File file) throws XMLStreamException { try (GZIPInputStream gin = new GZIPInputStream(new BufferedInputStream(new FileInputStream(file), 64 * 1024))) { return parseXML(gin); } catch (IOException ex) { throw new XMLStreamException(ex); } }
[ "public", "static", "XElement", "parseXMLGZ", "(", "File", "file", ")", "throws", "XMLStreamException", "{", "try", "(", "GZIPInputStream", "gin", "=", "new", "GZIPInputStream", "(", "new", "BufferedInputStream", "(", "new", "FileInputStream", "(", "file", ")", ",", "64", "*", "1024", ")", ")", ")", "{", "return", "parseXML", "(", "gin", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "new", "XMLStreamException", "(", "ex", ")", ";", "}", "}" ]
Parse an XML file compressed by GZIP. @param file the file @return the parsed XML @throws XMLStreamException on error
[ "Parse", "an", "XML", "file", "compressed", "by", "GZIP", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L165-L171
151,056
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.add
public void add(Iterable<XElement> elements) { for (XElement e : elements) { e.parent = this; children.add(e); } }
java
public void add(Iterable<XElement> elements) { for (XElement e : elements) { e.parent = this; children.add(e); } }
[ "public", "void", "add", "(", "Iterable", "<", "XElement", ">", "elements", ")", "{", "for", "(", "XElement", "e", ":", "elements", ")", "{", "e", ".", "parent", "=", "this", ";", "children", ".", "add", "(", "e", ")", ";", "}", "}" ]
Add the iterable of elements as children. @param elements the elements to add
[ "Add", "the", "iterable", "of", "elements", "as", "children", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L207-L212
151,057
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.add
public XElement add(String name) { XElement result = new XElement(name); result.parent = this; children.add(result); return result; }
java
public XElement add(String name) { XElement result = new XElement(name); result.parent = this; children.add(result); return result; }
[ "public", "XElement", "add", "(", "String", "name", ")", "{", "XElement", "result", "=", "new", "XElement", "(", "name", ")", ";", "result", ".", "parent", "=", "this", ";", "children", ".", "add", "(", "result", ")", ";", "return", "result", ";", "}" ]
Add a new child element with the given name. @param name the element name @return the created XElement
[ "Add", "a", "new", "child", "element", "with", "the", "given", "name", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L218-L223
151,058
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.add
public XElement add(String name, Object value) { XElement result = add(name); result.parent = this; result.setValue(value); return result; }
java
public XElement add(String name, Object value) { XElement result = add(name); result.parent = this; result.setValue(value); return result; }
[ "public", "XElement", "add", "(", "String", "name", ",", "Object", "value", ")", "{", "XElement", "result", "=", "add", "(", "name", ")", ";", "result", ".", "parent", "=", "this", ";", "result", ".", "setValue", "(", "value", ")", ";", "return", "result", ";", "}" ]
Add an element with the supplied content text. @param name the name @param value the content @return the new element
[ "Add", "an", "element", "with", "the", "supplied", "content", "text", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L230-L235
151,059
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.copyFrom
public void copyFrom(XElement other) { content = other.content; userObject = other.userObject; attributes.putAll(other.attributes); for (XElement c : other.children) { add(c.copy()); } }
java
public void copyFrom(XElement other) { content = other.content; userObject = other.userObject; attributes.putAll(other.attributes); for (XElement c : other.children) { add(c.copy()); } }
[ "public", "void", "copyFrom", "(", "XElement", "other", ")", "{", "content", "=", "other", ".", "content", ";", "userObject", "=", "other", ".", "userObject", ";", "attributes", ".", "putAll", "(", "other", ".", "attributes", ")", ";", "for", "(", "XElement", "c", ":", "other", ".", "children", ")", "{", "add", "(", "c", ".", "copy", "(", ")", ")", ";", "}", "}" ]
Copy the attributes, content and child elements from the other element in a deep-copy fashion. @param other the other element
[ "Copy", "the", "attributes", "content", "and", "child", "elements", "from", "the", "other", "element", "in", "a", "deep", "-", "copy", "fashion", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L310-L317
151,060
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.getDoubleObject
public Double getDoubleObject(String attributeName) { String val = get(attributeName, null); if (val != null) { return Double.valueOf(val); } return null; }
java
public Double getDoubleObject(String attributeName) { String val = get(attributeName, null); if (val != null) { return Double.valueOf(val); } return null; }
[ "public", "Double", "getDoubleObject", "(", "String", "attributeName", ")", "{", "String", "val", "=", "get", "(", "attributeName", ",", "null", ")", ";", "if", "(", "val", "!=", "null", ")", "{", "return", "Double", ".", "valueOf", "(", "val", ")", ";", "}", "return", "null", ";", "}" ]
Get a double attribute as object or null if not present. @param attributeName the attribute name @return the integer value
[ "Get", "a", "double", "attribute", "as", "object", "or", "null", "if", "not", "present", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L392-L398
151,061
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.getIntObject
public Integer getIntObject(String attributeName) { String val = get(attributeName, null); if (val != null) { return Integer.valueOf(val); } return null; }
java
public Integer getIntObject(String attributeName) { String val = get(attributeName, null); if (val != null) { return Integer.valueOf(val); } return null; }
[ "public", "Integer", "getIntObject", "(", "String", "attributeName", ")", "{", "String", "val", "=", "get", "(", "attributeName", ",", "null", ")", ";", "if", "(", "val", "!=", "null", ")", "{", "return", "Integer", ".", "valueOf", "(", "val", ")", ";", "}", "return", "null", ";", "}" ]
Get an integer attribute as object or null if not present. @param attributeName the attribute name @return the integer value
[ "Get", "an", "integer", "attribute", "as", "object", "or", "null", "if", "not", "present", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L469-L475
151,062
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.hasPositiveInt
public boolean hasPositiveInt(String attributeName) { String attr = attributes.get(attributeName); if (attr == null || attr.isEmpty()) { return false; } try { return Integer.parseInt(attr) >= 0; } catch (NumberFormatException ex) { return false; } }
java
public boolean hasPositiveInt(String attributeName) { String attr = attributes.get(attributeName); if (attr == null || attr.isEmpty()) { return false; } try { return Integer.parseInt(attr) >= 0; } catch (NumberFormatException ex) { return false; } }
[ "public", "boolean", "hasPositiveInt", "(", "String", "attributeName", ")", "{", "String", "attr", "=", "attributes", ".", "get", "(", "attributeName", ")", ";", "if", "(", "attr", "==", "null", "||", "attr", ".", "isEmpty", "(", ")", ")", "{", "return", "false", ";", "}", "try", "{", "return", "Integer", ".", "parseInt", "(", "attr", ")", ">=", "0", ";", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "return", "false", ";", "}", "}" ]
Check if there is a valid positive integer attribute. @param attributeName the attribute name @return true if the attribute is a valid positive int
[ "Check", "if", "there", "is", "a", "valid", "positive", "integer", "attribute", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L580-L590
151,063
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.isNullOrEmpty
public boolean isNullOrEmpty(String attributeName) { String attr = attributes.get(attributeName); if (attr == null || attr.isEmpty()) { return true; } return false; }
java
public boolean isNullOrEmpty(String attributeName) { String attr = attributes.get(attributeName); if (attr == null || attr.isEmpty()) { return true; } return false; }
[ "public", "boolean", "isNullOrEmpty", "(", "String", "attributeName", ")", "{", "String", "attr", "=", "attributes", ".", "get", "(", "attributeName", ")", ";", "if", "(", "attr", "==", "null", "||", "attr", ".", "isEmpty", "(", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if the given attribute is present an is not empty. @param attributeName the attribute name @return true if null or empty
[ "Check", "if", "the", "given", "attribute", "is", "present", "an", "is", "not", "empty", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L596-L602
151,064
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.removeChildrenWithName
public void removeChildrenWithName(String name) { for (int i = children.size() - 1; i >= 0; i--) { if (children.get(i).name.equals(name)) { children.remove(i).parent = null; } } }
java
public void removeChildrenWithName(String name) { for (int i = children.size() - 1; i >= 0; i--) { if (children.get(i).name.equals(name)) { children.remove(i).parent = null; } } }
[ "public", "void", "removeChildrenWithName", "(", "String", "name", ")", "{", "for", "(", "int", "i", "=", "children", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "children", ".", "get", "(", "i", ")", ".", "name", ".", "equals", "(", "name", ")", ")", "{", "children", ".", "remove", "(", "i", ")", ".", "parent", "=", "null", ";", "}", "}", "}" ]
Removes all children with the given element name. @param name the element name
[ "Removes", "all", "children", "with", "the", "given", "element", "name", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L617-L623
151,065
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.replace
public void replace(XElement oldChild, XElement newChild) { int idx = children.indexOf(oldChild); if (idx >= 0) { children.get(idx).parent = null; children.set(idx, newChild); newChild.parent = this; } }
java
public void replace(XElement oldChild, XElement newChild) { int idx = children.indexOf(oldChild); if (idx >= 0) { children.get(idx).parent = null; children.set(idx, newChild); newChild.parent = this; } }
[ "public", "void", "replace", "(", "XElement", "oldChild", ",", "XElement", "newChild", ")", "{", "int", "idx", "=", "children", ".", "indexOf", "(", "oldChild", ")", ";", "if", "(", "idx", ">=", "0", ")", "{", "children", ".", "get", "(", "idx", ")", ".", "parent", "=", "null", ";", "children", ".", "set", "(", "idx", ",", "newChild", ")", ";", "newChild", ".", "parent", "=", "this", ";", "}", "}" ]
Replaces the specified child node with the new node. If the old node is not present the method does nothing. @param oldChild the old child @param newChild the new child
[ "Replaces", "the", "specified", "child", "node", "with", "the", "new", "node", ".", "If", "the", "old", "node", "is", "not", "present", "the", "method", "does", "nothing", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L630-L637
151,066
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.save
public void save(OutputStream stream, boolean header, boolean flush) throws IOException { OutputStreamWriter out = new OutputStreamWriter(stream, "UTF-8"); save(out, header, flush); }
java
public void save(OutputStream stream, boolean header, boolean flush) throws IOException { OutputStreamWriter out = new OutputStreamWriter(stream, "UTF-8"); save(out, header, flush); }
[ "public", "void", "save", "(", "OutputStream", "stream", ",", "boolean", "header", ",", "boolean", "flush", ")", "throws", "IOException", "{", "OutputStreamWriter", "out", "=", "new", "OutputStreamWriter", "(", "stream", ",", "\"UTF-8\"", ")", ";", "save", "(", "out", ",", "header", ",", "flush", ")", ";", "}" ]
Save this XML into the supplied output stream. @param stream the output stream @param header write the header? @param flush flush after the save? @throws IOException on error
[ "Save", "this", "XML", "into", "the", "supplied", "output", "stream", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L668-L671
151,067
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.save
public void save(Writer writer, boolean header, boolean flush) throws IOException { final PrintWriter out = new PrintWriter(new BufferedWriter(writer)); try { if (header) { out.println("<?xml version='1.0' encoding='UTF-8'?>"); } toStringRep("", new XAppender() { @Override public XAppender append(Object o) { out.print(o); return this; } }); } finally { if (flush) { out.flush(); } } }
java
public void save(Writer writer, boolean header, boolean flush) throws IOException { final PrintWriter out = new PrintWriter(new BufferedWriter(writer)); try { if (header) { out.println("<?xml version='1.0' encoding='UTF-8'?>"); } toStringRep("", new XAppender() { @Override public XAppender append(Object o) { out.print(o); return this; } }); } finally { if (flush) { out.flush(); } } }
[ "public", "void", "save", "(", "Writer", "writer", ",", "boolean", "header", ",", "boolean", "flush", ")", "throws", "IOException", "{", "final", "PrintWriter", "out", "=", "new", "PrintWriter", "(", "new", "BufferedWriter", "(", "writer", ")", ")", ";", "try", "{", "if", "(", "header", ")", "{", "out", ".", "println", "(", "\"<?xml version='1.0' encoding='UTF-8'?>\"", ")", ";", "}", "toStringRep", "(", "\"\"", ",", "new", "XAppender", "(", ")", "{", "@", "Override", "public", "XAppender", "append", "(", "Object", "o", ")", "{", "out", ".", "print", "(", "o", ")", ";", "return", "this", ";", "}", "}", ")", ";", "}", "finally", "{", "if", "(", "flush", ")", "{", "out", ".", "flush", "(", ")", ";", "}", "}", "}" ]
Save this XML into the supplied output writer. @param writer the output writer @param header write the XML processing instruction as well? @throws IOException on error
[ "Save", "this", "XML", "into", "the", "supplied", "output", "writer", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L694-L712
151,068
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.set
public void set(String name, Object value) { if (value != null) { attributes.put(name, String.valueOf(value)); } else { attributes.remove(name); } }
java
public void set(String name, Object value) { if (value != null) { attributes.put(name, String.valueOf(value)); } else { attributes.remove(name); } }
[ "public", "void", "set", "(", "String", "name", ",", "Object", "value", ")", "{", "if", "(", "value", "!=", "null", ")", "{", "attributes", ".", "put", "(", "name", ",", "String", ".", "valueOf", "(", "value", ")", ")", ";", "}", "else", "{", "attributes", ".", "remove", "(", "name", ")", ";", "}", "}" ]
Set an attribute value. @param name the attribute name @param value the content value, null will remove any existing
[ "Set", "an", "attribute", "value", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L718-L725
151,069
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.visit
public void visit(boolean depthFirst, Consumer<? super XElement> action) { Deque<XElement> queue = new LinkedList<>(); queue.add(this); while (!queue.isEmpty()) { XElement x = queue.removeFirst(); action.accept(x); if (depthFirst) { ListIterator<XElement> li = x.children.listIterator(x.children.size()); while (li.hasPrevious()) { queue.addFirst(li.previous()); } } else { for (XElement c : x.children) { queue.addLast(c); } } } }
java
public void visit(boolean depthFirst, Consumer<? super XElement> action) { Deque<XElement> queue = new LinkedList<>(); queue.add(this); while (!queue.isEmpty()) { XElement x = queue.removeFirst(); action.accept(x); if (depthFirst) { ListIterator<XElement> li = x.children.listIterator(x.children.size()); while (li.hasPrevious()) { queue.addFirst(li.previous()); } } else { for (XElement c : x.children) { queue.addLast(c); } } } }
[ "public", "void", "visit", "(", "boolean", "depthFirst", ",", "Consumer", "<", "?", "super", "XElement", ">", "action", ")", "{", "Deque", "<", "XElement", ">", "queue", "=", "new", "LinkedList", "<>", "(", ")", ";", "queue", ".", "add", "(", "this", ")", ";", "while", "(", "!", "queue", ".", "isEmpty", "(", ")", ")", "{", "XElement", "x", "=", "queue", ".", "removeFirst", "(", ")", ";", "action", ".", "accept", "(", "x", ")", ";", "if", "(", "depthFirst", ")", "{", "ListIterator", "<", "XElement", ">", "li", "=", "x", ".", "children", ".", "listIterator", "(", "x", ".", "children", ".", "size", "(", ")", ")", ";", "while", "(", "li", ".", "hasPrevious", "(", ")", ")", "{", "queue", ".", "addFirst", "(", "li", ".", "previous", "(", ")", ")", ";", "}", "}", "else", "{", "for", "(", "XElement", "c", ":", "x", ".", "children", ")", "{", "queue", ".", "addLast", "(", "c", ")", ";", "}", "}", "}", "}" ]
Iterate through the elements of this XElement and invoke the action for each. @param depthFirst do a depth first search? @param action the action to invoke, non-null
[ "Iterate", "through", "the", "elements", "of", "this", "XElement", "and", "invoke", "the", "action", "for", "each", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L784-L801
151,070
akarnokd/akarnokd-xml
src/main/java/hu/akarnokd/xml/XElement.java
XElement.parseXMLActiveFragment
public static XElement parseXMLActiveFragment(XMLStreamReader in) throws XMLStreamException { XElement node = null; XElement root = null; final StringBuilder emptyBuilder = new StringBuilder(); StringBuilder b = null; Deque<StringBuilder> stack = new LinkedList<>(); int type = in.getEventType(); for (;;) { switch(type) { case XMLStreamConstants.START_ELEMENT: if (b != null) { stack.push(b); b = null; } else { stack.push(emptyBuilder); } XElement n = new XElement(in.getName().getLocalPart()); n.parent = node; int attCount = in.getAttributeCount(); if (attCount > 0) { for (int i = 0; i < attCount; i++) { n.set(in.getAttributeLocalName(i), in.getAttributeValue(i)); } } if (node != null) { node.add(n); } node = n; if (root == null) { root = n; } break; case XMLStreamConstants.CDATA: case XMLStreamConstants.CHARACTERS: if (node != null && !in.isWhiteSpace()) { if (b == null) { b = new StringBuilder(); } b.append(in.getText()); } break; case XMLStreamConstants.END_ELEMENT: if (node != null) { if (b != null) { node.content = b.toString(); } node = node.parent; } b = stack.pop(); if (b == emptyBuilder) { b = null; } if (stack.isEmpty()) { return root; } break; default: // ignore others. } if (in.hasNext()) { type = in.next(); } else { break; } } return root; }
java
public static XElement parseXMLActiveFragment(XMLStreamReader in) throws XMLStreamException { XElement node = null; XElement root = null; final StringBuilder emptyBuilder = new StringBuilder(); StringBuilder b = null; Deque<StringBuilder> stack = new LinkedList<>(); int type = in.getEventType(); for (;;) { switch(type) { case XMLStreamConstants.START_ELEMENT: if (b != null) { stack.push(b); b = null; } else { stack.push(emptyBuilder); } XElement n = new XElement(in.getName().getLocalPart()); n.parent = node; int attCount = in.getAttributeCount(); if (attCount > 0) { for (int i = 0; i < attCount; i++) { n.set(in.getAttributeLocalName(i), in.getAttributeValue(i)); } } if (node != null) { node.add(n); } node = n; if (root == null) { root = n; } break; case XMLStreamConstants.CDATA: case XMLStreamConstants.CHARACTERS: if (node != null && !in.isWhiteSpace()) { if (b == null) { b = new StringBuilder(); } b.append(in.getText()); } break; case XMLStreamConstants.END_ELEMENT: if (node != null) { if (b != null) { node.content = b.toString(); } node = node.parent; } b = stack.pop(); if (b == emptyBuilder) { b = null; } if (stack.isEmpty()) { return root; } break; default: // ignore others. } if (in.hasNext()) { type = in.next(); } else { break; } } return root; }
[ "public", "static", "XElement", "parseXMLActiveFragment", "(", "XMLStreamReader", "in", ")", "throws", "XMLStreamException", "{", "XElement", "node", "=", "null", ";", "XElement", "root", "=", "null", ";", "final", "StringBuilder", "emptyBuilder", "=", "new", "StringBuilder", "(", ")", ";", "StringBuilder", "b", "=", "null", ";", "Deque", "<", "StringBuilder", ">", "stack", "=", "new", "LinkedList", "<>", "(", ")", ";", "int", "type", "=", "in", ".", "getEventType", "(", ")", ";", "for", "(", ";", ";", ")", "{", "switch", "(", "type", ")", "{", "case", "XMLStreamConstants", ".", "START_ELEMENT", ":", "if", "(", "b", "!=", "null", ")", "{", "stack", ".", "push", "(", "b", ")", ";", "b", "=", "null", ";", "}", "else", "{", "stack", ".", "push", "(", "emptyBuilder", ")", ";", "}", "XElement", "n", "=", "new", "XElement", "(", "in", ".", "getName", "(", ")", ".", "getLocalPart", "(", ")", ")", ";", "n", ".", "parent", "=", "node", ";", "int", "attCount", "=", "in", ".", "getAttributeCount", "(", ")", ";", "if", "(", "attCount", ">", "0", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "attCount", ";", "i", "++", ")", "{", "n", ".", "set", "(", "in", ".", "getAttributeLocalName", "(", "i", ")", ",", "in", ".", "getAttributeValue", "(", "i", ")", ")", ";", "}", "}", "if", "(", "node", "!=", "null", ")", "{", "node", ".", "add", "(", "n", ")", ";", "}", "node", "=", "n", ";", "if", "(", "root", "==", "null", ")", "{", "root", "=", "n", ";", "}", "break", ";", "case", "XMLStreamConstants", ".", "CDATA", ":", "case", "XMLStreamConstants", ".", "CHARACTERS", ":", "if", "(", "node", "!=", "null", "&&", "!", "in", ".", "isWhiteSpace", "(", ")", ")", "{", "if", "(", "b", "==", "null", ")", "{", "b", "=", "new", "StringBuilder", "(", ")", ";", "}", "b", ".", "append", "(", "in", ".", "getText", "(", ")", ")", ";", "}", "break", ";", "case", "XMLStreamConstants", ".", "END_ELEMENT", ":", "if", "(", "node", "!=", "null", ")", "{", "if", "(", "b", "!=", "null", ")", "{", "node", ".", "content", "=", "b", ".", "toString", "(", ")", ";", "}", "node", "=", "node", ".", "parent", ";", "}", "b", "=", "stack", ".", "pop", "(", ")", ";", "if", "(", "b", "==", "emptyBuilder", ")", "{", "b", "=", "null", ";", "}", "if", "(", "stack", ".", "isEmpty", "(", ")", ")", "{", "return", "root", ";", "}", "break", ";", "default", ":", "// ignore others.", "}", "if", "(", "in", ".", "hasNext", "(", ")", ")", "{", "type", "=", "in", ".", "next", "(", ")", ";", "}", "else", "{", "break", ";", "}", "}", "return", "root", ";", "}" ]
Parses the stream as a fragment from the current element and returns an XElement. @param in the XML stream reader @return the parsed XElement instance @throws XMLStreamException in case there is a parsing error
[ "Parses", "the", "stream", "as", "a", "fragment", "from", "the", "current", "element", "and", "returns", "an", "XElement", "." ]
57466a5a9cb455a13d7121557c165287b31ee870
https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L819-L888
151,071
GerdHolz/TOVAL
src/de/invation/code/toval/time/AbstractIntervalList.java
AbstractIntervalList.addTimeInterval
public void addTimeInterval(T interval){ timeIntervals.add(interval); minBorders.setStart(Math.max(minBorders.getStart(), interval.getStart())); minBorders.setEnd(Math.min(minBorders.getEnd(), interval.getEnd())); if(maxBorders == null){ maxBorders = interval.clone(); } else { maxBorders.setStart(Math.min(maxBorders.getStart(), interval.getStart())); maxBorders.setEnd(Math.max(maxBorders.getEnd(), interval.getEnd())); } }
java
public void addTimeInterval(T interval){ timeIntervals.add(interval); minBorders.setStart(Math.max(minBorders.getStart(), interval.getStart())); minBorders.setEnd(Math.min(minBorders.getEnd(), interval.getEnd())); if(maxBorders == null){ maxBorders = interval.clone(); } else { maxBorders.setStart(Math.min(maxBorders.getStart(), interval.getStart())); maxBorders.setEnd(Math.max(maxBorders.getEnd(), interval.getEnd())); } }
[ "public", "void", "addTimeInterval", "(", "T", "interval", ")", "{", "timeIntervals", ".", "add", "(", "interval", ")", ";", "minBorders", ".", "setStart", "(", "Math", ".", "max", "(", "minBorders", ".", "getStart", "(", ")", ",", "interval", ".", "getStart", "(", ")", ")", ")", ";", "minBorders", ".", "setEnd", "(", "Math", ".", "min", "(", "minBorders", ".", "getEnd", "(", ")", ",", "interval", ".", "getEnd", "(", ")", ")", ")", ";", "if", "(", "maxBorders", "==", "null", ")", "{", "maxBorders", "=", "interval", ".", "clone", "(", ")", ";", "}", "else", "{", "maxBorders", ".", "setStart", "(", "Math", ".", "min", "(", "maxBorders", ".", "getStart", "(", ")", ",", "interval", ".", "getStart", "(", ")", ")", ")", ";", "maxBorders", ".", "setEnd", "(", "Math", ".", "max", "(", "maxBorders", ".", "getEnd", "(", ")", ",", "interval", ".", "getEnd", "(", ")", ")", ")", ";", "}", "}" ]
Adds a new time interval to the list of time intervals and adjusts the minimum and maximum borders. @param interval The interval to add.
[ "Adds", "a", "new", "time", "interval", "to", "the", "list", "of", "time", "intervals", "and", "adjusts", "the", "minimum", "and", "maximum", "borders", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/time/AbstractIntervalList.java#L38-L48
151,072
oaqa/uima-ecd
src/main/java/edu/cmu/lti/oaqa/ecd/BaseExperimentBuilder.java
BaseExperimentBuilder.loadTypePriorities
private void loadTypePriorities(AnyObject config) { AnyObject tpObject = config.getAnyObject("type-priorities"); if (tpObject == null) { return; } try { String[] typePrioritiesArray = getFromListOrInherit(tpObject, "type-list"); this.typePriorities = TypePrioritiesFactory.createTypePriorities(typePrioritiesArray); } catch (IOException e) { System.err.println("Failed to load type-priorities."); e.printStackTrace(); } }
java
private void loadTypePriorities(AnyObject config) { AnyObject tpObject = config.getAnyObject("type-priorities"); if (tpObject == null) { return; } try { String[] typePrioritiesArray = getFromListOrInherit(tpObject, "type-list"); this.typePriorities = TypePrioritiesFactory.createTypePriorities(typePrioritiesArray); } catch (IOException e) { System.err.println("Failed to load type-priorities."); e.printStackTrace(); } }
[ "private", "void", "loadTypePriorities", "(", "AnyObject", "config", ")", "{", "AnyObject", "tpObject", "=", "config", ".", "getAnyObject", "(", "\"type-priorities\"", ")", ";", "if", "(", "tpObject", "==", "null", ")", "{", "return", ";", "}", "try", "{", "String", "[", "]", "typePrioritiesArray", "=", "getFromListOrInherit", "(", "tpObject", ",", "\"type-list\"", ")", ";", "this", ".", "typePriorities", "=", "TypePrioritiesFactory", ".", "createTypePriorities", "(", "typePrioritiesArray", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "System", ".", "err", ".", "println", "(", "\"Failed to load type-priorities.\"", ")", ";", "e", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
Load type priorities
[ "Load", "type", "priorities" ]
09a0ae26647490b43affc36ab3a01100702b989f
https://github.com/oaqa/uima-ecd/blob/09a0ae26647490b43affc36ab3a01100702b989f/src/main/java/edu/cmu/lti/oaqa/ecd/BaseExperimentBuilder.java#L222-L234
151,073
oaqa/uima-ecd
src/main/java/edu/cmu/lti/oaqa/ecd/BaseExperimentBuilder.java
BaseExperimentBuilder.buildComponent
public AnalysisEngineDescription buildComponent(int stageId, int phase, AnyObject aeDescription) throws Exception { Map<String, Object> tuples = Maps.newLinkedHashMap(); tuples.put(BasePhase.QA_INTERNAL_PHASEID, new Integer(phase)); tuples.put(EXPERIMENT_UUID_PROPERTY, experimentUuid); tuples.put(STAGE_ID_PROPERTY, stageId); Class<? extends AnalysisComponent> ac = getFromClassOrInherit(aeDescription, AnalysisComponent.class, tuples); Object[] params = getParamList(tuples); AnalysisEngineDescription description = AnalysisEngineFactory.createPrimitiveDescription(ac, typeSystem, typePriorities, params); String name = (String) tuples.get("name"); description.getAnalysisEngineMetaData().setName(name); return description; }
java
public AnalysisEngineDescription buildComponent(int stageId, int phase, AnyObject aeDescription) throws Exception { Map<String, Object> tuples = Maps.newLinkedHashMap(); tuples.put(BasePhase.QA_INTERNAL_PHASEID, new Integer(phase)); tuples.put(EXPERIMENT_UUID_PROPERTY, experimentUuid); tuples.put(STAGE_ID_PROPERTY, stageId); Class<? extends AnalysisComponent> ac = getFromClassOrInherit(aeDescription, AnalysisComponent.class, tuples); Object[] params = getParamList(tuples); AnalysisEngineDescription description = AnalysisEngineFactory.createPrimitiveDescription(ac, typeSystem, typePriorities, params); String name = (String) tuples.get("name"); description.getAnalysisEngineMetaData().setName(name); return description; }
[ "public", "AnalysisEngineDescription", "buildComponent", "(", "int", "stageId", ",", "int", "phase", ",", "AnyObject", "aeDescription", ")", "throws", "Exception", "{", "Map", "<", "String", ",", "Object", ">", "tuples", "=", "Maps", ".", "newLinkedHashMap", "(", ")", ";", "tuples", ".", "put", "(", "BasePhase", ".", "QA_INTERNAL_PHASEID", ",", "new", "Integer", "(", "phase", ")", ")", ";", "tuples", ".", "put", "(", "EXPERIMENT_UUID_PROPERTY", ",", "experimentUuid", ")", ";", "tuples", ".", "put", "(", "STAGE_ID_PROPERTY", ",", "stageId", ")", ";", "Class", "<", "?", "extends", "AnalysisComponent", ">", "ac", "=", "getFromClassOrInherit", "(", "aeDescription", ",", "AnalysisComponent", ".", "class", ",", "tuples", ")", ";", "Object", "[", "]", "params", "=", "getParamList", "(", "tuples", ")", ";", "AnalysisEngineDescription", "description", "=", "AnalysisEngineFactory", ".", "createPrimitiveDescription", "(", "ac", ",", "typeSystem", ",", "typePriorities", ",", "params", ")", ";", "String", "name", "=", "(", "String", ")", "tuples", ".", "get", "(", "\"name\"", ")", ";", "description", ".", "getAnalysisEngineMetaData", "(", ")", ".", "setName", "(", "name", ")", ";", "return", "description", ";", "}" ]
Made this method public to invoke it from BasePhaseTest
[ "Made", "this", "method", "public", "to", "invoke", "it", "from", "BasePhaseTest" ]
09a0ae26647490b43affc36ab3a01100702b989f
https://github.com/oaqa/uima-ecd/blob/09a0ae26647490b43affc36ab3a01100702b989f/src/main/java/edu/cmu/lti/oaqa/ecd/BaseExperimentBuilder.java#L237-L251
151,074
oaqa/uima-ecd
src/main/java/edu/cmu/lti/oaqa/ecd/BaseExperimentBuilder.java
BaseExperimentBuilder.loadFromClassOrInherit
@Deprecated public static <C> Class<? extends C> loadFromClassOrInherit(String handle, Class<C> ifaceClass, Map<String, Object> tuples) throws Exception { String[] name = handle.split("!"); if (name[0].equals("class")) { return Class.forName(name[1]).asSubclass(ifaceClass); } else { if (name[0].equals("inherit")) { AnyObject yaml = ConfigurationLoader.load(name[1]); return getFromClassOrInherit(yaml, ifaceClass, tuples); } else { throw new IllegalArgumentException( "Illegal experiment descriptor, must contain one node of type <class> or <inherit>"); } } }
java
@Deprecated public static <C> Class<? extends C> loadFromClassOrInherit(String handle, Class<C> ifaceClass, Map<String, Object> tuples) throws Exception { String[] name = handle.split("!"); if (name[0].equals("class")) { return Class.forName(name[1]).asSubclass(ifaceClass); } else { if (name[0].equals("inherit")) { AnyObject yaml = ConfigurationLoader.load(name[1]); return getFromClassOrInherit(yaml, ifaceClass, tuples); } else { throw new IllegalArgumentException( "Illegal experiment descriptor, must contain one node of type <class> or <inherit>"); } } }
[ "@", "Deprecated", "public", "static", "<", "C", ">", "Class", "<", "?", "extends", "C", ">", "loadFromClassOrInherit", "(", "String", "handle", ",", "Class", "<", "C", ">", "ifaceClass", ",", "Map", "<", "String", ",", "Object", ">", "tuples", ")", "throws", "Exception", "{", "String", "[", "]", "name", "=", "handle", ".", "split", "(", "\"!\"", ")", ";", "if", "(", "name", "[", "0", "]", ".", "equals", "(", "\"class\"", ")", ")", "{", "return", "Class", ".", "forName", "(", "name", "[", "1", "]", ")", ".", "asSubclass", "(", "ifaceClass", ")", ";", "}", "else", "{", "if", "(", "name", "[", "0", "]", ".", "equals", "(", "\"inherit\"", ")", ")", "{", "AnyObject", "yaml", "=", "ConfigurationLoader", ".", "load", "(", "name", "[", "1", "]", ")", ";", "return", "getFromClassOrInherit", "(", "yaml", ",", "ifaceClass", ",", "tuples", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Illegal experiment descriptor, must contain one node of type <class> or <inherit>\"", ")", ";", "}", "}", "}" ]
These methods are preserved for compatibility with the old version of PhaseImpl
[ "These", "methods", "are", "preserved", "for", "compatibility", "with", "the", "old", "version", "of", "PhaseImpl" ]
09a0ae26647490b43affc36ab3a01100702b989f
https://github.com/oaqa/uima-ecd/blob/09a0ae26647490b43affc36ab3a01100702b989f/src/main/java/edu/cmu/lti/oaqa/ecd/BaseExperimentBuilder.java#L519-L534
151,075
jtrfp/javamod
src/main/java/de/quippy/ogg/jorbis/Lpc.java
Lpc.lpc_to_curve
void lpc_to_curve(float[] curve, float[] lpc, float amp){ for(int i=0; i<ln*2; i++) curve[i]=0.0f; if(amp==0) return; for(int i=0; i<m; i++){ curve[i*2+1]=lpc[i]/(4*amp); curve[i*2+2]=-lpc[i]/(4*amp); } fft.backward(curve); { int l2=ln*2; float unit=(float)(1./amp); curve[0]=(float)(1./(curve[0]*2+unit)); for(int i=1; i<ln; i++){ float real=(curve[i]+curve[l2-i]); float imag=(curve[i]-curve[l2-i]); float a=real+unit; curve[i]=(float)(1.0/FAST_HYPOT(a, imag)); } } }
java
void lpc_to_curve(float[] curve, float[] lpc, float amp){ for(int i=0; i<ln*2; i++) curve[i]=0.0f; if(amp==0) return; for(int i=0; i<m; i++){ curve[i*2+1]=lpc[i]/(4*amp); curve[i*2+2]=-lpc[i]/(4*amp); } fft.backward(curve); { int l2=ln*2; float unit=(float)(1./amp); curve[0]=(float)(1./(curve[0]*2+unit)); for(int i=1; i<ln; i++){ float real=(curve[i]+curve[l2-i]); float imag=(curve[i]-curve[l2-i]); float a=real+unit; curve[i]=(float)(1.0/FAST_HYPOT(a, imag)); } } }
[ "void", "lpc_to_curve", "(", "float", "[", "]", "curve", ",", "float", "[", "]", "lpc", ",", "float", "amp", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ln", "*", "2", ";", "i", "++", ")", "curve", "[", "i", "]", "=", "0.0f", ";", "if", "(", "amp", "==", "0", ")", "return", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "m", ";", "i", "++", ")", "{", "curve", "[", "i", "*", "2", "+", "1", "]", "=", "lpc", "[", "i", "]", "/", "(", "4", "*", "amp", ")", ";", "curve", "[", "i", "*", "2", "+", "2", "]", "=", "-", "lpc", "[", "i", "]", "/", "(", "4", "*", "amp", ")", ";", "}", "fft", ".", "backward", "(", "curve", ")", ";", "{", "int", "l2", "=", "ln", "*", "2", ";", "float", "unit", "=", "(", "float", ")", "(", "1.", "/", "amp", ")", ";", "curve", "[", "0", "]", "=", "(", "float", ")", "(", "1.", "/", "(", "curve", "[", "0", "]", "*", "2", "+", "unit", ")", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "ln", ";", "i", "++", ")", "{", "float", "real", "=", "(", "curve", "[", "i", "]", "+", "curve", "[", "l2", "-", "i", "]", ")", ";", "float", "imag", "=", "(", "curve", "[", "i", "]", "-", "curve", "[", "l2", "-", "i", "]", ")", ";", "float", "a", "=", "real", "+", "unit", ";", "curve", "[", "i", "]", "=", "(", "float", ")", "(", "1.0", "/", "FAST_HYPOT", "(", "a", ",", "imag", ")", ")", ";", "}", "}", "}" ]
interpolates the log curve from the linear curve.
[ "interpolates", "the", "log", "curve", "from", "the", "linear", "curve", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/ogg/jorbis/Lpc.java#L160-L187
151,076
mgledi/DRUMS
src/main/java/com/unister/semweb/drums/api/DRUMSIterator.java
DRUMSIterator.handleReadBuffer
private void handleReadBuffer() throws IOException { if (readBuffer.remaining() == 0) { readBuffer.clear(); actualFile.read(actualFileOffset, readBuffer); actualFileOffset += readBuffer.limit(); readBuffer.position(0); } }
java
private void handleReadBuffer() throws IOException { if (readBuffer.remaining() == 0) { readBuffer.clear(); actualFile.read(actualFileOffset, readBuffer); actualFileOffset += readBuffer.limit(); readBuffer.position(0); } }
[ "private", "void", "handleReadBuffer", "(", ")", "throws", "IOException", "{", "if", "(", "readBuffer", ".", "remaining", "(", ")", "==", "0", ")", "{", "readBuffer", ".", "clear", "(", ")", ";", "actualFile", ".", "read", "(", "actualFileOffset", ",", "readBuffer", ")", ";", "actualFileOffset", "+=", "readBuffer", ".", "limit", "(", ")", ";", "readBuffer", ".", "position", "(", "0", ")", ";", "}", "}" ]
fills the ReadBuffer from the HeaderIndexFile
[ "fills", "the", "ReadBuffer", "from", "the", "HeaderIndexFile" ]
a670f17a2186c9a15725f26617d77ce8e444e072
https://github.com/mgledi/DRUMS/blob/a670f17a2186c9a15725f26617d77ce8e444e072/src/main/java/com/unister/semweb/drums/api/DRUMSIterator.java#L146-L153
151,077
jtrfp/javamod
src/main/java/de/quippy/javamod/main/gui/components/SeekBarPanel.java
SeekBarPanel.initialize
private void initialize() { this.setLayout(new java.awt.GridBagLayout()); if (!showBarOnly) { this.add(getTimeTextField(), Helpers.getGridBagConstraint(0, 0, 1, 1, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 0.0, 0.0)); this.add(getTimeLabel(), Helpers.getGridBagConstraint(1, 0, 1, 1, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 1.0, 0.0)); this.add(getKBSField(), Helpers.getGridBagConstraint(2, 0, 1, 1, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 0.0, 0.0)); this.add(getKBSLabel(), Helpers.getGridBagConstraint(3, 0, 1, 1, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 1.0, 0.0)); this.add(getKHZField(), Helpers.getGridBagConstraint(4, 0, 1, 1, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 0.0, 0.0)); this.add(getKHZLabel(), Helpers.getGridBagConstraint(5, 0, 1, 1, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 1.0, 0.0)); this.add(getActiveChannelsTextField(), Helpers.getGridBagConstraint(6, 0, 1, 1, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 0.0, 0.0)); this.add(getActiveChannelsLabel(), Helpers.getGridBagConstraint(7, 0, 1, 0, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 1.0, 0.0)); this.add(getTimeBar(), Helpers.getGridBagConstraint(0, 1, 1, 0, java.awt.GridBagConstraints.HORIZONTAL, java.awt.GridBagConstraints.WEST, 1.0, 0.0)); } else { this.add(getTimeTextField(), Helpers.getGridBagConstraint(0, 0, 1, 1, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 0.0, 0.0)); this.add(getTimeBar(), Helpers.getGridBagConstraint(1, 0, 1, 0, java.awt.GridBagConstraints.HORIZONTAL, java.awt.GridBagConstraints.EAST, 1.0, 0.0)); } }
java
private void initialize() { this.setLayout(new java.awt.GridBagLayout()); if (!showBarOnly) { this.add(getTimeTextField(), Helpers.getGridBagConstraint(0, 0, 1, 1, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 0.0, 0.0)); this.add(getTimeLabel(), Helpers.getGridBagConstraint(1, 0, 1, 1, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 1.0, 0.0)); this.add(getKBSField(), Helpers.getGridBagConstraint(2, 0, 1, 1, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 0.0, 0.0)); this.add(getKBSLabel(), Helpers.getGridBagConstraint(3, 0, 1, 1, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 1.0, 0.0)); this.add(getKHZField(), Helpers.getGridBagConstraint(4, 0, 1, 1, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 0.0, 0.0)); this.add(getKHZLabel(), Helpers.getGridBagConstraint(5, 0, 1, 1, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 1.0, 0.0)); this.add(getActiveChannelsTextField(), Helpers.getGridBagConstraint(6, 0, 1, 1, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 0.0, 0.0)); this.add(getActiveChannelsLabel(), Helpers.getGridBagConstraint(7, 0, 1, 0, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 1.0, 0.0)); this.add(getTimeBar(), Helpers.getGridBagConstraint(0, 1, 1, 0, java.awt.GridBagConstraints.HORIZONTAL, java.awt.GridBagConstraints.WEST, 1.0, 0.0)); } else { this.add(getTimeTextField(), Helpers.getGridBagConstraint(0, 0, 1, 1, java.awt.GridBagConstraints.NONE, java.awt.GridBagConstraints.WEST, 0.0, 0.0)); this.add(getTimeBar(), Helpers.getGridBagConstraint(1, 0, 1, 0, java.awt.GridBagConstraints.HORIZONTAL, java.awt.GridBagConstraints.EAST, 1.0, 0.0)); } }
[ "private", "void", "initialize", "(", ")", "{", "this", ".", "setLayout", "(", "new", "java", ".", "awt", ".", "GridBagLayout", "(", ")", ")", ";", "if", "(", "!", "showBarOnly", ")", "{", "this", ".", "add", "(", "getTimeTextField", "(", ")", ",", "Helpers", ".", "getGridBagConstraint", "(", "0", ",", "0", ",", "1", ",", "1", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "NONE", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "WEST", ",", "0.0", ",", "0.0", ")", ")", ";", "this", ".", "add", "(", "getTimeLabel", "(", ")", ",", "Helpers", ".", "getGridBagConstraint", "(", "1", ",", "0", ",", "1", ",", "1", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "NONE", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "WEST", ",", "1.0", ",", "0.0", ")", ")", ";", "this", ".", "add", "(", "getKBSField", "(", ")", ",", "Helpers", ".", "getGridBagConstraint", "(", "2", ",", "0", ",", "1", ",", "1", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "NONE", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "WEST", ",", "0.0", ",", "0.0", ")", ")", ";", "this", ".", "add", "(", "getKBSLabel", "(", ")", ",", "Helpers", ".", "getGridBagConstraint", "(", "3", ",", "0", ",", "1", ",", "1", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "NONE", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "WEST", ",", "1.0", ",", "0.0", ")", ")", ";", "this", ".", "add", "(", "getKHZField", "(", ")", ",", "Helpers", ".", "getGridBagConstraint", "(", "4", ",", "0", ",", "1", ",", "1", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "NONE", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "WEST", ",", "0.0", ",", "0.0", ")", ")", ";", "this", ".", "add", "(", "getKHZLabel", "(", ")", ",", "Helpers", ".", "getGridBagConstraint", "(", "5", ",", "0", ",", "1", ",", "1", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "NONE", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "WEST", ",", "1.0", ",", "0.0", ")", ")", ";", "this", ".", "add", "(", "getActiveChannelsTextField", "(", ")", ",", "Helpers", ".", "getGridBagConstraint", "(", "6", ",", "0", ",", "1", ",", "1", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "NONE", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "WEST", ",", "0.0", ",", "0.0", ")", ")", ";", "this", ".", "add", "(", "getActiveChannelsLabel", "(", ")", ",", "Helpers", ".", "getGridBagConstraint", "(", "7", ",", "0", ",", "1", ",", "0", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "NONE", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "WEST", ",", "1.0", ",", "0.0", ")", ")", ";", "this", ".", "add", "(", "getTimeBar", "(", ")", ",", "Helpers", ".", "getGridBagConstraint", "(", "0", ",", "1", ",", "1", ",", "0", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "HORIZONTAL", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "WEST", ",", "1.0", ",", "0.0", ")", ")", ";", "}", "else", "{", "this", ".", "add", "(", "getTimeTextField", "(", ")", ",", "Helpers", ".", "getGridBagConstraint", "(", "0", ",", "0", ",", "1", ",", "1", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "NONE", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "WEST", ",", "0.0", ",", "0.0", ")", ")", ";", "this", ".", "add", "(", "getTimeBar", "(", ")", ",", "Helpers", ".", "getGridBagConstraint", "(", "1", ",", "0", ",", "1", ",", "0", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "HORIZONTAL", ",", "java", ".", "awt", ".", "GridBagConstraints", ".", "EAST", ",", "1.0", ",", "0.0", ")", ")", ";", "}", "}" ]
Will drop the graphical elements @since 09.09.2009
[ "Will", "drop", "the", "graphical", "elements" ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/javamod/main/gui/components/SeekBarPanel.java#L100-L120
151,078
agmip/acmo
src/main/java/org/agmip/acmo/util/AcmoUtil.java
AcmoUtil.escapeCsvStr
public static String escapeCsvStr(String str) { if (str != null && !str.equals("")) { boolean needQuote = false; if (str.contains("\"")) { str = str.replaceAll("\"", "\"\""); needQuote = true; } if (!needQuote && str.contains(",")) { needQuote = true; } if (needQuote) { str = "\"" + str + "\""; } return str; } else { return ""; } }
java
public static String escapeCsvStr(String str) { if (str != null && !str.equals("")) { boolean needQuote = false; if (str.contains("\"")) { str = str.replaceAll("\"", "\"\""); needQuote = true; } if (!needQuote && str.contains(",")) { needQuote = true; } if (needQuote) { str = "\"" + str + "\""; } return str; } else { return ""; } }
[ "public", "static", "String", "escapeCsvStr", "(", "String", "str", ")", "{", "if", "(", "str", "!=", "null", "&&", "!", "str", ".", "equals", "(", "\"\"", ")", ")", "{", "boolean", "needQuote", "=", "false", ";", "if", "(", "str", ".", "contains", "(", "\"\\\"\"", ")", ")", "{", "str", "=", "str", ".", "replaceAll", "(", "\"\\\"\"", ",", "\"\\\"\\\"\"", ")", ";", "needQuote", "=", "true", ";", "}", "if", "(", "!", "needQuote", "&&", "str", ".", "contains", "(", "\",\"", ")", ")", "{", "needQuote", "=", "true", ";", "}", "if", "(", "needQuote", ")", "{", "str", "=", "\"\\\"\"", "+", "str", "+", "\"\\\"\"", ";", "}", "return", "str", ";", "}", "else", "{", "return", "\"\"", ";", "}", "}" ]
CSV Escape handling for given string. " -> "" , -> "," @param str The string will be escaped for CSV format output @return Escaped CSV string
[ "CSV", "Escape", "handling", "for", "given", "string", ".", "-", ">", "-", ">" ]
cf609b272ed7344abd2e2bef3d0060d2afa81cb0
https://github.com/agmip/acmo/blob/cf609b272ed7344abd2e2bef3d0060d2afa81cb0/src/main/java/org/agmip/acmo/util/AcmoUtil.java#L661-L678
151,079
GerdHolz/TOVAL
src/de/invation/code/toval/statistic/ExtendedObservation.java
ExtendedObservation.getExpectationAt
public double getExpectationAt(int index){ if(index <0 || index>=expectations.getObservationCount()) throw new IndexOutOfBoundsException(); return expectations.getValueAt(index); }
java
public double getExpectationAt(int index){ if(index <0 || index>=expectations.getObservationCount()) throw new IndexOutOfBoundsException(); return expectations.getValueAt(index); }
[ "public", "double", "getExpectationAt", "(", "int", "index", ")", "{", "if", "(", "index", "<", "0", "||", "index", ">=", "expectations", ".", "getObservationCount", "(", ")", ")", "throw", "new", "IndexOutOfBoundsException", "(", ")", ";", "return", "expectations", ".", "getValueAt", "(", "index", ")", ";", "}" ]
Returns the expectation for a certain insertion step specified by the given index. @param index Index of the desired insertion step @return The expectation for the specified insertion step
[ "Returns", "the", "expectation", "for", "a", "certain", "insertion", "step", "specified", "by", "the", "given", "index", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/statistic/ExtendedObservation.java#L60-L64
151,080
GerdHolz/TOVAL
src/de/invation/code/toval/statistic/ExtendedObservation.java
ExtendedObservation.getMomentsAt
public HashMap<Integer, Double> getMomentsAt(int index){ if(index <0 || index>=getObservationCount()) throw new IndexOutOfBoundsException(); HashMap<Integer, Double> ret = new HashMap<Integer, Double>(); for(Integer m: momentObservation.keySet()) { Double value = momentObservation.get(m).getValueAt(index); if(value != null) ret.put(m, value); } return ret; }
java
public HashMap<Integer, Double> getMomentsAt(int index){ if(index <0 || index>=getObservationCount()) throw new IndexOutOfBoundsException(); HashMap<Integer, Double> ret = new HashMap<Integer, Double>(); for(Integer m: momentObservation.keySet()) { Double value = momentObservation.get(m).getValueAt(index); if(value != null) ret.put(m, value); } return ret; }
[ "public", "HashMap", "<", "Integer", ",", "Double", ">", "getMomentsAt", "(", "int", "index", ")", "{", "if", "(", "index", "<", "0", "||", "index", ">=", "getObservationCount", "(", ")", ")", "throw", "new", "IndexOutOfBoundsException", "(", ")", ";", "HashMap", "<", "Integer", ",", "Double", ">", "ret", "=", "new", "HashMap", "<", "Integer", ",", "Double", ">", "(", ")", ";", "for", "(", "Integer", "m", ":", "momentObservation", ".", "keySet", "(", ")", ")", "{", "Double", "value", "=", "momentObservation", ".", "get", "(", "m", ")", ".", "getValueAt", "(", "index", ")", ";", "if", "(", "value", "!=", "null", ")", "ret", ".", "put", "(", "m", ",", "value", ")", ";", "}", "return", "ret", ";", "}" ]
Returns the values of all moments for a certain insertion step specified by the given index. @param index Index of the desired insertion step @return moment values for the specified insertion step
[ "Returns", "the", "values", "of", "all", "moments", "for", "a", "certain", "insertion", "step", "specified", "by", "the", "given", "index", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/statistic/ExtendedObservation.java#L71-L81
151,081
GerdHolz/TOVAL
src/de/invation/code/toval/graphic/diagrams/panels/ScatterChartPanel.java
ScatterChartPanel.getRange
protected double getRange(ValueDimension dim) { return zeroBased ? diagram.getValues(dim).max().doubleValue() : diagram.getValues(dim).range(); }
java
protected double getRange(ValueDimension dim) { return zeroBased ? diagram.getValues(dim).max().doubleValue() : diagram.getValues(dim).range(); }
[ "protected", "double", "getRange", "(", "ValueDimension", "dim", ")", "{", "return", "zeroBased", "?", "diagram", ".", "getValues", "(", "dim", ")", ".", "max", "(", ")", ".", "doubleValue", "(", ")", ":", "diagram", ".", "getValues", "(", "dim", ")", ".", "range", "(", ")", ";", "}" ]
Returns the range of the maintained values for the given dimension. @param dim Reference dimension for range extraction @return Range of the maintained values for the given dimension
[ "Returns", "the", "range", "of", "the", "maintained", "values", "for", "the", "given", "dimension", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/graphic/diagrams/panels/ScatterChartPanel.java#L145-L147
151,082
GerdHolz/TOVAL
src/de/invation/code/toval/graphic/diagrams/panels/ScatterChartPanel.java
ScatterChartPanel.setZeroBased
public void setZeroBased(boolean zeroBased) { if(zeroBased != this.zeroBased) { this.zeroBased = zeroBased; for(ValueDimension dim: tickInfo.keySet()) tickInfo.get(dim).setZeroBased(zeroBased); } }
java
public void setZeroBased(boolean zeroBased) { if(zeroBased != this.zeroBased) { this.zeroBased = zeroBased; for(ValueDimension dim: tickInfo.keySet()) tickInfo.get(dim).setZeroBased(zeroBased); } }
[ "public", "void", "setZeroBased", "(", "boolean", "zeroBased", ")", "{", "if", "(", "zeroBased", "!=", "this", ".", "zeroBased", ")", "{", "this", ".", "zeroBased", "=", "zeroBased", ";", "for", "(", "ValueDimension", "dim", ":", "tickInfo", ".", "keySet", "(", ")", ")", "tickInfo", ".", "get", "(", "dim", ")", ".", "setZeroBased", "(", "zeroBased", ")", ";", "}", "}" ]
Sets the operation mode. In zero-based mode coordinate axes always start at 0 and end near the maximum value of the corresponding dimension. Otherwise axes start at the minimum value. @param zeroBased Operation mode
[ "Sets", "the", "operation", "mode", ".", "In", "zero", "-", "based", "mode", "coordinate", "axes", "always", "start", "at", "0", "and", "end", "near", "the", "maximum", "value", "of", "the", "corresponding", "dimension", ".", "Otherwise", "axes", "start", "at", "the", "minimum", "value", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/graphic/diagrams/panels/ScatterChartPanel.java#L242-L248
151,083
GerdHolz/TOVAL
src/de/invation/code/toval/graphic/diagrams/panels/ScatterChartPanel.java
ScatterChartPanel.paintTicks
protected void paintTicks(Graphics g, ValueDimension dim) { for(int i=0; i<getTickInfo(dim).getTickNumber(); i++) { if(i % getTickInfo(dim).getTickMultiplicator() != 0) paintTick(g, dim, getTickInfo(dim).getFirstTick()+i*getTickInfo(dim).getMinorTickSpacing(), getTickInfo(dim).getMinorTickLength()); else paintTick(g, dim, getTickInfo(dim).getFirstTick()+i*getTickInfo(dim).getMinorTickSpacing(), getTickInfo(dim).getMajorTickLength()); } }
java
protected void paintTicks(Graphics g, ValueDimension dim) { for(int i=0; i<getTickInfo(dim).getTickNumber(); i++) { if(i % getTickInfo(dim).getTickMultiplicator() != 0) paintTick(g, dim, getTickInfo(dim).getFirstTick()+i*getTickInfo(dim).getMinorTickSpacing(), getTickInfo(dim).getMinorTickLength()); else paintTick(g, dim, getTickInfo(dim).getFirstTick()+i*getTickInfo(dim).getMinorTickSpacing(), getTickInfo(dim).getMajorTickLength()); } }
[ "protected", "void", "paintTicks", "(", "Graphics", "g", ",", "ValueDimension", "dim", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "getTickInfo", "(", "dim", ")", ".", "getTickNumber", "(", ")", ";", "i", "++", ")", "{", "if", "(", "i", "%", "getTickInfo", "(", "dim", ")", ".", "getTickMultiplicator", "(", ")", "!=", "0", ")", "paintTick", "(", "g", ",", "dim", ",", "getTickInfo", "(", "dim", ")", ".", "getFirstTick", "(", ")", "+", "i", "*", "getTickInfo", "(", "dim", ")", ".", "getMinorTickSpacing", "(", ")", ",", "getTickInfo", "(", "dim", ")", ".", "getMinorTickLength", "(", ")", ")", ";", "else", "paintTick", "(", "g", ",", "dim", ",", "getTickInfo", "(", "dim", ")", ".", "getFirstTick", "(", ")", "+", "i", "*", "getTickInfo", "(", "dim", ")", ".", "getMinorTickSpacing", "(", ")", ",", "getTickInfo", "(", "dim", ")", ".", "getMajorTickLength", "(", ")", ")", ";", "}", "}" ]
Paints tick information for the coordinate axis of the given dimension. @param g Graphics context @param dim Reference dimension for tick painting
[ "Paints", "tick", "information", "for", "the", "coordinate", "axis", "of", "the", "given", "dimension", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/graphic/diagrams/panels/ScatterChartPanel.java#L324-L330
151,084
GerdHolz/TOVAL
src/de/invation/code/toval/graphic/diagrams/panels/ScatterChartPanel.java
ScatterChartPanel.paintTick
protected void paintTick(Graphics g, ValueDimension dim, Number tickValue, int tickLength) { String str = String.format(getTickInfo(dim).getFormat(), tickValue.doubleValue()); int xPosition; int yPosition; Point descPos; switch (dim) { case X: xPosition = getXFor(tickValue); yPosition = getPaintingRegion().getBottomLeft().y; g.drawLine(xPosition, yPosition, xPosition, yPosition+tickLength); descPos = getPaintingRegion().getDescriptionPos(dim, str, xPosition); g.drawString(str, descPos.x, descPos.y+tickLength); break; case Y: xPosition = getPaintingRegion().getBottomLeft().x; yPosition = getYFor(tickValue); g.drawLine(xPosition, yPosition, xPosition-tickLength, yPosition); descPos = getPaintingRegion().getDescriptionPos(dim, str, yPosition); g.drawString(str, descPos.x-tickLength, descPos.y+tickLength); break; } }
java
protected void paintTick(Graphics g, ValueDimension dim, Number tickValue, int tickLength) { String str = String.format(getTickInfo(dim).getFormat(), tickValue.doubleValue()); int xPosition; int yPosition; Point descPos; switch (dim) { case X: xPosition = getXFor(tickValue); yPosition = getPaintingRegion().getBottomLeft().y; g.drawLine(xPosition, yPosition, xPosition, yPosition+tickLength); descPos = getPaintingRegion().getDescriptionPos(dim, str, xPosition); g.drawString(str, descPos.x, descPos.y+tickLength); break; case Y: xPosition = getPaintingRegion().getBottomLeft().x; yPosition = getYFor(tickValue); g.drawLine(xPosition, yPosition, xPosition-tickLength, yPosition); descPos = getPaintingRegion().getDescriptionPos(dim, str, yPosition); g.drawString(str, descPos.x-tickLength, descPos.y+tickLength); break; } }
[ "protected", "void", "paintTick", "(", "Graphics", "g", ",", "ValueDimension", "dim", ",", "Number", "tickValue", ",", "int", "tickLength", ")", "{", "String", "str", "=", "String", ".", "format", "(", "getTickInfo", "(", "dim", ")", ".", "getFormat", "(", ")", ",", "tickValue", ".", "doubleValue", "(", ")", ")", ";", "int", "xPosition", ";", "int", "yPosition", ";", "Point", "descPos", ";", "switch", "(", "dim", ")", "{", "case", "X", ":", "xPosition", "=", "getXFor", "(", "tickValue", ")", ";", "yPosition", "=", "getPaintingRegion", "(", ")", ".", "getBottomLeft", "(", ")", ".", "y", ";", "g", ".", "drawLine", "(", "xPosition", ",", "yPosition", ",", "xPosition", ",", "yPosition", "+", "tickLength", ")", ";", "descPos", "=", "getPaintingRegion", "(", ")", ".", "getDescriptionPos", "(", "dim", ",", "str", ",", "xPosition", ")", ";", "g", ".", "drawString", "(", "str", ",", "descPos", ".", "x", ",", "descPos", ".", "y", "+", "tickLength", ")", ";", "break", ";", "case", "Y", ":", "xPosition", "=", "getPaintingRegion", "(", ")", ".", "getBottomLeft", "(", ")", ".", "x", ";", "yPosition", "=", "getYFor", "(", "tickValue", ")", ";", "g", ".", "drawLine", "(", "xPosition", ",", "yPosition", ",", "xPosition", "-", "tickLength", ",", "yPosition", ")", ";", "descPos", "=", "getPaintingRegion", "(", ")", ".", "getDescriptionPos", "(", "dim", ",", "str", ",", "yPosition", ")", ";", "g", ".", "drawString", "(", "str", ",", "descPos", ".", "x", "-", "tickLength", ",", "descPos", ".", "y", "+", "tickLength", ")", ";", "break", ";", "}", "}" ]
Paints a tick with the specified length and value with respect to the given dimension. @param g Graphics context @param dim Reference dimension for tick painting @param tickValue Value for the tick @param tickLength Length of the tick
[ "Paints", "a", "tick", "with", "the", "specified", "length", "and", "value", "with", "respect", "to", "the", "given", "dimension", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/graphic/diagrams/panels/ScatterChartPanel.java#L339-L360
151,085
GerdHolz/TOVAL
src/de/invation/code/toval/graphic/diagrams/panels/ScatterChartPanel.java
ScatterChartPanel.paintValues
protected void paintValues(Graphics g, boolean paintLines) { Point valueLocation; Point lastLocation = null; for (int i = 0; i < getValueCount(); i++) { valueLocation = getPointFor(i); GraphicUtils.fillCircle(g, valueLocation, getPointDiameter()); if(paintLines && lastLocation!=null){ g.drawLine(lastLocation.x, lastLocation.y, valueLocation.x, valueLocation.y); } lastLocation = valueLocation; } }
java
protected void paintValues(Graphics g, boolean paintLines) { Point valueLocation; Point lastLocation = null; for (int i = 0; i < getValueCount(); i++) { valueLocation = getPointFor(i); GraphicUtils.fillCircle(g, valueLocation, getPointDiameter()); if(paintLines && lastLocation!=null){ g.drawLine(lastLocation.x, lastLocation.y, valueLocation.x, valueLocation.y); } lastLocation = valueLocation; } }
[ "protected", "void", "paintValues", "(", "Graphics", "g", ",", "boolean", "paintLines", ")", "{", "Point", "valueLocation", ";", "Point", "lastLocation", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "getValueCount", "(", ")", ";", "i", "++", ")", "{", "valueLocation", "=", "getPointFor", "(", "i", ")", ";", "GraphicUtils", ".", "fillCircle", "(", "g", ",", "valueLocation", ",", "getPointDiameter", "(", ")", ")", ";", "if", "(", "paintLines", "&&", "lastLocation", "!=", "null", ")", "{", "g", ".", "drawLine", "(", "lastLocation", ".", "x", ",", "lastLocation", ".", "y", ",", "valueLocation", ".", "x", ",", "valueLocation", ".", "y", ")", ";", "}", "lastLocation", "=", "valueLocation", ";", "}", "}" ]
Paints diagram-content on the base of the values for different dimensions. @param g Graphics context
[ "Paints", "diagram", "-", "content", "on", "the", "base", "of", "the", "values", "for", "different", "dimensions", "." ]
036922cdfd710fa53b18e5dbe1e07f226f731fde
https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/graphic/diagrams/panels/ScatterChartPanel.java#L366-L377
151,086
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/collections/sort/RedBlackTreeLong.java
RedBlackTreeLong.get
public Node<T> get(long value) { if (root == null) return null; if (value == first.value) return first; if (value == last.value) return last; if (value < first.value) return null; if (value > last.value) return null; return get(root, value); }
java
public Node<T> get(long value) { if (root == null) return null; if (value == first.value) return first; if (value == last.value) return last; if (value < first.value) return null; if (value > last.value) return null; return get(root, value); }
[ "public", "Node", "<", "T", ">", "get", "(", "long", "value", ")", "{", "if", "(", "root", "==", "null", ")", "return", "null", ";", "if", "(", "value", "==", "first", ".", "value", ")", "return", "first", ";", "if", "(", "value", "==", "last", ".", "value", ")", "return", "last", ";", "if", "(", "value", "<", "first", ".", "value", ")", "return", "null", ";", "if", "(", "value", ">", "last", ".", "value", ")", "return", "null", ";", "return", "get", "(", "root", ",", "value", ")", ";", "}" ]
Returns the node associated to the given key, or null if no such key exists.
[ "Returns", "the", "node", "associated", "to", "the", "given", "key", "or", "null", "if", "no", "such", "key", "exists", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/collections/sort/RedBlackTreeLong.java#L67-L74
151,087
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/collections/sort/RedBlackTreeLong.java
RedBlackTreeLong.get
private Node<T> get(Node<T> x, long key) { while (x != null) { if (x.value == key) return x; if (key < x.value) x = x.left; else x = x.right; } return null; }
java
private Node<T> get(Node<T> x, long key) { while (x != null) { if (x.value == key) return x; if (key < x.value) x = x.left; else x = x.right; } return null; }
[ "private", "Node", "<", "T", ">", "get", "(", "Node", "<", "T", ">", "x", ",", "long", "key", ")", "{", "while", "(", "x", "!=", "null", ")", "{", "if", "(", "x", ".", "value", "==", "key", ")", "return", "x", ";", "if", "(", "key", "<", "x", ".", "value", ")", "x", "=", "x", ".", "left", ";", "else", "x", "=", "x", ".", "right", ";", "}", "return", "null", ";", "}" ]
value associated with the given key in subtree rooted at x; null if no such key
[ "value", "associated", "with", "the", "given", "key", "in", "subtree", "rooted", "at", "x", ";", "null", "if", "no", "such", "key" ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/collections/sort/RedBlackTreeLong.java#L77-L84
151,088
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/collections/sort/RedBlackTreeLong.java
RedBlackTreeLong.contains
@Override public boolean contains(long value, T element) { if (root == null) return false; if (value < first.value) return false; if (value > last.value) return false; if (value == first.value && ObjectUtil.equalsOrNull(element, first.element)) return true; if (value == last.value && ObjectUtil.equalsOrNull(element, last.element)) return true; return contains(root, value, element); }
java
@Override public boolean contains(long value, T element) { if (root == null) return false; if (value < first.value) return false; if (value > last.value) return false; if (value == first.value && ObjectUtil.equalsOrNull(element, first.element)) return true; if (value == last.value && ObjectUtil.equalsOrNull(element, last.element)) return true; return contains(root, value, element); }
[ "@", "Override", "public", "boolean", "contains", "(", "long", "value", ",", "T", "element", ")", "{", "if", "(", "root", "==", "null", ")", "return", "false", ";", "if", "(", "value", "<", "first", ".", "value", ")", "return", "false", ";", "if", "(", "value", ">", "last", ".", "value", ")", "return", "false", ";", "if", "(", "value", "==", "first", ".", "value", "&&", "ObjectUtil", ".", "equalsOrNull", "(", "element", ",", "first", ".", "element", ")", ")", "return", "true", ";", "if", "(", "value", "==", "last", ".", "value", "&&", "ObjectUtil", ".", "equalsOrNull", "(", "element", ",", "last", ".", "element", ")", ")", "return", "true", ";", "return", "contains", "(", "root", ",", "value", ",", "element", ")", ";", "}" ]
Returns true if the given key exists in the tree and its associated value is the given element. Comparison of the element is using the equals method.
[ "Returns", "true", "if", "the", "given", "key", "exists", "in", "the", "tree", "and", "its", "associated", "value", "is", "the", "given", "element", ".", "Comparison", "of", "the", "element", "is", "using", "the", "equals", "method", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/collections/sort/RedBlackTreeLong.java#L224-L232
151,089
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/collections/sort/RedBlackTreeLong.java
RedBlackTreeLong.searchNearestHigher
public Node<T> searchNearestHigher(long value, boolean acceptEquals) { if (root == null) return null; return searchNearestHigher(root, value, acceptEquals); }
java
public Node<T> searchNearestHigher(long value, boolean acceptEquals) { if (root == null) return null; return searchNearestHigher(root, value, acceptEquals); }
[ "public", "Node", "<", "T", ">", "searchNearestHigher", "(", "long", "value", ",", "boolean", "acceptEquals", ")", "{", "if", "(", "root", "==", "null", ")", "return", "null", ";", "return", "searchNearestHigher", "(", "root", ",", "value", ",", "acceptEquals", ")", ";", "}" ]
Returns the node containing the lowest value strictly higher than the given one.
[ "Returns", "the", "node", "containing", "the", "lowest", "value", "strictly", "higher", "than", "the", "given", "one", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/collections/sort/RedBlackTreeLong.java#L310-L313
151,090
mgledi/DRUMS
src/main/java/com/unister/semweb/drums/api/DRUMS.java
DRUMS.select
public List<Data> select(byte[]... keys) throws DRUMSException { List<Data> result = new ArrayList<Data>(); IntObjectOpenHashMap<ArrayList<byte[]>> bucketKeyMapping = getBucketKeyMapping(keys); String filename; for (IntObjectCursor<ArrayList<byte[]>> entry : bucketKeyMapping) { filename = gp.DATABASE_DIRECTORY + "/" + hashFunction.getFilename(entry.key); HeaderIndexFile<Data> indexFile = null; try { indexFile = new HeaderIndexFile<Data>(filename, HeaderIndexFile.AccessMode.READ_ONLY, gp.HEADER_FILE_LOCK_RETRY, gp); ArrayList<byte[]> keyList = entry.value; result.addAll(searchForData(indexFile, keyList.toArray(new byte[keyList.size()][]))); } catch (FileLockException ex) { logger.error("Could not access the file {} within {} retries. The file seems to be locked.", filename, gp.HEADER_FILE_LOCK_RETRY); throw new DRUMSException(ex); } catch (IOException ex) { logger.error("An exception occurred while trying to get objects from the file {}.", filename, ex); throw new DRUMSException(ex); } finally { if (indexFile != null) { indexFile.close(); } } } return result; }
java
public List<Data> select(byte[]... keys) throws DRUMSException { List<Data> result = new ArrayList<Data>(); IntObjectOpenHashMap<ArrayList<byte[]>> bucketKeyMapping = getBucketKeyMapping(keys); String filename; for (IntObjectCursor<ArrayList<byte[]>> entry : bucketKeyMapping) { filename = gp.DATABASE_DIRECTORY + "/" + hashFunction.getFilename(entry.key); HeaderIndexFile<Data> indexFile = null; try { indexFile = new HeaderIndexFile<Data>(filename, HeaderIndexFile.AccessMode.READ_ONLY, gp.HEADER_FILE_LOCK_RETRY, gp); ArrayList<byte[]> keyList = entry.value; result.addAll(searchForData(indexFile, keyList.toArray(new byte[keyList.size()][]))); } catch (FileLockException ex) { logger.error("Could not access the file {} within {} retries. The file seems to be locked.", filename, gp.HEADER_FILE_LOCK_RETRY); throw new DRUMSException(ex); } catch (IOException ex) { logger.error("An exception occurred while trying to get objects from the file {}.", filename, ex); throw new DRUMSException(ex); } finally { if (indexFile != null) { indexFile.close(); } } } return result; }
[ "public", "List", "<", "Data", ">", "select", "(", "byte", "[", "]", "...", "keys", ")", "throws", "DRUMSException", "{", "List", "<", "Data", ">", "result", "=", "new", "ArrayList", "<", "Data", ">", "(", ")", ";", "IntObjectOpenHashMap", "<", "ArrayList", "<", "byte", "[", "]", ">", ">", "bucketKeyMapping", "=", "getBucketKeyMapping", "(", "keys", ")", ";", "String", "filename", ";", "for", "(", "IntObjectCursor", "<", "ArrayList", "<", "byte", "[", "]", ">", ">", "entry", ":", "bucketKeyMapping", ")", "{", "filename", "=", "gp", ".", "DATABASE_DIRECTORY", "+", "\"/\"", "+", "hashFunction", ".", "getFilename", "(", "entry", ".", "key", ")", ";", "HeaderIndexFile", "<", "Data", ">", "indexFile", "=", "null", ";", "try", "{", "indexFile", "=", "new", "HeaderIndexFile", "<", "Data", ">", "(", "filename", ",", "HeaderIndexFile", ".", "AccessMode", ".", "READ_ONLY", ",", "gp", ".", "HEADER_FILE_LOCK_RETRY", ",", "gp", ")", ";", "ArrayList", "<", "byte", "[", "]", ">", "keyList", "=", "entry", ".", "value", ";", "result", ".", "addAll", "(", "searchForData", "(", "indexFile", ",", "keyList", ".", "toArray", "(", "new", "byte", "[", "keyList", ".", "size", "(", ")", "]", "[", "", "]", ")", ")", ")", ";", "}", "catch", "(", "FileLockException", "ex", ")", "{", "logger", ".", "error", "(", "\"Could not access the file {} within {} retries. The file seems to be locked.\"", ",", "filename", ",", "gp", ".", "HEADER_FILE_LOCK_RETRY", ")", ";", "throw", "new", "DRUMSException", "(", "ex", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "logger", ".", "error", "(", "\"An exception occurred while trying to get objects from the file {}.\"", ",", "filename", ",", "ex", ")", ";", "throw", "new", "DRUMSException", "(", "ex", ")", ";", "}", "finally", "{", "if", "(", "indexFile", "!=", "null", ")", "{", "indexFile", ".", "close", "(", ")", ";", "}", "}", "}", "return", "result", ";", "}" ]
Selects all existing records to the keys in the given array. @param keys the keys to look for @return a list of all found elements @throws DRUMSException
[ "Selects", "all", "existing", "records", "to", "the", "keys", "in", "the", "given", "array", "." ]
a670f17a2186c9a15725f26617d77ce8e444e072
https://github.com/mgledi/DRUMS/blob/a670f17a2186c9a15725f26617d77ce8e444e072/src/main/java/com/unister/semweb/drums/api/DRUMS.java#L226-L253
151,091
mgledi/DRUMS
src/main/java/com/unister/semweb/drums/api/DRUMS.java
DRUMS.getBucketKeyMapping
protected IntObjectOpenHashMap<ArrayList<byte[]>> getBucketKeyMapping(byte[]... keys) { IntObjectOpenHashMap<ArrayList<byte[]>> bucketKeyMapping = new IntObjectOpenHashMap<ArrayList<byte[]>>(); int bucketId; for (byte[] key : keys) { bucketId = hashFunction.getBucketId(key); if (!bucketKeyMapping.containsKey(bucketId)) { bucketKeyMapping.put(bucketId, new ArrayList<byte[]>()); } bucketKeyMapping.get(bucketId).add(key); } return bucketKeyMapping; }
java
protected IntObjectOpenHashMap<ArrayList<byte[]>> getBucketKeyMapping(byte[]... keys) { IntObjectOpenHashMap<ArrayList<byte[]>> bucketKeyMapping = new IntObjectOpenHashMap<ArrayList<byte[]>>(); int bucketId; for (byte[] key : keys) { bucketId = hashFunction.getBucketId(key); if (!bucketKeyMapping.containsKey(bucketId)) { bucketKeyMapping.put(bucketId, new ArrayList<byte[]>()); } bucketKeyMapping.get(bucketId).add(key); } return bucketKeyMapping; }
[ "protected", "IntObjectOpenHashMap", "<", "ArrayList", "<", "byte", "[", "]", ">", ">", "getBucketKeyMapping", "(", "byte", "[", "]", "...", "keys", ")", "{", "IntObjectOpenHashMap", "<", "ArrayList", "<", "byte", "[", "]", ">", ">", "bucketKeyMapping", "=", "new", "IntObjectOpenHashMap", "<", "ArrayList", "<", "byte", "[", "]", ">", ">", "(", ")", ";", "int", "bucketId", ";", "for", "(", "byte", "[", "]", "key", ":", "keys", ")", "{", "bucketId", "=", "hashFunction", ".", "getBucketId", "(", "key", ")", ";", "if", "(", "!", "bucketKeyMapping", ".", "containsKey", "(", "bucketId", ")", ")", "{", "bucketKeyMapping", ".", "put", "(", "bucketId", ",", "new", "ArrayList", "<", "byte", "[", "]", ">", "(", ")", ")", ";", "}", "bucketKeyMapping", ".", "get", "(", "bucketId", ")", ".", "add", "(", "key", ")", ";", "}", "return", "bucketKeyMapping", ";", "}" ]
This method maps all keys in the given array to their corresponding buckets and returns the determined mapping. @param keys the keys to search for @return a mapping from bucket-id to a list of keys.
[ "This", "method", "maps", "all", "keys", "in", "the", "given", "array", "to", "their", "corresponding", "buckets", "and", "returns", "the", "determined", "mapping", "." ]
a670f17a2186c9a15725f26617d77ce8e444e072
https://github.com/mgledi/DRUMS/blob/a670f17a2186c9a15725f26617d77ce8e444e072/src/main/java/com/unister/semweb/drums/api/DRUMS.java#L302-L313
151,092
mgledi/DRUMS
src/main/java/com/unister/semweb/drums/api/DRUMS.java
DRUMS.size
public long size() throws FileLockException, IOException { long size = 0L; for (int bucketId = 0; bucketId < hashFunction.getNumberOfBuckets(); bucketId++) { HeaderIndexFile<Data> headerIndexFile = new HeaderIndexFile<Data>(gp.DATABASE_DIRECTORY + "/" + hashFunction.getFilename(bucketId), gp.HEADER_FILE_LOCK_RETRY, gp); size += headerIndexFile.getFilledUpFromContentStart() / gp.getElementSize(); headerIndexFile.close(); } return size; }
java
public long size() throws FileLockException, IOException { long size = 0L; for (int bucketId = 0; bucketId < hashFunction.getNumberOfBuckets(); bucketId++) { HeaderIndexFile<Data> headerIndexFile = new HeaderIndexFile<Data>(gp.DATABASE_DIRECTORY + "/" + hashFunction.getFilename(bucketId), gp.HEADER_FILE_LOCK_RETRY, gp); size += headerIndexFile.getFilledUpFromContentStart() / gp.getElementSize(); headerIndexFile.close(); } return size; }
[ "public", "long", "size", "(", ")", "throws", "FileLockException", ",", "IOException", "{", "long", "size", "=", "0L", ";", "for", "(", "int", "bucketId", "=", "0", ";", "bucketId", "<", "hashFunction", ".", "getNumberOfBuckets", "(", ")", ";", "bucketId", "++", ")", "{", "HeaderIndexFile", "<", "Data", ">", "headerIndexFile", "=", "new", "HeaderIndexFile", "<", "Data", ">", "(", "gp", ".", "DATABASE_DIRECTORY", "+", "\"/\"", "+", "hashFunction", ".", "getFilename", "(", "bucketId", ")", ",", "gp", ".", "HEADER_FILE_LOCK_RETRY", ",", "gp", ")", ";", "size", "+=", "headerIndexFile", ".", "getFilledUpFromContentStart", "(", ")", "/", "gp", ".", "getElementSize", "(", ")", ";", "headerIndexFile", ".", "close", "(", ")", ";", "}", "return", "size", ";", "}" ]
Determines the number of elements in each buckets by opening all files. @return the number of elements in the database. @throws IOException @throws FileLockException
[ "Determines", "the", "number", "of", "elements", "in", "each", "buckets", "by", "opening", "all", "files", "." ]
a670f17a2186c9a15725f26617d77ce8e444e072
https://github.com/mgledi/DRUMS/blob/a670f17a2186c9a15725f26617d77ce8e444e072/src/main/java/com/unister/semweb/drums/api/DRUMS.java#L383-L392
151,093
mgledi/DRUMS
src/main/java/com/unister/semweb/drums/api/DRUMS.java
DRUMS.close
public void close() throws InterruptedException { if (reader_instance != null) { reader_instance.closeFiles(); } reader_instance = null; // you can only close a syncmanager, when drums was opened for READ_WRITE if (syncManager != null) { syncManager.shutdown(); syncManager.join(); } }
java
public void close() throws InterruptedException { if (reader_instance != null) { reader_instance.closeFiles(); } reader_instance = null; // you can only close a syncmanager, when drums was opened for READ_WRITE if (syncManager != null) { syncManager.shutdown(); syncManager.join(); } }
[ "public", "void", "close", "(", ")", "throws", "InterruptedException", "{", "if", "(", "reader_instance", "!=", "null", ")", "{", "reader_instance", ".", "closeFiles", "(", ")", ";", "}", "reader_instance", "=", "null", ";", "// you can only close a syncmanager, when drums was opened for READ_WRITE\r", "if", "(", "syncManager", "!=", "null", ")", "{", "syncManager", ".", "shutdown", "(", ")", ";", "syncManager", ".", "join", "(", ")", ";", "}", "}" ]
Closes this DRUMS. @throws InterruptedException
[ "Closes", "this", "DRUMS", "." ]
a670f17a2186c9a15725f26617d77ce8e444e072
https://github.com/mgledi/DRUMS/blob/a670f17a2186c9a15725f26617d77ce8e444e072/src/main/java/com/unister/semweb/drums/api/DRUMS.java#L481-L492
151,094
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/application/libraries/artifacts/maven/MavenPOM.java
MavenPOM.parseVersionSpecification
public static VersionSpecification parseVersionSpecification(String s) { if (s == null) return null; if (s.length() == 0) return null; char c = s.charAt(0); if (c == '[') { int i = s.indexOf(']'); boolean excluded = false; if (i < 0) { i = s.indexOf(')'); if (i > 0) excluded = true; } if (i < 0) { // no end ? consider a unique version return new VersionSpecification.SingleVersion(new Version(s)); } String range = s.substring(1, i).trim(); i = range.indexOf(','); if (i < 0) { // unique version return new VersionSpecification.SingleVersion(new Version(range)); } Version min = new Version(range.substring(0, i).trim()); range = range.substring(i + 1).trim(); Version max; if (range.length() == 0 && excluded) max = null; else max = new Version(range); return new VersionSpecification.Range(new VersionRange(min, max, !excluded)); } // TODO Version v = new Version(s); return new VersionSpecification.RangeWithRecommended(new VersionRange(v, null, false), v); }
java
public static VersionSpecification parseVersionSpecification(String s) { if (s == null) return null; if (s.length() == 0) return null; char c = s.charAt(0); if (c == '[') { int i = s.indexOf(']'); boolean excluded = false; if (i < 0) { i = s.indexOf(')'); if (i > 0) excluded = true; } if (i < 0) { // no end ? consider a unique version return new VersionSpecification.SingleVersion(new Version(s)); } String range = s.substring(1, i).trim(); i = range.indexOf(','); if (i < 0) { // unique version return new VersionSpecification.SingleVersion(new Version(range)); } Version min = new Version(range.substring(0, i).trim()); range = range.substring(i + 1).trim(); Version max; if (range.length() == 0 && excluded) max = null; else max = new Version(range); return new VersionSpecification.Range(new VersionRange(min, max, !excluded)); } // TODO Version v = new Version(s); return new VersionSpecification.RangeWithRecommended(new VersionRange(v, null, false), v); }
[ "public", "static", "VersionSpecification", "parseVersionSpecification", "(", "String", "s", ")", "{", "if", "(", "s", "==", "null", ")", "return", "null", ";", "if", "(", "s", ".", "length", "(", ")", "==", "0", ")", "return", "null", ";", "char", "c", "=", "s", ".", "charAt", "(", "0", ")", ";", "if", "(", "c", "==", "'", "'", ")", "{", "int", "i", "=", "s", ".", "indexOf", "(", "'", "'", ")", ";", "boolean", "excluded", "=", "false", ";", "if", "(", "i", "<", "0", ")", "{", "i", "=", "s", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "i", ">", "0", ")", "excluded", "=", "true", ";", "}", "if", "(", "i", "<", "0", ")", "{", "// no end ? consider a unique version\r", "return", "new", "VersionSpecification", ".", "SingleVersion", "(", "new", "Version", "(", "s", ")", ")", ";", "}", "String", "range", "=", "s", ".", "substring", "(", "1", ",", "i", ")", ".", "trim", "(", ")", ";", "i", "=", "range", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "i", "<", "0", ")", "{", "// unique version\r", "return", "new", "VersionSpecification", ".", "SingleVersion", "(", "new", "Version", "(", "range", ")", ")", ";", "}", "Version", "min", "=", "new", "Version", "(", "range", ".", "substring", "(", "0", ",", "i", ")", ".", "trim", "(", ")", ")", ";", "range", "=", "range", ".", "substring", "(", "i", "+", "1", ")", ".", "trim", "(", ")", ";", "Version", "max", ";", "if", "(", "range", ".", "length", "(", ")", "==", "0", "&&", "excluded", ")", "max", "=", "null", ";", "else", "max", "=", "new", "Version", "(", "range", ")", ";", "return", "new", "VersionSpecification", ".", "Range", "(", "new", "VersionRange", "(", "min", ",", "max", ",", "!", "excluded", ")", ")", ";", "}", "// TODO\r", "Version", "v", "=", "new", "Version", "(", "s", ")", ";", "return", "new", "VersionSpecification", ".", "RangeWithRecommended", "(", "new", "VersionRange", "(", "v", ",", "null", ",", "false", ")", ",", "v", ")", ";", "}" ]
Parse a version specification in POM format.
[ "Parse", "a", "version", "specification", "in", "POM", "format", "." ]
b0c893b44bfde2c03f90ea846a49ef5749d598f3
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/application/libraries/artifacts/maven/MavenPOM.java#L970-L1004
151,095
mwanji/sql-writer
src/main/java/co/mewf/sqlwriter/utils/Strings.java
Strings.chompChomp
public static StringBuilder chompChomp(StringBuilder builder) { return builder.delete(builder.length() - 2, builder.length()); }
java
public static StringBuilder chompChomp(StringBuilder builder) { return builder.delete(builder.length() - 2, builder.length()); }
[ "public", "static", "StringBuilder", "chompChomp", "(", "StringBuilder", "builder", ")", "{", "return", "builder", ".", "delete", "(", "builder", ".", "length", "(", ")", "-", "2", ",", "builder", ".", "length", "(", ")", ")", ";", "}" ]
Deletes the last two characters.
[ "Deletes", "the", "last", "two", "characters", "." ]
319efa92211845d53fb6271650cd42d1b644f463
https://github.com/mwanji/sql-writer/blob/319efa92211845d53fb6271650cd42d1b644f463/src/main/java/co/mewf/sqlwriter/utils/Strings.java#L8-L10
151,096
mgledi/DRUMS
src/main/java/com/unister/semweb/drums/storable/GeneralStructure.java
GeneralStructure.addValuePart
public boolean addValuePart(String name, int size) throws IOException { if (INSTANCE_EXISITS) { throw new IOException("A GeneralStroable was already instantiated. You cant further add Value Parts"); } int hash = Arrays.hashCode(name.getBytes()); int index = valuePartNames.size(); if (valueHash2Index.containsKey(hash)) { logger.error("A valuePart with the name {} already exists", name); return false; } valuePartNames.add(name); valueHash2Index.put(hash, index); valueIndex2Hash.add(hash); valueSizes.add(size); valueByteOffsets.add(valueSize); valueSize += size; return true; }
java
public boolean addValuePart(String name, int size) throws IOException { if (INSTANCE_EXISITS) { throw new IOException("A GeneralStroable was already instantiated. You cant further add Value Parts"); } int hash = Arrays.hashCode(name.getBytes()); int index = valuePartNames.size(); if (valueHash2Index.containsKey(hash)) { logger.error("A valuePart with the name {} already exists", name); return false; } valuePartNames.add(name); valueHash2Index.put(hash, index); valueIndex2Hash.add(hash); valueSizes.add(size); valueByteOffsets.add(valueSize); valueSize += size; return true; }
[ "public", "boolean", "addValuePart", "(", "String", "name", ",", "int", "size", ")", "throws", "IOException", "{", "if", "(", "INSTANCE_EXISITS", ")", "{", "throw", "new", "IOException", "(", "\"A GeneralStroable was already instantiated. You cant further add Value Parts\"", ")", ";", "}", "int", "hash", "=", "Arrays", ".", "hashCode", "(", "name", ".", "getBytes", "(", ")", ")", ";", "int", "index", "=", "valuePartNames", ".", "size", "(", ")", ";", "if", "(", "valueHash2Index", ".", "containsKey", "(", "hash", ")", ")", "{", "logger", ".", "error", "(", "\"A valuePart with the name {} already exists\"", ",", "name", ")", ";", "return", "false", ";", "}", "valuePartNames", ".", "add", "(", "name", ")", ";", "valueHash2Index", ".", "put", "(", "hash", ",", "index", ")", ";", "valueIndex2Hash", ".", "add", "(", "hash", ")", ";", "valueSizes", ".", "add", "(", "size", ")", ";", "valueByteOffsets", ".", "add", "(", "valueSize", ")", ";", "valueSize", "+=", "size", ";", "return", "true", ";", "}" ]
Adds a new ValuePart @param name the name of the key part. With this name you can access this part @param size the size of the key part in bytes @return true if adding the value part was successful @throws IOException
[ "Adds", "a", "new", "ValuePart" ]
a670f17a2186c9a15725f26617d77ce8e444e072
https://github.com/mgledi/DRUMS/blob/a670f17a2186c9a15725f26617d77ce8e444e072/src/main/java/com/unister/semweb/drums/storable/GeneralStructure.java#L82-L99
151,097
mgledi/DRUMS
src/main/java/com/unister/semweb/drums/storable/GeneralStructure.java
GeneralStructure.addKeyPart
public boolean addKeyPart(String name, int size) throws IOException { if (INSTANCE_EXISITS) { throw new IOException("A GeneralStroable was already instantiated. You cant further add Key Parts"); } int hash = Arrays.hashCode(name.getBytes()); int index = keyPartNames.size(); if (keyHash2Index.containsKey(hash)) { logger.error("A keyPart with the name {} already exists", name); return false; } keyPartNames.add(name); keyHash2Index.put(hash, index); keyIndex2Hash.add(hash); keySizes.add(size); keyByteOffsets.add(keySize); keySize += size; return true; }
java
public boolean addKeyPart(String name, int size) throws IOException { if (INSTANCE_EXISITS) { throw new IOException("A GeneralStroable was already instantiated. You cant further add Key Parts"); } int hash = Arrays.hashCode(name.getBytes()); int index = keyPartNames.size(); if (keyHash2Index.containsKey(hash)) { logger.error("A keyPart with the name {} already exists", name); return false; } keyPartNames.add(name); keyHash2Index.put(hash, index); keyIndex2Hash.add(hash); keySizes.add(size); keyByteOffsets.add(keySize); keySize += size; return true; }
[ "public", "boolean", "addKeyPart", "(", "String", "name", ",", "int", "size", ")", "throws", "IOException", "{", "if", "(", "INSTANCE_EXISITS", ")", "{", "throw", "new", "IOException", "(", "\"A GeneralStroable was already instantiated. You cant further add Key Parts\"", ")", ";", "}", "int", "hash", "=", "Arrays", ".", "hashCode", "(", "name", ".", "getBytes", "(", ")", ")", ";", "int", "index", "=", "keyPartNames", ".", "size", "(", ")", ";", "if", "(", "keyHash2Index", ".", "containsKey", "(", "hash", ")", ")", "{", "logger", ".", "error", "(", "\"A keyPart with the name {} already exists\"", ",", "name", ")", ";", "return", "false", ";", "}", "keyPartNames", ".", "add", "(", "name", ")", ";", "keyHash2Index", ".", "put", "(", "hash", ",", "index", ")", ";", "keyIndex2Hash", ".", "add", "(", "hash", ")", ";", "keySizes", ".", "add", "(", "size", ")", ";", "keyByteOffsets", ".", "add", "(", "keySize", ")", ";", "keySize", "+=", "size", ";", "return", "true", ";", "}" ]
Adds a new KeyPart @param name the name of the key part. With this name you can access this part @param size the size of the key part in bytes @return true if adding the key part was successful @throws IOException
[ "Adds", "a", "new", "KeyPart" ]
a670f17a2186c9a15725f26617d77ce8e444e072
https://github.com/mgledi/DRUMS/blob/a670f17a2186c9a15725f26617d77ce8e444e072/src/main/java/com/unister/semweb/drums/storable/GeneralStructure.java#L125-L142
151,098
jtrfp/javamod
src/main/java/de/quippy/javamod/multimedia/mod/mixer/ProTrackerMixer.java
ProTrackerMixer.setPeriodBorders
protected void setPeriodBorders(ChannelMemory aktMemo) { if (frequencyTableType==Helpers.AMIGA_TABLE) { aktMemo.portaStepUpEnd = getFineTunePeriod(aktMemo, Helpers.getNoteIndexForPeriod(113)+1); aktMemo.portaStepDownEnd = getFineTunePeriod(aktMemo, Helpers.getNoteIndexForPeriod(856)+1); } else { aktMemo.portaStepUpEnd = getFineTunePeriod(aktMemo, 119); aktMemo.portaStepDownEnd = getFineTunePeriod(aktMemo, 0); } }
java
protected void setPeriodBorders(ChannelMemory aktMemo) { if (frequencyTableType==Helpers.AMIGA_TABLE) { aktMemo.portaStepUpEnd = getFineTunePeriod(aktMemo, Helpers.getNoteIndexForPeriod(113)+1); aktMemo.portaStepDownEnd = getFineTunePeriod(aktMemo, Helpers.getNoteIndexForPeriod(856)+1); } else { aktMemo.portaStepUpEnd = getFineTunePeriod(aktMemo, 119); aktMemo.portaStepDownEnd = getFineTunePeriod(aktMemo, 0); } }
[ "protected", "void", "setPeriodBorders", "(", "ChannelMemory", "aktMemo", ")", "{", "if", "(", "frequencyTableType", "==", "Helpers", ".", "AMIGA_TABLE", ")", "{", "aktMemo", ".", "portaStepUpEnd", "=", "getFineTunePeriod", "(", "aktMemo", ",", "Helpers", ".", "getNoteIndexForPeriod", "(", "113", ")", "+", "1", ")", ";", "aktMemo", ".", "portaStepDownEnd", "=", "getFineTunePeriod", "(", "aktMemo", ",", "Helpers", ".", "getNoteIndexForPeriod", "(", "856", ")", "+", "1", ")", ";", "}", "else", "{", "aktMemo", ".", "portaStepUpEnd", "=", "getFineTunePeriod", "(", "aktMemo", ",", "119", ")", ";", "aktMemo", ".", "portaStepDownEnd", "=", "getFineTunePeriod", "(", "aktMemo", ",", "0", ")", ";", "}", "}" ]
Sets the borders for Portas @since 17.06.2010 @param aktMemo
[ "Sets", "the", "borders", "for", "Portas" ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/javamod/multimedia/mod/mixer/ProTrackerMixer.java#L49-L61
151,099
jtrfp/javamod
src/main/java/de/quippy/javamod/multimedia/mod/mixer/ProTrackerMixer.java
ProTrackerMixer.resetAllEffects
@Override protected void resetAllEffects(ChannelMemory aktMemo, PatternElement nextElement, boolean forced) { if (aktMemo.arpegioIndex>=0) { aktMemo.arpegioIndex=-1; int nextNotePeriod = aktMemo.arpegioNote[0]; if (nextNotePeriod!=0) { setNewPlayerTuningFor(aktMemo, aktMemo.currentNotePeriod = nextNotePeriod); } } if (aktMemo.vibratoOn) // We have a vibrato for reset { if (forced || (nextElement.getEffekt()!=0x04 && nextElement.getEffekt()!=0x06)) //but only, if there is no vibrato following { aktMemo.vibratoOn = false; if (!aktMemo.vibratoNoRetrig) aktMemo.vibratoTablePos = 0; setNewPlayerTuningFor(aktMemo); } } if (aktMemo.tremoloOn) // We have a tremolo for reset { if (forced || nextElement.getEffekt()!=0x07) //but only, if there is no tremolo following { aktMemo.tremoloOn = false; if (!aktMemo.tremoloNoRetrig) aktMemo.tremoloTablePos = 0; } } if (aktMemo.panbrelloOn) // We have a panbrello for reset { if (forced || nextElement.getEffekt()!=0x22) //but only, if there is no panbrello following { aktMemo.panbrelloOn = false; if (!aktMemo.panbrelloNoRetrig) aktMemo.panbrelloTablePos = 0; } } }
java
@Override protected void resetAllEffects(ChannelMemory aktMemo, PatternElement nextElement, boolean forced) { if (aktMemo.arpegioIndex>=0) { aktMemo.arpegioIndex=-1; int nextNotePeriod = aktMemo.arpegioNote[0]; if (nextNotePeriod!=0) { setNewPlayerTuningFor(aktMemo, aktMemo.currentNotePeriod = nextNotePeriod); } } if (aktMemo.vibratoOn) // We have a vibrato for reset { if (forced || (nextElement.getEffekt()!=0x04 && nextElement.getEffekt()!=0x06)) //but only, if there is no vibrato following { aktMemo.vibratoOn = false; if (!aktMemo.vibratoNoRetrig) aktMemo.vibratoTablePos = 0; setNewPlayerTuningFor(aktMemo); } } if (aktMemo.tremoloOn) // We have a tremolo for reset { if (forced || nextElement.getEffekt()!=0x07) //but only, if there is no tremolo following { aktMemo.tremoloOn = false; if (!aktMemo.tremoloNoRetrig) aktMemo.tremoloTablePos = 0; } } if (aktMemo.panbrelloOn) // We have a panbrello for reset { if (forced || nextElement.getEffekt()!=0x22) //but only, if there is no panbrello following { aktMemo.panbrelloOn = false; if (!aktMemo.panbrelloNoRetrig) aktMemo.panbrelloTablePos = 0; } } }
[ "@", "Override", "protected", "void", "resetAllEffects", "(", "ChannelMemory", "aktMemo", ",", "PatternElement", "nextElement", ",", "boolean", "forced", ")", "{", "if", "(", "aktMemo", ".", "arpegioIndex", ">=", "0", ")", "{", "aktMemo", ".", "arpegioIndex", "=", "-", "1", ";", "int", "nextNotePeriod", "=", "aktMemo", ".", "arpegioNote", "[", "0", "]", ";", "if", "(", "nextNotePeriod", "!=", "0", ")", "{", "setNewPlayerTuningFor", "(", "aktMemo", ",", "aktMemo", ".", "currentNotePeriod", "=", "nextNotePeriod", ")", ";", "}", "}", "if", "(", "aktMemo", ".", "vibratoOn", ")", "// We have a vibrato for reset", "{", "if", "(", "forced", "||", "(", "nextElement", ".", "getEffekt", "(", ")", "!=", "0x04", "&&", "nextElement", ".", "getEffekt", "(", ")", "!=", "0x06", ")", ")", "//but only, if there is no vibrato following", "{", "aktMemo", ".", "vibratoOn", "=", "false", ";", "if", "(", "!", "aktMemo", ".", "vibratoNoRetrig", ")", "aktMemo", ".", "vibratoTablePos", "=", "0", ";", "setNewPlayerTuningFor", "(", "aktMemo", ")", ";", "}", "}", "if", "(", "aktMemo", ".", "tremoloOn", ")", "// We have a tremolo for reset", "{", "if", "(", "forced", "||", "nextElement", ".", "getEffekt", "(", ")", "!=", "0x07", ")", "//but only, if there is no tremolo following", "{", "aktMemo", ".", "tremoloOn", "=", "false", ";", "if", "(", "!", "aktMemo", ".", "tremoloNoRetrig", ")", "aktMemo", ".", "tremoloTablePos", "=", "0", ";", "}", "}", "if", "(", "aktMemo", ".", "panbrelloOn", ")", "// We have a panbrello for reset", "{", "if", "(", "forced", "||", "nextElement", ".", "getEffekt", "(", ")", "!=", "0x22", ")", "//but only, if there is no panbrello following", "{", "aktMemo", ".", "panbrelloOn", "=", "false", ";", "if", "(", "!", "aktMemo", ".", "panbrelloNoRetrig", ")", "aktMemo", ".", "panbrelloTablePos", "=", "0", ";", "}", "}", "}" ]
Clear all effekts. Sometimes, if Effekts do continue, they are not stopped. @param aktMemo @param nextElement
[ "Clear", "all", "effekts", ".", "Sometimes", "if", "Effekts", "do", "continue", "they", "are", "not", "stopped", "." ]
cda4fe943a589dc49415f4413453e2eece72076a
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/javamod/multimedia/mod/mixer/ProTrackerMixer.java#L77-L114