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
11,100
arquillian/arquillian-algeron
common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java
GitOperations.checkoutTag
public Ref checkoutTag(Git git, String tag) { try { return git.checkout() .setName("tags/" + tag).call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
java
public Ref checkoutTag(Git git, String tag) { try { return git.checkout() .setName("tags/" + tag).call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
[ "public", "Ref", "checkoutTag", "(", "Git", "git", ",", "String", "tag", ")", "{", "try", "{", "return", "git", ".", "checkout", "(", ")", ".", "setName", "(", "\"tags/\"", "+", "tag", ")", ".", "call", "(", ")", ";", "}", "catch", "(", "GitAPIException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}" ]
Checkout existing tag. @param git instance. @param tag to move @return Ref to current branch
[ "Checkout", "existing", "tag", "." ]
ec79372defdafe99ab2f7bb696f1c1eabdbbacb6
https://github.com/arquillian/arquillian-algeron/blob/ec79372defdafe99ab2f7bb696f1c1eabdbbacb6/common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java#L78-L85
11,101
arquillian/arquillian-algeron
common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java
GitOperations.isLocalBranch
public boolean isLocalBranch(final Git git, final String branch) { try { final List<Ref> refs = git.branchList().call(); return refs.stream() .anyMatch(ref -> ref.getName().endsWith(branch)); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
java
public boolean isLocalBranch(final Git git, final String branch) { try { final List<Ref> refs = git.branchList().call(); return refs.stream() .anyMatch(ref -> ref.getName().endsWith(branch)); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
[ "public", "boolean", "isLocalBranch", "(", "final", "Git", "git", ",", "final", "String", "branch", ")", "{", "try", "{", "final", "List", "<", "Ref", ">", "refs", "=", "git", ".", "branchList", "(", ")", ".", "call", "(", ")", ";", "return", "refs", ".", "stream", "(", ")", ".", "anyMatch", "(", "ref", "->", "ref", ".", "getName", "(", ")", ".", "endsWith", "(", "branch", ")", ")", ";", "}", "catch", "(", "GitAPIException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}" ]
Checks if given branch has been checkedout locally too. @param git instance. @param branch to check. @return True if it is local, false otherwise.
[ "Checks", "if", "given", "branch", "has", "been", "checkedout", "locally", "too", "." ]
ec79372defdafe99ab2f7bb696f1c1eabdbbacb6
https://github.com/arquillian/arquillian-algeron/blob/ec79372defdafe99ab2f7bb696f1c1eabdbbacb6/common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java#L97-L105
11,102
arquillian/arquillian-algeron
common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java
GitOperations.isRemoteBranch
public boolean isRemoteBranch(final Git git, final String branch, final String remote) { try { final List<Ref> refs = git.branchList() .setListMode(ListBranchCommand.ListMode.REMOTE).call(); final String remoteBranch = remote + "/" + branch; return refs.stream().anyMatch(ref -> ref.getName().endsWith(remoteBranch)); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
java
public boolean isRemoteBranch(final Git git, final String branch, final String remote) { try { final List<Ref> refs = git.branchList() .setListMode(ListBranchCommand.ListMode.REMOTE).call(); final String remoteBranch = remote + "/" + branch; return refs.stream().anyMatch(ref -> ref.getName().endsWith(remoteBranch)); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
[ "public", "boolean", "isRemoteBranch", "(", "final", "Git", "git", ",", "final", "String", "branch", ",", "final", "String", "remote", ")", "{", "try", "{", "final", "List", "<", "Ref", ">", "refs", "=", "git", ".", "branchList", "(", ")", ".", "setListMode", "(", "ListBranchCommand", ".", "ListMode", ".", "REMOTE", ")", ".", "call", "(", ")", ";", "final", "String", "remoteBranch", "=", "remote", "+", "\"/\"", "+", "branch", ";", "return", "refs", ".", "stream", "(", ")", ".", "anyMatch", "(", "ref", "->", "ref", ".", "getName", "(", ")", ".", "endsWith", "(", "remoteBranch", ")", ")", ";", "}", "catch", "(", "GitAPIException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}" ]
Checks if given branch is remote. @param git instance. @param branch to check. @param remote name. @return True if it is remote, false otherwise.
[ "Checks", "if", "given", "branch", "is", "remote", "." ]
ec79372defdafe99ab2f7bb696f1c1eabdbbacb6
https://github.com/arquillian/arquillian-algeron/blob/ec79372defdafe99ab2f7bb696f1c1eabdbbacb6/common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java#L119-L129
11,103
arquillian/arquillian-algeron
common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java
GitOperations.checkoutBranch
public Ref checkoutBranch(Git git, String branch) { try { return git.checkout() .setName(branch) .call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
java
public Ref checkoutBranch(Git git, String branch) { try { return git.checkout() .setName(branch) .call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
[ "public", "Ref", "checkoutBranch", "(", "Git", "git", ",", "String", "branch", ")", "{", "try", "{", "return", "git", ".", "checkout", "(", ")", ".", "setName", "(", "branch", ")", ".", "call", "(", ")", ";", "}", "catch", "(", "GitAPIException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}" ]
Checkout existing branch. @param git instance. @param branch to move @return Ref to current branch
[ "Checkout", "existing", "branch", "." ]
ec79372defdafe99ab2f7bb696f1c1eabdbbacb6
https://github.com/arquillian/arquillian-algeron/blob/ec79372defdafe99ab2f7bb696f1c1eabdbbacb6/common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java#L141-L149
11,104
arquillian/arquillian-algeron
common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java
GitOperations.createBranchAndCheckout
public Ref createBranchAndCheckout(Git git, String branch) { try { return git.checkout() .setCreateBranch(true) .setName(branch) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK) .call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
java
public Ref createBranchAndCheckout(Git git, String branch) { try { return git.checkout() .setCreateBranch(true) .setName(branch) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK) .call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
[ "public", "Ref", "createBranchAndCheckout", "(", "Git", "git", ",", "String", "branch", ")", "{", "try", "{", "return", "git", ".", "checkout", "(", ")", ".", "setCreateBranch", "(", "true", ")", ".", "setName", "(", "branch", ")", ".", "setUpstreamMode", "(", "CreateBranchCommand", ".", "SetupUpstreamMode", ".", "TRACK", ")", ".", "call", "(", ")", ";", "}", "catch", "(", "GitAPIException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}" ]
Executes a checkout -b command using given branch. @param git instance. @param branch to create and checkout. @return Ref to current branch.
[ "Executes", "a", "checkout", "-", "b", "command", "using", "given", "branch", "." ]
ec79372defdafe99ab2f7bb696f1c1eabdbbacb6
https://github.com/arquillian/arquillian-algeron/blob/ec79372defdafe99ab2f7bb696f1c1eabdbbacb6/common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java#L186-L196
11,105
arquillian/arquillian-algeron
common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java
GitOperations.addAndCommit
public RevCommit addAndCommit(Git git, String message) { try { git.add() .addFilepattern(".") .call(); return git.commit() .setMessage(message) .call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
java
public RevCommit addAndCommit(Git git, String message) { try { git.add() .addFilepattern(".") .call(); return git.commit() .setMessage(message) .call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
[ "public", "RevCommit", "addAndCommit", "(", "Git", "git", ",", "String", "message", ")", "{", "try", "{", "git", ".", "add", "(", ")", ".", "addFilepattern", "(", "\".\"", ")", ".", "call", "(", ")", ";", "return", "git", ".", "commit", "(", ")", ".", "setMessage", "(", "message", ")", ".", "call", "(", ")", ";", "}", "catch", "(", "GitAPIException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}" ]
Add all files and commit them with given message. This is equivalent as doing git add . git commit -m "message". @param git instance. @param message of the commit. @return RevCommit of this commit.
[ "Add", "all", "files", "and", "commit", "them", "with", "given", "message", ".", "This", "is", "equivalent", "as", "doing", "git", "add", ".", "git", "commit", "-", "m", "message", "." ]
ec79372defdafe99ab2f7bb696f1c1eabdbbacb6
https://github.com/arquillian/arquillian-algeron/blob/ec79372defdafe99ab2f7bb696f1c1eabdbbacb6/common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java#L208-L219
11,106
arquillian/arquillian-algeron
common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java
GitOperations.createTag
public Ref createTag(Git git, String name) { try { return git.tag() .setName(name) .call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
java
public Ref createTag(Git git, String name) { try { return git.tag() .setName(name) .call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
[ "public", "Ref", "createTag", "(", "Git", "git", ",", "String", "name", ")", "{", "try", "{", "return", "git", ".", "tag", "(", ")", ".", "setName", "(", "name", ")", ".", "call", "(", ")", ";", "}", "catch", "(", "GitAPIException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}" ]
Creates a tag. @param git instance. @param name of the tag. @return Ref created to tag.
[ "Creates", "a", "tag", "." ]
ec79372defdafe99ab2f7bb696f1c1eabdbbacb6
https://github.com/arquillian/arquillian-algeron/blob/ec79372defdafe99ab2f7bb696f1c1eabdbbacb6/common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java#L329-L337
11,107
arquillian/arquillian-algeron
common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java
GitOperations.cloneRepository
public Git cloneRepository(String remoteUrl, Path localPath) { try { return Git.cloneRepository() .setURI(remoteUrl) .setDirectory(localPath.toFile()) .call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
java
public Git cloneRepository(String remoteUrl, Path localPath) { try { return Git.cloneRepository() .setURI(remoteUrl) .setDirectory(localPath.toFile()) .call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
[ "public", "Git", "cloneRepository", "(", "String", "remoteUrl", ",", "Path", "localPath", ")", "{", "try", "{", "return", "Git", ".", "cloneRepository", "(", ")", ".", "setURI", "(", "remoteUrl", ")", ".", "setDirectory", "(", "localPath", ".", "toFile", "(", ")", ")", ".", "call", "(", ")", ";", "}", "catch", "(", "GitAPIException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}" ]
Clones a public remote git repository. Caller is responsible of closing git repository. @param remoteUrl to connect. @param localPath where to clone the repo. @return Git instance. Caller is responsible to close the connection.
[ "Clones", "a", "public", "remote", "git", "repository", ".", "Caller", "is", "responsible", "of", "closing", "git", "repository", "." ]
ec79372defdafe99ab2f7bb696f1c1eabdbbacb6
https://github.com/arquillian/arquillian-algeron/blob/ec79372defdafe99ab2f7bb696f1c1eabdbbacb6/common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java#L471-L480
11,108
arquillian/arquillian-algeron
common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java
GitOperations.hasAtLeastOneReference
public boolean hasAtLeastOneReference(Repository repo) { for (Ref ref : repo.getAllRefs().values()) { if (ref.getObjectId() == null) continue; return true; } return false; }
java
public boolean hasAtLeastOneReference(Repository repo) { for (Ref ref : repo.getAllRefs().values()) { if (ref.getObjectId() == null) continue; return true; } return false; }
[ "public", "boolean", "hasAtLeastOneReference", "(", "Repository", "repo", ")", "{", "for", "(", "Ref", "ref", ":", "repo", ".", "getAllRefs", "(", ")", ".", "values", "(", ")", ")", "{", "if", "(", "ref", ".", "getObjectId", "(", ")", "==", "null", ")", "continue", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks if a repo has been cloned correctly. @param repo to check @return true if has been cloned correctly, false otherwise
[ "Checks", "if", "a", "repo", "has", "been", "cloned", "correctly", "." ]
ec79372defdafe99ab2f7bb696f1c1eabdbbacb6
https://github.com/arquillian/arquillian-algeron/blob/ec79372defdafe99ab2f7bb696f1c1eabdbbacb6/common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java#L565-L574
11,109
shrinkwrap/descriptors
spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/Node.java
Node.removeChildren
public List<Node> removeChildren(final String name) throws IllegalArgumentException { if (name == null || name.trim().length() == 0) { throw new IllegalArgumentException("Path must not be null or empty"); } List<Node> found = get(name); for (Node child : found) { children.remove(child); } return found; }
java
public List<Node> removeChildren(final String name) throws IllegalArgumentException { if (name == null || name.trim().length() == 0) { throw new IllegalArgumentException("Path must not be null or empty"); } List<Node> found = get(name); for (Node child : found) { children.remove(child); } return found; }
[ "public", "List", "<", "Node", ">", "removeChildren", "(", "final", "String", "name", ")", "throws", "IllegalArgumentException", "{", "if", "(", "name", "==", "null", "||", "name", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Path must not be null or empty\"", ")", ";", "}", "List", "<", "Node", ">", "found", "=", "get", "(", "name", ")", ";", "for", "(", "Node", "child", ":", "found", ")", "{", "children", ".", "remove", "(", "child", ")", ";", "}", "return", "found", ";", "}" ]
Remove all child nodes found at the given query. @return the {@link List} of removed children. @throws IllegalArgumentException If the specified name is not specified
[ "Remove", "all", "child", "nodes", "found", "at", "the", "given", "query", "." ]
023ba080e6396b9f4dd8275dc4e5c0ebb6b5e6ba
https://github.com/shrinkwrap/descriptors/blob/023ba080e6396b9f4dd8275dc4e5c0ebb6b5e6ba/spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/Node.java#L350-L360
11,110
shrinkwrap/descriptors
spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/Node.java
Node.getTextValueForPatternName
public String getTextValueForPatternName(final String name) { Node n = this.getSingle(name); String text = n == null ? null : n.getText(); return text; }
java
public String getTextValueForPatternName(final String name) { Node n = this.getSingle(name); String text = n == null ? null : n.getText(); return text; }
[ "public", "String", "getTextValueForPatternName", "(", "final", "String", "name", ")", "{", "Node", "n", "=", "this", ".", "getSingle", "(", "name", ")", ";", "String", "text", "=", "n", "==", "null", "?", "null", ":", "n", ".", "getText", "(", ")", ";", "return", "text", ";", "}" ]
Get the text value of the element found at the given query name. If no element is found, or no text exists, return null;
[ "Get", "the", "text", "value", "of", "the", "element", "found", "at", "the", "given", "query", "name", ".", "If", "no", "element", "is", "found", "or", "no", "text", "exists", "return", "null", ";" ]
023ba080e6396b9f4dd8275dc4e5c0ebb6b5e6ba
https://github.com/shrinkwrap/descriptors/blob/023ba080e6396b9f4dd8275dc4e5c0ebb6b5e6ba/spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/Node.java#L449-L453
11,111
shrinkwrap/descriptors
spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/Node.java
Node.getTextValuesForPatternName
public List<String> getTextValuesForPatternName(final String name) { List<String> result = new ArrayList<String>(); List<Node> jars = this.get(name); for (Node node : jars) { String text = node.getText(); if (text != null) { result.add(text); } } return Collections.unmodifiableList(result); }
java
public List<String> getTextValuesForPatternName(final String name) { List<String> result = new ArrayList<String>(); List<Node> jars = this.get(name); for (Node node : jars) { String text = node.getText(); if (text != null) { result.add(text); } } return Collections.unmodifiableList(result); }
[ "public", "List", "<", "String", ">", "getTextValuesForPatternName", "(", "final", "String", "name", ")", "{", "List", "<", "String", ">", "result", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "List", "<", "Node", ">", "jars", "=", "this", ".", "get", "(", "name", ")", ";", "for", "(", "Node", "node", ":", "jars", ")", "{", "String", "text", "=", "node", ".", "getText", "(", ")", ";", "if", "(", "text", "!=", "null", ")", "{", "result", ".", "add", "(", "text", ")", ";", "}", "}", "return", "Collections", ".", "unmodifiableList", "(", "result", ")", ";", "}" ]
Get the text values of all elements found at the given query name. If no elements are found, or no text exists, return an empty list;
[ "Get", "the", "text", "values", "of", "all", "elements", "found", "at", "the", "given", "query", "name", ".", "If", "no", "elements", "are", "found", "or", "no", "text", "exists", "return", "an", "empty", "list", ";" ]
023ba080e6396b9f4dd8275dc4e5c0ebb6b5e6ba
https://github.com/shrinkwrap/descriptors/blob/023ba080e6396b9f4dd8275dc4e5c0ebb6b5e6ba/spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/Node.java#L459-L469
11,112
shrinkwrap/descriptors
spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/Node.java
Node.validateAndMergePatternInput
private Pattern[] validateAndMergePatternInput(final Pattern pattern, final Pattern... patterns) { // Precondition check if (pattern == null) { throw new IllegalArgumentException("At least one pattern must not be specified"); } final List<Pattern> merged = new ArrayList<Pattern>(); merged.add(pattern); for (final Pattern p : patterns) { merged.add(p); } return merged.toArray(PATTERN_CAST); }
java
private Pattern[] validateAndMergePatternInput(final Pattern pattern, final Pattern... patterns) { // Precondition check if (pattern == null) { throw new IllegalArgumentException("At least one pattern must not be specified"); } final List<Pattern> merged = new ArrayList<Pattern>(); merged.add(pattern); for (final Pattern p : patterns) { merged.add(p); } return merged.toArray(PATTERN_CAST); }
[ "private", "Pattern", "[", "]", "validateAndMergePatternInput", "(", "final", "Pattern", "pattern", ",", "final", "Pattern", "...", "patterns", ")", "{", "// Precondition check", "if", "(", "pattern", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"At least one pattern must not be specified\"", ")", ";", "}", "final", "List", "<", "Pattern", ">", "merged", "=", "new", "ArrayList", "<", "Pattern", ">", "(", ")", ";", "merged", ".", "add", "(", "pattern", ")", ";", "for", "(", "final", "Pattern", "p", ":", "patterns", ")", "{", "merged", ".", "add", "(", "p", ")", ";", "}", "return", "merged", ".", "toArray", "(", "PATTERN_CAST", ")", ";", "}" ]
Validates that at least one pattern was specified, merges all patterns together, and returns the result @param pattern @param patterns @return
[ "Validates", "that", "at", "least", "one", "pattern", "was", "specified", "merges", "all", "patterns", "together", "and", "returns", "the", "result" ]
023ba080e6396b9f4dd8275dc4e5c0ebb6b5e6ba
https://github.com/shrinkwrap/descriptors/blob/023ba080e6396b9f4dd8275dc4e5c0ebb6b5e6ba/spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/Node.java#L619-L630
11,113
shrinkwrap/descriptors
api-base/src/main/java/org/jboss/shrinkwrap/descriptor/api/Descriptors.java
Descriptors.create
public static <T extends Descriptor> T create(final Class<T> type) throws IllegalArgumentException { return create(type, null); }
java
public static <T extends Descriptor> T create(final Class<T> type) throws IllegalArgumentException { return create(type, null); }
[ "public", "static", "<", "T", "extends", "Descriptor", ">", "T", "create", "(", "final", "Class", "<", "T", ">", "type", ")", "throws", "IllegalArgumentException", "{", "return", "create", "(", "type", ",", "null", ")", ";", "}" ]
Creates a new Descriptor instance; the predefined default descriptor name for this type will be used. @param <T> @param type @return @see #create(Class, String) @throws IllegalArgumentException If the type is not specified
[ "Creates", "a", "new", "Descriptor", "instance", ";", "the", "predefined", "default", "descriptor", "name", "for", "this", "type", "will", "be", "used", "." ]
023ba080e6396b9f4dd8275dc4e5c0ebb6b5e6ba
https://github.com/shrinkwrap/descriptors/blob/023ba080e6396b9f4dd8275dc4e5c0ebb6b5e6ba/api-base/src/main/java/org/jboss/shrinkwrap/descriptor/api/Descriptors.java#L45-L47
11,114
shrinkwrap/descriptors
metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/codegen/CodeGen.java
CodeGen.generateEnums
public void generateEnums() throws JClassAlreadyExistsException, IOException { final JCodeModel cm = new JCodeModel(); for (final MetadataEnum metadataEnum : metadata.getEnumList()) { final String fqnEnum = metadataEnum.getPackageApi() + "." + getPascalizeCase(metadataEnum.getName()); final JDefinedClass dc = cm._class(fqnEnum, ClassType.ENUM); final JDocComment javaDocComment = dc.javadoc(); final Map<String, String> part = javaDocComment.addXdoclet("author"); part.put("<a href", "'mailto:ralf.battenfeld@bluewin.ch'>Ralf Battenfeld</a>"); for (final String enumConstant : metadataEnum.getValueList()) { dc.enumConstant(getEnumConstantName(enumConstant)); } final JMethod toStringMethod = dc.method(1, String.class, "toString"); toStringMethod.body()._return(JExpr.direct("name().substring(1)")); } final File file = new File("./src/test/java"); file.mkdirs(); cm.build(file); }
java
public void generateEnums() throws JClassAlreadyExistsException, IOException { final JCodeModel cm = new JCodeModel(); for (final MetadataEnum metadataEnum : metadata.getEnumList()) { final String fqnEnum = metadataEnum.getPackageApi() + "." + getPascalizeCase(metadataEnum.getName()); final JDefinedClass dc = cm._class(fqnEnum, ClassType.ENUM); final JDocComment javaDocComment = dc.javadoc(); final Map<String, String> part = javaDocComment.addXdoclet("author"); part.put("<a href", "'mailto:ralf.battenfeld@bluewin.ch'>Ralf Battenfeld</a>"); for (final String enumConstant : metadataEnum.getValueList()) { dc.enumConstant(getEnumConstantName(enumConstant)); } final JMethod toStringMethod = dc.method(1, String.class, "toString"); toStringMethod.body()._return(JExpr.direct("name().substring(1)")); } final File file = new File("./src/test/java"); file.mkdirs(); cm.build(file); }
[ "public", "void", "generateEnums", "(", ")", "throws", "JClassAlreadyExistsException", ",", "IOException", "{", "final", "JCodeModel", "cm", "=", "new", "JCodeModel", "(", ")", ";", "for", "(", "final", "MetadataEnum", "metadataEnum", ":", "metadata", ".", "getEnumList", "(", ")", ")", "{", "final", "String", "fqnEnum", "=", "metadataEnum", ".", "getPackageApi", "(", ")", "+", "\".\"", "+", "getPascalizeCase", "(", "metadataEnum", ".", "getName", "(", ")", ")", ";", "final", "JDefinedClass", "dc", "=", "cm", ".", "_class", "(", "fqnEnum", ",", "ClassType", ".", "ENUM", ")", ";", "final", "JDocComment", "javaDocComment", "=", "dc", ".", "javadoc", "(", ")", ";", "final", "Map", "<", "String", ",", "String", ">", "part", "=", "javaDocComment", ".", "addXdoclet", "(", "\"author\"", ")", ";", "part", ".", "put", "(", "\"<a href\"", ",", "\"'mailto:ralf.battenfeld@bluewin.ch'>Ralf Battenfeld</a>\"", ")", ";", "for", "(", "final", "String", "enumConstant", ":", "metadataEnum", ".", "getValueList", "(", ")", ")", "{", "dc", ".", "enumConstant", "(", "getEnumConstantName", "(", "enumConstant", ")", ")", ";", "}", "final", "JMethod", "toStringMethod", "=", "dc", ".", "method", "(", "1", ",", "String", ".", "class", ",", "\"toString\"", ")", ";", "toStringMethod", ".", "body", "(", ")", ".", "_return", "(", "JExpr", ".", "direct", "(", "\"name().substring(1)\"", ")", ")", ";", "}", "final", "File", "file", "=", "new", "File", "(", "\"./src/test/java\"", ")", ";", "file", ".", "mkdirs", "(", ")", ";", "cm", ".", "build", "(", "file", ")", ";", "}" ]
Generates all enumeration classes. @param metadata @throws JClassAlreadyExistsException @throws IOException
[ "Generates", "all", "enumeration", "classes", "." ]
023ba080e6396b9f4dd8275dc4e5c0ebb6b5e6ba
https://github.com/shrinkwrap/descriptors/blob/023ba080e6396b9f4dd8275dc4e5c0ebb6b5e6ba/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/codegen/CodeGen.java#L77-L97
11,115
shrinkwrap/descriptors
metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/codegen/CodeGen.java
CodeGen.isEnum
public boolean isEnum(final String elementType) { final String namespace = splitElementType(elementType)[0]; final String localname = splitElementType(elementType)[1]; boolean isEnum = false; for (final MetadataEnum metadataEnum : metadata.getEnumList()) { if (metadataEnum.getName().equals(localname) && metadataEnum.getNamespace().equals(namespace)) { isEnum = true; break; } } return isEnum; }
java
public boolean isEnum(final String elementType) { final String namespace = splitElementType(elementType)[0]; final String localname = splitElementType(elementType)[1]; boolean isEnum = false; for (final MetadataEnum metadataEnum : metadata.getEnumList()) { if (metadataEnum.getName().equals(localname) && metadataEnum.getNamespace().equals(namespace)) { isEnum = true; break; } } return isEnum; }
[ "public", "boolean", "isEnum", "(", "final", "String", "elementType", ")", "{", "final", "String", "namespace", "=", "splitElementType", "(", "elementType", ")", "[", "0", "]", ";", "final", "String", "localname", "=", "splitElementType", "(", "elementType", ")", "[", "1", "]", ";", "boolean", "isEnum", "=", "false", ";", "for", "(", "final", "MetadataEnum", "metadataEnum", ":", "metadata", ".", "getEnumList", "(", ")", ")", "{", "if", "(", "metadataEnum", ".", "getName", "(", ")", ".", "equals", "(", "localname", ")", "&&", "metadataEnum", ".", "getNamespace", "(", ")", ".", "equals", "(", "namespace", ")", ")", "{", "isEnum", "=", "true", ";", "break", ";", "}", "}", "return", "isEnum", ";", "}" ]
Returns true, if the given string argument represents a enumeration class. @param elementName @return true, if the string represents a enumeration, otherwise false.
[ "Returns", "true", "if", "the", "given", "string", "argument", "represents", "a", "enumeration", "class", "." ]
023ba080e6396b9f4dd8275dc4e5c0ebb6b5e6ba
https://github.com/shrinkwrap/descriptors/blob/023ba080e6396b9f4dd8275dc4e5c0ebb6b5e6ba/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/codegen/CodeGen.java#L211-L224
11,116
craftercms/profile
security-provider/src/main/java/org/craftercms/security/utils/SecurityUtils.java
SecurityUtils.getProfileLastModifiedCookie
public static Long getProfileLastModifiedCookie(HttpServletRequest request) { String profileLastModified = HttpUtils.getCookieValue(PROFILE_LAST_MODIFIED_COOKIE_NAME, request); if (StringUtils.isNotEmpty(profileLastModified)) { try { return new Long(profileLastModified); } catch (NumberFormatException e) { logger.error("Invalid profile last modified cookie format: {}", profileLastModified); } } return null; }
java
public static Long getProfileLastModifiedCookie(HttpServletRequest request) { String profileLastModified = HttpUtils.getCookieValue(PROFILE_LAST_MODIFIED_COOKIE_NAME, request); if (StringUtils.isNotEmpty(profileLastModified)) { try { return new Long(profileLastModified); } catch (NumberFormatException e) { logger.error("Invalid profile last modified cookie format: {}", profileLastModified); } } return null; }
[ "public", "static", "Long", "getProfileLastModifiedCookie", "(", "HttpServletRequest", "request", ")", "{", "String", "profileLastModified", "=", "HttpUtils", ".", "getCookieValue", "(", "PROFILE_LAST_MODIFIED_COOKIE_NAME", ",", "request", ")", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "profileLastModified", ")", ")", "{", "try", "{", "return", "new", "Long", "(", "profileLastModified", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "logger", ".", "error", "(", "\"Invalid profile last modified cookie format: {}\"", ",", "profileLastModified", ")", ";", "}", "}", "return", "null", ";", "}" ]
Returns the last modified timestamp cookie from the request. @param request the request where to retrieve the last modified timestamp from @return the last modified timestamp of the authenticated profile
[ "Returns", "the", "last", "modified", "timestamp", "cookie", "from", "the", "request", "." ]
d829c1136b0fd21d87dc925cb7046cbd38a300a4
https://github.com/craftercms/profile/blob/d829c1136b0fd21d87dc925cb7046cbd38a300a4/security-provider/src/main/java/org/craftercms/security/utils/SecurityUtils.java#L68-L79
11,117
craftercms/profile
security-provider/src/main/java/org/craftercms/security/utils/SecurityUtils.java
SecurityUtils.getCurrentAuthentication
public static Authentication getCurrentAuthentication() { RequestContext context = RequestContext.getCurrent(); if (context != null) { return getAuthentication(context.getRequest()); } else { return null; } }
java
public static Authentication getCurrentAuthentication() { RequestContext context = RequestContext.getCurrent(); if (context != null) { return getAuthentication(context.getRequest()); } else { return null; } }
[ "public", "static", "Authentication", "getCurrentAuthentication", "(", ")", "{", "RequestContext", "context", "=", "RequestContext", ".", "getCurrent", "(", ")", ";", "if", "(", "context", "!=", "null", ")", "{", "return", "getAuthentication", "(", "context", ".", "getRequest", "(", ")", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Returns the authentication attribute from the current request. @return the authentication object
[ "Returns", "the", "authentication", "attribute", "from", "the", "current", "request", "." ]
d829c1136b0fd21d87dc925cb7046cbd38a300a4
https://github.com/craftercms/profile/blob/d829c1136b0fd21d87dc925cb7046cbd38a300a4/security-provider/src/main/java/org/craftercms/security/utils/SecurityUtils.java#L86-L93
11,118
craftercms/profile
security-provider/src/main/java/org/craftercms/security/utils/SecurityUtils.java
SecurityUtils.setCurrentAuthentication
public static void setCurrentAuthentication(Authentication authentication) { RequestContext context = RequestContext.getCurrent(); if (context != null) { setAuthentication(context.getRequest(), authentication); } }
java
public static void setCurrentAuthentication(Authentication authentication) { RequestContext context = RequestContext.getCurrent(); if (context != null) { setAuthentication(context.getRequest(), authentication); } }
[ "public", "static", "void", "setCurrentAuthentication", "(", "Authentication", "authentication", ")", "{", "RequestContext", "context", "=", "RequestContext", ".", "getCurrent", "(", ")", ";", "if", "(", "context", "!=", "null", ")", "{", "setAuthentication", "(", "context", ".", "getRequest", "(", ")", ",", "authentication", ")", ";", "}", "}" ]
Sets the authentication attribute in the current request. @param authentication the authentication object to set as request attribute
[ "Sets", "the", "authentication", "attribute", "in", "the", "current", "request", "." ]
d829c1136b0fd21d87dc925cb7046cbd38a300a4
https://github.com/craftercms/profile/blob/d829c1136b0fd21d87dc925cb7046cbd38a300a4/security-provider/src/main/java/org/craftercms/security/utils/SecurityUtils.java#L100-L105
11,119
craftercms/profile
security-provider/src/main/java/org/craftercms/security/utils/SecurityUtils.java
SecurityUtils.removeCurrentAuthentication
public static void removeCurrentAuthentication() { RequestContext context = RequestContext.getCurrent(); if (context != null) { removeAuthentication(context.getRequest()); } }
java
public static void removeCurrentAuthentication() { RequestContext context = RequestContext.getCurrent(); if (context != null) { removeAuthentication(context.getRequest()); } }
[ "public", "static", "void", "removeCurrentAuthentication", "(", ")", "{", "RequestContext", "context", "=", "RequestContext", ".", "getCurrent", "(", ")", ";", "if", "(", "context", "!=", "null", ")", "{", "removeAuthentication", "(", "context", ".", "getRequest", "(", ")", ")", ";", "}", "}" ]
Removes the authentication attribute from the current request.
[ "Removes", "the", "authentication", "attribute", "from", "the", "current", "request", "." ]
d829c1136b0fd21d87dc925cb7046cbd38a300a4
https://github.com/craftercms/profile/blob/d829c1136b0fd21d87dc925cb7046cbd38a300a4/security-provider/src/main/java/org/craftercms/security/utils/SecurityUtils.java#L110-L115
11,120
craftercms/profile
security-provider/src/main/java/org/craftercms/security/utils/SecurityUtils.java
SecurityUtils.getCurrentProfile
public static Profile getCurrentProfile() { RequestContext context = RequestContext.getCurrent(); if (context != null) { return getProfile(context.getRequest()); } else { return null; } }
java
public static Profile getCurrentProfile() { RequestContext context = RequestContext.getCurrent(); if (context != null) { return getProfile(context.getRequest()); } else { return null; } }
[ "public", "static", "Profile", "getCurrentProfile", "(", ")", "{", "RequestContext", "context", "=", "RequestContext", ".", "getCurrent", "(", ")", ";", "if", "(", "context", "!=", "null", ")", "{", "return", "getProfile", "(", "context", ".", "getRequest", "(", ")", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Returns the profile from authentication attribute from the current request. @return the profile object, or null if there's no authentication
[ "Returns", "the", "profile", "from", "authentication", "attribute", "from", "the", "current", "request", "." ]
d829c1136b0fd21d87dc925cb7046cbd38a300a4
https://github.com/craftercms/profile/blob/d829c1136b0fd21d87dc925cb7046cbd38a300a4/security-provider/src/main/java/org/craftercms/security/utils/SecurityUtils.java#L152-L159
11,121
craftercms/profile
security-provider/src/main/java/org/craftercms/security/utils/SecurityUtils.java
SecurityUtils.getProfile
public static Profile getProfile(HttpServletRequest request) { Authentication auth = getAuthentication(request); if (auth != null) { return auth.getProfile(); } else { return null; } }
java
public static Profile getProfile(HttpServletRequest request) { Authentication auth = getAuthentication(request); if (auth != null) { return auth.getProfile(); } else { return null; } }
[ "public", "static", "Profile", "getProfile", "(", "HttpServletRequest", "request", ")", "{", "Authentication", "auth", "=", "getAuthentication", "(", "request", ")", ";", "if", "(", "auth", "!=", "null", ")", "{", "return", "auth", ".", "getProfile", "(", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Returns the profile from authentication attribute from the specified request. @return the profile object, or null if there's no authentication
[ "Returns", "the", "profile", "from", "authentication", "attribute", "from", "the", "specified", "request", "." ]
d829c1136b0fd21d87dc925cb7046cbd38a300a4
https://github.com/craftercms/profile/blob/d829c1136b0fd21d87dc925cb7046cbd38a300a4/security-provider/src/main/java/org/craftercms/security/utils/SecurityUtils.java#L166-L173
11,122
craftercms/profile
security-provider/src/main/java/org/craftercms/security/processors/impl/UrlAccessRestrictionCheckingProcessor.java
UrlAccessRestrictionCheckingProcessor.setUrlRestrictions
@Required public void setUrlRestrictions(Map<String, String> restrictions) { urlRestrictions = new LinkedHashMap<>(); ExpressionParser parser = new SpelExpressionParser(); for (Map.Entry<String, String> entry : restrictions.entrySet()) { urlRestrictions.put(entry.getKey(), parser.parseExpression(entry.getValue())); } }
java
@Required public void setUrlRestrictions(Map<String, String> restrictions) { urlRestrictions = new LinkedHashMap<>(); ExpressionParser parser = new SpelExpressionParser(); for (Map.Entry<String, String> entry : restrictions.entrySet()) { urlRestrictions.put(entry.getKey(), parser.parseExpression(entry.getValue())); } }
[ "@", "Required", "public", "void", "setUrlRestrictions", "(", "Map", "<", "String", ",", "String", ">", "restrictions", ")", "{", "urlRestrictions", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", "ExpressionParser", "parser", "=", "new", "SpelExpressionParser", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "entry", ":", "restrictions", ".", "entrySet", "(", ")", ")", "{", "urlRestrictions", ".", "put", "(", "entry", ".", "getKey", "(", ")", ",", "parser", ".", "parseExpression", "(", "entry", ".", "getValue", "(", ")", ")", ")", ";", "}", "}" ]
Sets the map of restrictions. Each key of the map is ANT-style path pattern, used to match the URLs of incoming requests, and each value is a Spring EL expression.
[ "Sets", "the", "map", "of", "restrictions", ".", "Each", "key", "of", "the", "map", "is", "ANT", "-", "style", "path", "pattern", "used", "to", "match", "the", "URLs", "of", "incoming", "requests", "and", "each", "value", "is", "a", "Spring", "EL", "expression", "." ]
d829c1136b0fd21d87dc925cb7046cbd38a300a4
https://github.com/craftercms/profile/blob/d829c1136b0fd21d87dc925cb7046cbd38a300a4/security-provider/src/main/java/org/craftercms/security/processors/impl/UrlAccessRestrictionCheckingProcessor.java#L95-L104
11,123
pedrovgs/Nox
nox/src/main/java/com/github/pedrovgs/nox/imageloader/PicassoImageLoader.java
PicassoImageLoader.loadImage
private void loadImage() { List<Transformation> transformations = getTransformations(); boolean hasUrl = url != null; boolean hasResourceId = resourceId != null; boolean hasPlaceholder = placeholderId != null; ListenerTarget listenerTarget = getLinearTarget(listener); if (hasUrl) { RequestCreator bitmapRequest = Picasso.with(context).load(url).tag(PICASSO_IMAGE_LOADER_TAG); applyPlaceholder(bitmapRequest).resize(size, size) .transform(transformations) .into(listenerTarget); } else if (hasResourceId || hasPlaceholder) { Resources resources = context.getResources(); Drawable placeholder = null; Drawable drawable = null; if (hasPlaceholder) { placeholder = resources.getDrawable(placeholderId); listenerTarget.onPrepareLoad(placeholder); } if (hasResourceId) { drawable = resources.getDrawable(resourceId); listenerTarget.onDrawableLoad(drawable); } } else { throw new IllegalArgumentException( "Review your request, you are trying to load an image without a url or a resource id."); } }
java
private void loadImage() { List<Transformation> transformations = getTransformations(); boolean hasUrl = url != null; boolean hasResourceId = resourceId != null; boolean hasPlaceholder = placeholderId != null; ListenerTarget listenerTarget = getLinearTarget(listener); if (hasUrl) { RequestCreator bitmapRequest = Picasso.with(context).load(url).tag(PICASSO_IMAGE_LOADER_TAG); applyPlaceholder(bitmapRequest).resize(size, size) .transform(transformations) .into(listenerTarget); } else if (hasResourceId || hasPlaceholder) { Resources resources = context.getResources(); Drawable placeholder = null; Drawable drawable = null; if (hasPlaceholder) { placeholder = resources.getDrawable(placeholderId); listenerTarget.onPrepareLoad(placeholder); } if (hasResourceId) { drawable = resources.getDrawable(resourceId); listenerTarget.onDrawableLoad(drawable); } } else { throw new IllegalArgumentException( "Review your request, you are trying to load an image without a url or a resource id."); } }
[ "private", "void", "loadImage", "(", ")", "{", "List", "<", "Transformation", ">", "transformations", "=", "getTransformations", "(", ")", ";", "boolean", "hasUrl", "=", "url", "!=", "null", ";", "boolean", "hasResourceId", "=", "resourceId", "!=", "null", ";", "boolean", "hasPlaceholder", "=", "placeholderId", "!=", "null", ";", "ListenerTarget", "listenerTarget", "=", "getLinearTarget", "(", "listener", ")", ";", "if", "(", "hasUrl", ")", "{", "RequestCreator", "bitmapRequest", "=", "Picasso", ".", "with", "(", "context", ")", ".", "load", "(", "url", ")", ".", "tag", "(", "PICASSO_IMAGE_LOADER_TAG", ")", ";", "applyPlaceholder", "(", "bitmapRequest", ")", ".", "resize", "(", "size", ",", "size", ")", ".", "transform", "(", "transformations", ")", ".", "into", "(", "listenerTarget", ")", ";", "}", "else", "if", "(", "hasResourceId", "||", "hasPlaceholder", ")", "{", "Resources", "resources", "=", "context", ".", "getResources", "(", ")", ";", "Drawable", "placeholder", "=", "null", ";", "Drawable", "drawable", "=", "null", ";", "if", "(", "hasPlaceholder", ")", "{", "placeholder", "=", "resources", ".", "getDrawable", "(", "placeholderId", ")", ";", "listenerTarget", ".", "onPrepareLoad", "(", "placeholder", ")", ";", "}", "if", "(", "hasResourceId", ")", "{", "drawable", "=", "resources", ".", "getDrawable", "(", "resourceId", ")", ";", "listenerTarget", ".", "onDrawableLoad", "(", "drawable", ")", ";", "}", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Review your request, you are trying to load an image without a url or a resource id.\"", ")", ";", "}", "}" ]
Uses the configuration previously applied using this ImageLoader builder to download a resource asynchronously and notify the result to the listener.
[ "Uses", "the", "configuration", "previously", "applied", "using", "this", "ImageLoader", "builder", "to", "download", "a", "resource", "asynchronously", "and", "notify", "the", "result", "to", "the", "listener", "." ]
b4dfe37895e1b7bf2084d60139931dd4fb12f3f4
https://github.com/pedrovgs/Nox/blob/b4dfe37895e1b7bf2084d60139931dd4fb12f3f4/nox/src/main/java/com/github/pedrovgs/nox/imageloader/PicassoImageLoader.java#L105-L132
11,124
pedrovgs/Nox
nox/src/main/java/com/github/pedrovgs/nox/imageloader/PicassoImageLoader.java
PicassoImageLoader.getLinearTarget
private ListenerTarget getLinearTarget(final Listener listener) { ListenerTarget target = targets.get(listener); if (target == null) { target = new ListenerTarget(listener); targets.put(listener, target); } return target; }
java
private ListenerTarget getLinearTarget(final Listener listener) { ListenerTarget target = targets.get(listener); if (target == null) { target = new ListenerTarget(listener); targets.put(listener, target); } return target; }
[ "private", "ListenerTarget", "getLinearTarget", "(", "final", "Listener", "listener", ")", "{", "ListenerTarget", "target", "=", "targets", ".", "get", "(", "listener", ")", ";", "if", "(", "target", "==", "null", ")", "{", "target", "=", "new", "ListenerTarget", "(", "listener", ")", ";", "targets", ".", "put", "(", "listener", ",", "target", ")", ";", "}", "return", "target", ";", "}" ]
Given a listener passed as argument creates or returns a lazy instance of a Picasso Target. This implementation is needed because Picasso doesn't keep a strong reference to the target passed as parameter. Without this method Picasso looses the reference to the target and never notifies when the resource has been downloaded. Listener and Target instances are going to be stored into a WeakHashMap to avoid a memory leak when ImageLoader client code is garbage collected.
[ "Given", "a", "listener", "passed", "as", "argument", "creates", "or", "returns", "a", "lazy", "instance", "of", "a", "Picasso", "Target", ".", "This", "implementation", "is", "needed", "because", "Picasso", "doesn", "t", "keep", "a", "strong", "reference", "to", "the", "target", "passed", "as", "parameter", ".", "Without", "this", "method", "Picasso", "looses", "the", "reference", "to", "the", "target", "and", "never", "notifies", "when", "the", "resource", "has", "been", "downloaded", "." ]
b4dfe37895e1b7bf2084d60139931dd4fb12f3f4
https://github.com/pedrovgs/Nox/blob/b4dfe37895e1b7bf2084d60139931dd4fb12f3f4/nox/src/main/java/com/github/pedrovgs/nox/imageloader/PicassoImageLoader.java#L143-L150
11,125
arquillian/arquillian-extension-warp
impl/src/main/java/org/jboss/arquillian/warp/impl/server/delegation/RequestDelegator.java
RequestDelegator.delegate
private void delegate(RequestDelegationService service, HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) { try { service.delegate(request, response, filterChain); } catch (Exception e) { throw new RequestDelegationException( String.format("The request processing delegation failed: %s", e.getCause()), e); } }
java
private void delegate(RequestDelegationService service, HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) { try { service.delegate(request, response, filterChain); } catch (Exception e) { throw new RequestDelegationException( String.format("The request processing delegation failed: %s", e.getCause()), e); } }
[ "private", "void", "delegate", "(", "RequestDelegationService", "service", ",", "HttpServletRequest", "request", ",", "HttpServletResponse", "response", ",", "FilterChain", "filterChain", ")", "{", "try", "{", "service", ".", "delegate", "(", "request", ",", "response", ",", "filterChain", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RequestDelegationException", "(", "String", ".", "format", "(", "\"The request processing delegation failed: %s\"", ",", "e", ".", "getCause", "(", ")", ")", ",", "e", ")", ";", "}", "}" ]
Delegates given request and response to be processed by given service. @throws RequestDelegationException in case the delegated request processing fails
[ "Delegates", "given", "request", "and", "response", "to", "be", "processed", "by", "given", "service", "." ]
e958f4d782851baf7f40e39835d3d1ad185b74dd
https://github.com/arquillian/arquillian-extension-warp/blob/e958f4d782851baf7f40e39835d3d1ad185b74dd/impl/src/main/java/org/jboss/arquillian/warp/impl/server/delegation/RequestDelegator.java#L69-L77
11,126
arquillian/arquillian-extension-warp
impl/src/main/java/org/jboss/arquillian/warp/impl/server/delegation/RequestDelegator.java
RequestDelegator.canDelegate
private boolean canDelegate(RequestDelegationService delegate, HttpServletRequest request) { try { return delegate.canDelegate(request); } catch (Exception e) { log.log(Level.SEVERE, String.format("The delegation service can't check the delegability of the request: %s", e.getCause()), e.getCause()); return false; } }
java
private boolean canDelegate(RequestDelegationService delegate, HttpServletRequest request) { try { return delegate.canDelegate(request); } catch (Exception e) { log.log(Level.SEVERE, String.format("The delegation service can't check the delegability of the request: %s", e.getCause()), e.getCause()); return false; } }
[ "private", "boolean", "canDelegate", "(", "RequestDelegationService", "delegate", ",", "HttpServletRequest", "request", ")", "{", "try", "{", "return", "delegate", ".", "canDelegate", "(", "request", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "log", "(", "Level", ".", "SEVERE", ",", "String", ".", "format", "(", "\"The delegation service can't check the delegability of the request: %s\"", ",", "e", ".", "getCause", "(", ")", ")", ",", "e", ".", "getCause", "(", ")", ")", ";", "return", "false", ";", "}", "}" ]
Checks whether the given service can serve given request.
[ "Checks", "whether", "the", "given", "service", "can", "serve", "given", "request", "." ]
e958f4d782851baf7f40e39835d3d1ad185b74dd
https://github.com/arquillian/arquillian-extension-warp/blob/e958f4d782851baf7f40e39835d3d1ad185b74dd/impl/src/main/java/org/jboss/arquillian/warp/impl/server/delegation/RequestDelegator.java#L82-L91
11,127
arquillian/arquillian-extension-warp
impl/src/main/java/org/jboss/arquillian/warp/impl/client/execution/SynchronizationPoint.java
SynchronizationPoint.awaitRequests
void awaitRequests() { if (!isWaitingForEnriching()) { return; } for (int i = 0; i < NUMBER_OF_WAIT_LOOPS; i++) { try { Thread.sleep(THREAD_SLEEP); if (!isEnrichmentAdvertised()) { return; } } catch (InterruptedException e) { throw new IllegalStateException(e); } } throw new SettingRequestTimeoutException(); }
java
void awaitRequests() { if (!isWaitingForEnriching()) { return; } for (int i = 0; i < NUMBER_OF_WAIT_LOOPS; i++) { try { Thread.sleep(THREAD_SLEEP); if (!isEnrichmentAdvertised()) { return; } } catch (InterruptedException e) { throw new IllegalStateException(e); } } throw new SettingRequestTimeoutException(); }
[ "void", "awaitRequests", "(", ")", "{", "if", "(", "!", "isWaitingForEnriching", "(", ")", ")", "{", "return", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "NUMBER_OF_WAIT_LOOPS", ";", "i", "++", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "THREAD_SLEEP", ")", ";", "if", "(", "!", "isEnrichmentAdvertised", "(", ")", ")", "{", "return", ";", "}", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}", "throw", "new", "SettingRequestTimeoutException", "(", ")", ";", "}" ]
Await client activity causing requests in order to enrich requests
[ "Await", "client", "activity", "causing", "requests", "in", "order", "to", "enrich", "requests" ]
e958f4d782851baf7f40e39835d3d1ad185b74dd
https://github.com/arquillian/arquillian-extension-warp/blob/e958f4d782851baf7f40e39835d3d1ad185b74dd/impl/src/main/java/org/jboss/arquillian/warp/impl/client/execution/SynchronizationPoint.java#L131-L146
11,128
arquillian/arquillian-extension-warp
impl/src/main/java/org/jboss/arquillian/warp/impl/client/execution/SynchronizationPoint.java
SynchronizationPoint.awaitResponses
void awaitResponses() { try { boolean finishedNicely = responseFinished.await(WAIT_TIMEOUT_MILISECONDS, TimeUnit.MILLISECONDS); if (!finishedNicely) { throw new WarpSynchronizationException(WarpContextStore.get()); } } catch (InterruptedException e) { } }
java
void awaitResponses() { try { boolean finishedNicely = responseFinished.await(WAIT_TIMEOUT_MILISECONDS, TimeUnit.MILLISECONDS); if (!finishedNicely) { throw new WarpSynchronizationException(WarpContextStore.get()); } } catch (InterruptedException e) { } }
[ "void", "awaitResponses", "(", ")", "{", "try", "{", "boolean", "finishedNicely", "=", "responseFinished", ".", "await", "(", "WAIT_TIMEOUT_MILISECONDS", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "if", "(", "!", "finishedNicely", ")", "{", "throw", "new", "WarpSynchronizationException", "(", "WarpContextStore", ".", "get", "(", ")", ")", ";", "}", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}" ]
Await responses for requests or premature finishing
[ "Await", "responses", "for", "requests", "or", "premature", "finishing" ]
e958f4d782851baf7f40e39835d3d1ad185b74dd
https://github.com/arquillian/arquillian-extension-warp/blob/e958f4d782851baf7f40e39835d3d1ad185b74dd/impl/src/main/java/org/jboss/arquillian/warp/impl/client/execution/SynchronizationPoint.java#L151-L159
11,129
JodaOrg/joda-time-jsptags
src/main/java/org/joda/time/contrib/jsptag/ParseDateTimeTag.java
ParseDateTimeTag.setDateTimeZone
public void setDateTimeZone(Object dtz) throws JspTagException { if (dtz == null || dtz instanceof String && ((String) dtz).length() == 0) { this.dateTimeZone = null; } else if (dtz instanceof DateTimeZone) { this.dateTimeZone = (DateTimeZone) dtz; } else { try { this.dateTimeZone = DateTimeZone.forID((String) dtz); } catch (IllegalArgumentException iae) { this.dateTimeZone = DateTimeZone.UTC; } } }
java
public void setDateTimeZone(Object dtz) throws JspTagException { if (dtz == null || dtz instanceof String && ((String) dtz).length() == 0) { this.dateTimeZone = null; } else if (dtz instanceof DateTimeZone) { this.dateTimeZone = (DateTimeZone) dtz; } else { try { this.dateTimeZone = DateTimeZone.forID((String) dtz); } catch (IllegalArgumentException iae) { this.dateTimeZone = DateTimeZone.UTC; } } }
[ "public", "void", "setDateTimeZone", "(", "Object", "dtz", ")", "throws", "JspTagException", "{", "if", "(", "dtz", "==", "null", "||", "dtz", "instanceof", "String", "&&", "(", "(", "String", ")", "dtz", ")", ".", "length", "(", ")", "==", "0", ")", "{", "this", ".", "dateTimeZone", "=", "null", ";", "}", "else", "if", "(", "dtz", "instanceof", "DateTimeZone", ")", "{", "this", ".", "dateTimeZone", "=", "(", "DateTimeZone", ")", "dtz", ";", "}", "else", "{", "try", "{", "this", ".", "dateTimeZone", "=", "DateTimeZone", ".", "forID", "(", "(", "String", ")", "dtz", ")", ";", "}", "catch", "(", "IllegalArgumentException", "iae", ")", "{", "this", ".", "dateTimeZone", "=", "DateTimeZone", ".", "UTC", ";", "}", "}", "}" ]
Sets the zone attribute. @param dtz the zone
[ "Sets", "the", "zone", "attribute", "." ]
69008a813568cb6f3e37ea7a80f8b1f2070edf14
https://github.com/JodaOrg/joda-time-jsptags/blob/69008a813568cb6f3e37ea7a80f8b1f2070edf14/src/main/java/org/joda/time/contrib/jsptag/ParseDateTimeTag.java#L69-L82
11,130
JodaOrg/joda-time-jsptags
src/main/java/org/joda/time/contrib/jsptag/ParseDateTimeTag.java
ParseDateTimeTag.setLocale
public void setLocale(Object loc) throws JspTagException { if (loc == null || (loc instanceof String && ((String) loc).length() == 0)) { this.locale = null; } else if (loc instanceof Locale) { this.locale = (Locale) loc; } else { locale = Util.parseLocale((String) loc); } }
java
public void setLocale(Object loc) throws JspTagException { if (loc == null || (loc instanceof String && ((String) loc).length() == 0)) { this.locale = null; } else if (loc instanceof Locale) { this.locale = (Locale) loc; } else { locale = Util.parseLocale((String) loc); } }
[ "public", "void", "setLocale", "(", "Object", "loc", ")", "throws", "JspTagException", "{", "if", "(", "loc", "==", "null", "||", "(", "loc", "instanceof", "String", "&&", "(", "(", "String", ")", "loc", ")", ".", "length", "(", ")", "==", "0", ")", ")", "{", "this", ".", "locale", "=", "null", ";", "}", "else", "if", "(", "loc", "instanceof", "Locale", ")", "{", "this", ".", "locale", "=", "(", "Locale", ")", "loc", ";", "}", "else", "{", "locale", "=", "Util", ".", "parseLocale", "(", "(", "String", ")", "loc", ")", ";", "}", "}" ]
Sets the style attribute. @param loc the locale
[ "Sets", "the", "style", "attribute", "." ]
69008a813568cb6f3e37ea7a80f8b1f2070edf14
https://github.com/JodaOrg/joda-time-jsptags/blob/69008a813568cb6f3e37ea7a80f8b1f2070edf14/src/main/java/org/joda/time/contrib/jsptag/ParseDateTimeTag.java#L89-L98
11,131
JodaOrg/joda-time-jsptags
src/main/java/org/joda/time/contrib/jsptag/JodaTagLibraryValidator.java
JodaTagLibraryValidator.hasNoInvalidScope
protected boolean hasNoInvalidScope(Attributes a) { String scope = a.getValue(SCOPE); if ((scope != null) && !scope.equals(PAGE_SCOPE) && !scope.equals(REQUEST_SCOPE) && !scope.equals(SESSION_SCOPE) && !scope.equals(APPLICATION_SCOPE)) { return false; } return true; }
java
protected boolean hasNoInvalidScope(Attributes a) { String scope = a.getValue(SCOPE); if ((scope != null) && !scope.equals(PAGE_SCOPE) && !scope.equals(REQUEST_SCOPE) && !scope.equals(SESSION_SCOPE) && !scope.equals(APPLICATION_SCOPE)) { return false; } return true; }
[ "protected", "boolean", "hasNoInvalidScope", "(", "Attributes", "a", ")", "{", "String", "scope", "=", "a", ".", "getValue", "(", "SCOPE", ")", ";", "if", "(", "(", "scope", "!=", "null", ")", "&&", "!", "scope", ".", "equals", "(", "PAGE_SCOPE", ")", "&&", "!", "scope", ".", "equals", "(", "REQUEST_SCOPE", ")", "&&", "!", "scope", ".", "equals", "(", "SESSION_SCOPE", ")", "&&", "!", "scope", ".", "equals", "(", "APPLICATION_SCOPE", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
returns true if the 'scope' attribute is valid
[ "returns", "true", "if", "the", "scope", "attribute", "is", "valid" ]
69008a813568cb6f3e37ea7a80f8b1f2070edf14
https://github.com/JodaOrg/joda-time-jsptags/blob/69008a813568cb6f3e37ea7a80f8b1f2070edf14/src/main/java/org/joda/time/contrib/jsptag/JodaTagLibraryValidator.java#L246-L254
11,132
JodaOrg/joda-time-jsptags
src/main/java/org/joda/time/contrib/jsptag/JodaTagLibraryValidator.java
JodaTagLibraryValidator.hasDanglingScope
protected boolean hasDanglingScope(Attributes a) { return (a.getValue(SCOPE) != null && a.getValue(VAR) == null); }
java
protected boolean hasDanglingScope(Attributes a) { return (a.getValue(SCOPE) != null && a.getValue(VAR) == null); }
[ "protected", "boolean", "hasDanglingScope", "(", "Attributes", "a", ")", "{", "return", "(", "a", ".", "getValue", "(", "SCOPE", ")", "!=", "null", "&&", "a", ".", "getValue", "(", "VAR", ")", "==", "null", ")", ";", "}" ]
returns true if the 'scope' attribute is present without 'var'
[ "returns", "true", "if", "the", "scope", "attribute", "is", "present", "without", "var" ]
69008a813568cb6f3e37ea7a80f8b1f2070edf14
https://github.com/JodaOrg/joda-time-jsptags/blob/69008a813568cb6f3e37ea7a80f8b1f2070edf14/src/main/java/org/joda/time/contrib/jsptag/JodaTagLibraryValidator.java#L262-L264
11,133
JodaOrg/joda-time-jsptags
src/main/java/org/joda/time/contrib/jsptag/JodaTagLibraryValidator.java
JodaTagLibraryValidator.getLocalPart
protected String getLocalPart(String qname) { int colon = qname.indexOf(":"); return (colon == -1) ? qname : qname.substring(colon + 1); }
java
protected String getLocalPart(String qname) { int colon = qname.indexOf(":"); return (colon == -1) ? qname : qname.substring(colon + 1); }
[ "protected", "String", "getLocalPart", "(", "String", "qname", ")", "{", "int", "colon", "=", "qname", ".", "indexOf", "(", "\":\"", ")", ";", "return", "(", "colon", "==", "-", "1", ")", "?", "qname", ":", "qname", ".", "substring", "(", "colon", "+", "1", ")", ";", "}" ]
retrieves the local part of a QName
[ "retrieves", "the", "local", "part", "of", "a", "QName" ]
69008a813568cb6f3e37ea7a80f8b1f2070edf14
https://github.com/JodaOrg/joda-time-jsptags/blob/69008a813568cb6f3e37ea7a80f8b1f2070edf14/src/main/java/org/joda/time/contrib/jsptag/JodaTagLibraryValidator.java#L267-L270
11,134
arquillian/arquillian-extension-warp
impl/src/main/java/org/jboss/arquillian/warp/impl/server/commandBus/CommandBusOnServer.java
CommandBusOnServer.executeGetOperation
private void executeGetOperation(HttpServletRequest request, HttpServletResponse response) throws IOException, ClassNotFoundException { if (request.getContentLength() > 0) { response.setStatus(HttpServletResponse.SC_NO_CONTENT); ObjectInputStream input = new ObjectInputStream(new BufferedInputStream(request.getInputStream())); CommandPayload paylod = (CommandPayload) input.readObject(); events.put(currentCall, paylod); } else { if (events.containsKey(currentCall) && !events.get(currentCall).isExecuted()) { response.setStatus(HttpServletResponse.SC_OK); ObjectOutputStream output = new ObjectOutputStream(response.getOutputStream()); output.writeObject(events.remove(currentCall)); output.flush(); output.close(); } else { response.setStatus(HttpServletResponse.SC_NO_CONTENT); } } }
java
private void executeGetOperation(HttpServletRequest request, HttpServletResponse response) throws IOException, ClassNotFoundException { if (request.getContentLength() > 0) { response.setStatus(HttpServletResponse.SC_NO_CONTENT); ObjectInputStream input = new ObjectInputStream(new BufferedInputStream(request.getInputStream())); CommandPayload paylod = (CommandPayload) input.readObject(); events.put(currentCall, paylod); } else { if (events.containsKey(currentCall) && !events.get(currentCall).isExecuted()) { response.setStatus(HttpServletResponse.SC_OK); ObjectOutputStream output = new ObjectOutputStream(response.getOutputStream()); output.writeObject(events.remove(currentCall)); output.flush(); output.close(); } else { response.setStatus(HttpServletResponse.SC_NO_CONTENT); } } }
[ "private", "void", "executeGetOperation", "(", "HttpServletRequest", "request", ",", "HttpServletResponse", "response", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "if", "(", "request", ".", "getContentLength", "(", ")", ">", "0", ")", "{", "response", ".", "setStatus", "(", "HttpServletResponse", ".", "SC_NO_CONTENT", ")", ";", "ObjectInputStream", "input", "=", "new", "ObjectInputStream", "(", "new", "BufferedInputStream", "(", "request", ".", "getInputStream", "(", ")", ")", ")", ";", "CommandPayload", "paylod", "=", "(", "CommandPayload", ")", "input", ".", "readObject", "(", ")", ";", "events", ".", "put", "(", "currentCall", ",", "paylod", ")", ";", "}", "else", "{", "if", "(", "events", ".", "containsKey", "(", "currentCall", ")", "&&", "!", "events", ".", "get", "(", "currentCall", ")", ".", "isExecuted", "(", ")", ")", "{", "response", ".", "setStatus", "(", "HttpServletResponse", ".", "SC_OK", ")", ";", "ObjectOutputStream", "output", "=", "new", "ObjectOutputStream", "(", "response", ".", "getOutputStream", "(", ")", ")", ";", "output", ".", "writeObject", "(", "events", ".", "remove", "(", "currentCall", ")", ")", ";", "output", ".", "flush", "(", ")", ";", "output", ".", "close", "(", ")", ";", "}", "else", "{", "response", ".", "setStatus", "(", "HttpServletResponse", ".", "SC_NO_CONTENT", ")", ";", "}", "}", "}" ]
Container-to-Client command execution
[ "Container", "-", "to", "-", "Client", "command", "execution" ]
e958f4d782851baf7f40e39835d3d1ad185b74dd
https://github.com/arquillian/arquillian-extension-warp/blob/e958f4d782851baf7f40e39835d3d1ad185b74dd/impl/src/main/java/org/jboss/arquillian/warp/impl/server/commandBus/CommandBusOnServer.java#L113-L131
11,135
arquillian/arquillian-extension-warp
impl/src/main/java/org/jboss/arquillian/warp/impl/server/commandBus/CommandBusOnServer.java
CommandBusOnServer.executePutOperation
private void executePutOperation(HttpServletRequest request, HttpServletResponse response) throws IOException, ClassNotFoundException { if (request.getContentLength() > 0) { ObjectInputStream input = new ObjectInputStream(new BufferedInputStream(request.getInputStream())); CommandPayload payload = (CommandPayload) input.readObject(); Command operation = payload.getCommand(); Manager manager = (Manager) request.getAttribute(ARQUILLIAN_MANAGER_ATTRIBUTE); // execute remote Event try { manager.fire(new ActivateManager(manager)); manager.inject(operation); operation.perform(); manager.fire(new PassivateManager(manager)); } catch (Throwable e) { payload.setThrowable(e); } response.setStatus(HttpServletResponse.SC_OK); ObjectOutputStream output = new ObjectOutputStream(response.getOutputStream()); output.writeObject(payload); output.flush(); output.close(); } else { response.setStatus(HttpServletResponse.SC_NO_CONTENT); } }
java
private void executePutOperation(HttpServletRequest request, HttpServletResponse response) throws IOException, ClassNotFoundException { if (request.getContentLength() > 0) { ObjectInputStream input = new ObjectInputStream(new BufferedInputStream(request.getInputStream())); CommandPayload payload = (CommandPayload) input.readObject(); Command operation = payload.getCommand(); Manager manager = (Manager) request.getAttribute(ARQUILLIAN_MANAGER_ATTRIBUTE); // execute remote Event try { manager.fire(new ActivateManager(manager)); manager.inject(operation); operation.perform(); manager.fire(new PassivateManager(manager)); } catch (Throwable e) { payload.setThrowable(e); } response.setStatus(HttpServletResponse.SC_OK); ObjectOutputStream output = new ObjectOutputStream(response.getOutputStream()); output.writeObject(payload); output.flush(); output.close(); } else { response.setStatus(HttpServletResponse.SC_NO_CONTENT); } }
[ "private", "void", "executePutOperation", "(", "HttpServletRequest", "request", ",", "HttpServletResponse", "response", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "if", "(", "request", ".", "getContentLength", "(", ")", ">", "0", ")", "{", "ObjectInputStream", "input", "=", "new", "ObjectInputStream", "(", "new", "BufferedInputStream", "(", "request", ".", "getInputStream", "(", ")", ")", ")", ";", "CommandPayload", "payload", "=", "(", "CommandPayload", ")", "input", ".", "readObject", "(", ")", ";", "Command", "operation", "=", "payload", ".", "getCommand", "(", ")", ";", "Manager", "manager", "=", "(", "Manager", ")", "request", ".", "getAttribute", "(", "ARQUILLIAN_MANAGER_ATTRIBUTE", ")", ";", "// execute remote Event", "try", "{", "manager", ".", "fire", "(", "new", "ActivateManager", "(", "manager", ")", ")", ";", "manager", ".", "inject", "(", "operation", ")", ";", "operation", ".", "perform", "(", ")", ";", "manager", ".", "fire", "(", "new", "PassivateManager", "(", "manager", ")", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "payload", ".", "setThrowable", "(", "e", ")", ";", "}", "response", ".", "setStatus", "(", "HttpServletResponse", ".", "SC_OK", ")", ";", "ObjectOutputStream", "output", "=", "new", "ObjectOutputStream", "(", "response", ".", "getOutputStream", "(", ")", ")", ";", "output", ".", "writeObject", "(", "payload", ")", ";", "output", ".", "flush", "(", ")", ";", "output", ".", "close", "(", ")", ";", "}", "else", "{", "response", ".", "setStatus", "(", "HttpServletResponse", ".", "SC_NO_CONTENT", ")", ";", "}", "}" ]
Client-to-Container event propagation
[ "Client", "-", "to", "-", "Container", "event", "propagation" ]
e958f4d782851baf7f40e39835d3d1ad185b74dd
https://github.com/arquillian/arquillian-extension-warp/blob/e958f4d782851baf7f40e39835d3d1ad185b74dd/impl/src/main/java/org/jboss/arquillian/warp/impl/server/commandBus/CommandBusOnServer.java#L136-L160
11,136
datasift/datasift-java
src/main/java/com/datasift/client/DataSiftClient.java
DataSiftClient.dpu
public FutureData<Dpu> dpu(String historicsId) { final FutureData<Dpu> future = new FutureData<Dpu>(); URI uri = newParams().put("historics_id", historicsId).forURL(config.newAPIEndpointURI(DPU)); Request request = config.http().GET(uri, new PageReader(newRequestCallback(future, new Dpu(), config))); performRequest(future, request); return future; }
java
public FutureData<Dpu> dpu(String historicsId) { final FutureData<Dpu> future = new FutureData<Dpu>(); URI uri = newParams().put("historics_id", historicsId).forURL(config.newAPIEndpointURI(DPU)); Request request = config.http().GET(uri, new PageReader(newRequestCallback(future, new Dpu(), config))); performRequest(future, request); return future; }
[ "public", "FutureData", "<", "Dpu", ">", "dpu", "(", "String", "historicsId", ")", "{", "final", "FutureData", "<", "Dpu", ">", "future", "=", "new", "FutureData", "<", "Dpu", ">", "(", ")", ";", "URI", "uri", "=", "newParams", "(", ")", ".", "put", "(", "\"historics_id\"", ",", "historicsId", ")", ".", "forURL", "(", "config", ".", "newAPIEndpointURI", "(", "DPU", ")", ")", ";", "Request", "request", "=", "config", ".", "http", "(", ")", ".", "GET", "(", "uri", ",", "new", "PageReader", "(", "newRequestCallback", "(", "future", ",", "new", "Dpu", "(", ")", ",", "config", ")", ")", ")", ";", "performRequest", "(", "future", ",", "request", ")", ";", "return", "future", ";", "}" ]
Retrieve the DPU usage of a historics job @param historicsId id of the historics job to get the DPU usage of @return future containing DPU response
[ "Retrieve", "the", "DPU", "usage", "of", "a", "historics", "job" ]
09de124f2a1a507ff6181e59875c6f325290850e
https://github.com/datasift/datasift-java/blob/09de124f2a1a507ff6181e59875c6f325290850e/src/main/java/com/datasift/client/DataSiftClient.java#L210-L216
11,137
spotify/docgenerator
scanner/src/main/java/com/spotify/docgenerator/JacksonJerseyAnnotationProcessor.java
JacksonJerseyAnnotationProcessor.computeRequestMethod
private String computeRequestMethod(Element e) { for (AnnotationMirror am : e.getAnnotationMirrors()) { final String typeString = am.getAnnotationType().toString(); if (typeString.endsWith(".GET")) { return "GET"; } else if (typeString.endsWith(".PUT")) { return "PUT"; } else if (typeString.endsWith(".POST")) { return "POST"; } else if (typeString.endsWith(".PATCH")) { return "PATCH"; } else if (typeString.endsWith(".DELETE")) { return "DELETE"; } } return null; }
java
private String computeRequestMethod(Element e) { for (AnnotationMirror am : e.getAnnotationMirrors()) { final String typeString = am.getAnnotationType().toString(); if (typeString.endsWith(".GET")) { return "GET"; } else if (typeString.endsWith(".PUT")) { return "PUT"; } else if (typeString.endsWith(".POST")) { return "POST"; } else if (typeString.endsWith(".PATCH")) { return "PATCH"; } else if (typeString.endsWith(".DELETE")) { return "DELETE"; } } return null; }
[ "private", "String", "computeRequestMethod", "(", "Element", "e", ")", "{", "for", "(", "AnnotationMirror", "am", ":", "e", ".", "getAnnotationMirrors", "(", ")", ")", "{", "final", "String", "typeString", "=", "am", ".", "getAnnotationType", "(", ")", ".", "toString", "(", ")", ";", "if", "(", "typeString", ".", "endsWith", "(", "\".GET\"", ")", ")", "{", "return", "\"GET\"", ";", "}", "else", "if", "(", "typeString", ".", "endsWith", "(", "\".PUT\"", ")", ")", "{", "return", "\"PUT\"", ";", "}", "else", "if", "(", "typeString", ".", "endsWith", "(", "\".POST\"", ")", ")", "{", "return", "\"POST\"", ";", "}", "else", "if", "(", "typeString", ".", "endsWith", "(", "\".PATCH\"", ")", ")", "{", "return", "\"PATCH\"", ";", "}", "else", "if", "(", "typeString", ".", "endsWith", "(", "\".DELETE\"", ")", ")", "{", "return", "\"DELETE\"", ";", "}", "}", "return", "null", ";", "}" ]
Find the request method annotation the method was annotated with and return a string representing the request method.
[ "Find", "the", "request", "method", "annotation", "the", "method", "was", "annotated", "with", "and", "return", "a", "string", "representing", "the", "request", "method", "." ]
a7965f6d4a1546864a3f8584b86841cef9ac2f65
https://github.com/spotify/docgenerator/blob/a7965f6d4a1546864a3f8584b86841cef9ac2f65/scanner/src/main/java/com/spotify/docgenerator/JacksonJerseyAnnotationProcessor.java#L187-L204
11,138
spotify/docgenerator
scanner/src/main/java/com/spotify/docgenerator/JacksonJerseyAnnotationProcessor.java
JacksonJerseyAnnotationProcessor.generateOutput
private void generateOutput() { final Filer filer = processingEnv.getFiler(); writeJsonToFile(filer, "JSONClasses", jsonClasses); writeJsonToFile(filer, "debugcrud", debugMessages); final List<ResourceMethod> resources = Lists.newArrayList(); for (ResourceClass klass : resourceClasses.values()) { final String path = klass.getPath(); for (final ResourceMethod method : klass.getMembers()) { resources.add(new ResourceMethod("", method.getMethod(), computeDisplayPath(path, method.getPath()), method.getReturnContentType(), method.getReturnType(), method.getArguments(), method.getJavadoc())); } } writeJsonToFile(filer, "RESTEndpoints", resources); }
java
private void generateOutput() { final Filer filer = processingEnv.getFiler(); writeJsonToFile(filer, "JSONClasses", jsonClasses); writeJsonToFile(filer, "debugcrud", debugMessages); final List<ResourceMethod> resources = Lists.newArrayList(); for (ResourceClass klass : resourceClasses.values()) { final String path = klass.getPath(); for (final ResourceMethod method : klass.getMembers()) { resources.add(new ResourceMethod("", method.getMethod(), computeDisplayPath(path, method.getPath()), method.getReturnContentType(), method.getReturnType(), method.getArguments(), method.getJavadoc())); } } writeJsonToFile(filer, "RESTEndpoints", resources); }
[ "private", "void", "generateOutput", "(", ")", "{", "final", "Filer", "filer", "=", "processingEnv", ".", "getFiler", "(", ")", ";", "writeJsonToFile", "(", "filer", ",", "\"JSONClasses\"", ",", "jsonClasses", ")", ";", "writeJsonToFile", "(", "filer", ",", "\"debugcrud\"", ",", "debugMessages", ")", ";", "final", "List", "<", "ResourceMethod", ">", "resources", "=", "Lists", ".", "newArrayList", "(", ")", ";", "for", "(", "ResourceClass", "klass", ":", "resourceClasses", ".", "values", "(", ")", ")", "{", "final", "String", "path", "=", "klass", ".", "getPath", "(", ")", ";", "for", "(", "final", "ResourceMethod", "method", ":", "klass", ".", "getMembers", "(", ")", ")", "{", "resources", ".", "add", "(", "new", "ResourceMethod", "(", "\"\"", ",", "method", ".", "getMethod", "(", ")", ",", "computeDisplayPath", "(", "path", ",", "method", ".", "getPath", "(", ")", ")", ",", "method", ".", "getReturnContentType", "(", ")", ",", "method", ".", "getReturnType", "(", ")", ",", "method", ".", "getArguments", "(", ")", ",", "method", ".", "getJavadoc", "(", ")", ")", ")", ";", "}", "}", "writeJsonToFile", "(", "filer", ",", "\"RESTEndpoints\"", ",", "resources", ")", ";", "}" ]
Dump the contents of our discoveries.
[ "Dump", "the", "contents", "of", "our", "discoveries", "." ]
a7965f6d4a1546864a3f8584b86841cef9ac2f65
https://github.com/spotify/docgenerator/blob/a7965f6d4a1546864a3f8584b86841cef9ac2f65/scanner/src/main/java/com/spotify/docgenerator/JacksonJerseyAnnotationProcessor.java#L318-L335
11,139
arquillian/arquillian-extension-warp
impl/src/main/java/org/jboss/arquillian/warp/impl/client/deployment/DeploymentEnricher.java
DeploymentEnricher.process
@Override public void process(TestDeployment testDeployment, Archive<?> protocolArchive) { final TestClass testClass = this.testClass.get(); final Archive<?> applicationArchive = testDeployment.getApplicationArchive(); if (WarpCommons.isWarpTest(testClass.getJavaClass())) { if (!Validate.isArchiveOfType(WebArchive.class, protocolArchive)) { throw new IllegalArgumentException("Protocol archives of type " + protocolArchive.getClass() + " not supported by Warp. Please use the Servlet 3.0 protocol."); } addWarpPackageToDeployment(protocolArchive.as(WebArchive.class)); addWarpExtensionsDeployment(protocolArchive.as(WebArchive.class)); removeTestClassFromDeployment(applicationArchive, testClass); } }
java
@Override public void process(TestDeployment testDeployment, Archive<?> protocolArchive) { final TestClass testClass = this.testClass.get(); final Archive<?> applicationArchive = testDeployment.getApplicationArchive(); if (WarpCommons.isWarpTest(testClass.getJavaClass())) { if (!Validate.isArchiveOfType(WebArchive.class, protocolArchive)) { throw new IllegalArgumentException("Protocol archives of type " + protocolArchive.getClass() + " not supported by Warp. Please use the Servlet 3.0 protocol."); } addWarpPackageToDeployment(protocolArchive.as(WebArchive.class)); addWarpExtensionsDeployment(protocolArchive.as(WebArchive.class)); removeTestClassFromDeployment(applicationArchive, testClass); } }
[ "@", "Override", "public", "void", "process", "(", "TestDeployment", "testDeployment", ",", "Archive", "<", "?", ">", "protocolArchive", ")", "{", "final", "TestClass", "testClass", "=", "this", ".", "testClass", ".", "get", "(", ")", ";", "final", "Archive", "<", "?", ">", "applicationArchive", "=", "testDeployment", ".", "getApplicationArchive", "(", ")", ";", "if", "(", "WarpCommons", ".", "isWarpTest", "(", "testClass", ".", "getJavaClass", "(", ")", ")", ")", "{", "if", "(", "!", "Validate", ".", "isArchiveOfType", "(", "WebArchive", ".", "class", ",", "protocolArchive", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Protocol archives of type \"", "+", "protocolArchive", ".", "getClass", "(", ")", "+", "\" not supported by Warp. Please use the Servlet 3.0 protocol.\"", ")", ";", "}", "addWarpPackageToDeployment", "(", "protocolArchive", ".", "as", "(", "WebArchive", ".", "class", ")", ")", ";", "addWarpExtensionsDeployment", "(", "protocolArchive", ".", "as", "(", "WebArchive", ".", "class", ")", ")", ";", "removeTestClassFromDeployment", "(", "applicationArchive", ",", "testClass", ")", ";", "}", "}" ]
Adds Warp archive to the protocol archive to make it available for WARs and EARs.
[ "Adds", "Warp", "archive", "to", "the", "protocol", "archive", "to", "make", "it", "available", "for", "WARs", "and", "EARs", "." ]
e958f4d782851baf7f40e39835d3d1ad185b74dd
https://github.com/arquillian/arquillian-extension-warp/blob/e958f4d782851baf7f40e39835d3d1ad185b74dd/impl/src/main/java/org/jboss/arquillian/warp/impl/client/deployment/DeploymentEnricher.java#L106-L123
11,140
arquillian/arquillian-extension-warp
impl/src/main/java/org/jboss/arquillian/warp/impl/client/deployment/DeploymentEnricher.java
DeploymentEnricher.addWarpExtensionsDeployment
private void addWarpExtensionsDeployment(WebArchive archive) { final Collection<WarpDeploymentEnrichmentExtension> lifecycleExtensions = serviceLoader.get().all( WarpDeploymentEnrichmentExtension.class); for (WarpDeploymentEnrichmentExtension extension : lifecycleExtensions) { JavaArchive library = extension.getEnrichmentLibrary(); if (library != null) { archive.addAsLibrary(library); } extension.enrichWebArchive(archive); } }
java
private void addWarpExtensionsDeployment(WebArchive archive) { final Collection<WarpDeploymentEnrichmentExtension> lifecycleExtensions = serviceLoader.get().all( WarpDeploymentEnrichmentExtension.class); for (WarpDeploymentEnrichmentExtension extension : lifecycleExtensions) { JavaArchive library = extension.getEnrichmentLibrary(); if (library != null) { archive.addAsLibrary(library); } extension.enrichWebArchive(archive); } }
[ "private", "void", "addWarpExtensionsDeployment", "(", "WebArchive", "archive", ")", "{", "final", "Collection", "<", "WarpDeploymentEnrichmentExtension", ">", "lifecycleExtensions", "=", "serviceLoader", ".", "get", "(", ")", ".", "all", "(", "WarpDeploymentEnrichmentExtension", ".", "class", ")", ";", "for", "(", "WarpDeploymentEnrichmentExtension", "extension", ":", "lifecycleExtensions", ")", "{", "JavaArchive", "library", "=", "extension", ".", "getEnrichmentLibrary", "(", ")", ";", "if", "(", "library", "!=", "null", ")", "{", "archive", ".", "addAsLibrary", "(", "library", ")", ";", "}", "extension", ".", "enrichWebArchive", "(", "archive", ")", ";", "}", "}" ]
Adds all Warp lifecycle extension packages to the archive
[ "Adds", "all", "Warp", "lifecycle", "extension", "packages", "to", "the", "archive" ]
e958f4d782851baf7f40e39835d3d1ad185b74dd
https://github.com/arquillian/arquillian-extension-warp/blob/e958f4d782851baf7f40e39835d3d1ad185b74dd/impl/src/main/java/org/jboss/arquillian/warp/impl/client/deployment/DeploymentEnricher.java#L135-L146
11,141
JodaOrg/joda-time-jsptags
src/main/java/org/joda/time/contrib/jsptag/Util.java
Util.getScope
public static int getScope(String scope) { int ret = PageContext.PAGE_SCOPE; // default if (REQUEST.equalsIgnoreCase(scope)) { ret = PageContext.REQUEST_SCOPE; } else if (SESSION.equalsIgnoreCase(scope)) { ret = PageContext.SESSION_SCOPE; } else if (APPLICATION.equalsIgnoreCase(scope)) { ret = PageContext.APPLICATION_SCOPE; } return ret; }
java
public static int getScope(String scope) { int ret = PageContext.PAGE_SCOPE; // default if (REQUEST.equalsIgnoreCase(scope)) { ret = PageContext.REQUEST_SCOPE; } else if (SESSION.equalsIgnoreCase(scope)) { ret = PageContext.SESSION_SCOPE; } else if (APPLICATION.equalsIgnoreCase(scope)) { ret = PageContext.APPLICATION_SCOPE; } return ret; }
[ "public", "static", "int", "getScope", "(", "String", "scope", ")", "{", "int", "ret", "=", "PageContext", ".", "PAGE_SCOPE", ";", "// default", "if", "(", "REQUEST", ".", "equalsIgnoreCase", "(", "scope", ")", ")", "{", "ret", "=", "PageContext", ".", "REQUEST_SCOPE", ";", "}", "else", "if", "(", "SESSION", ".", "equalsIgnoreCase", "(", "scope", ")", ")", "{", "ret", "=", "PageContext", ".", "SESSION_SCOPE", ";", "}", "else", "if", "(", "APPLICATION", ".", "equalsIgnoreCase", "(", "scope", ")", ")", "{", "ret", "=", "PageContext", ".", "APPLICATION_SCOPE", ";", "}", "return", "ret", ";", "}" ]
Converts the given string description of a scope to the corresponding PageContext constant. The validity of the given scope has already been checked by the appropriate TLV. @param scope String description of scope @return PageContext constant corresponding to given scope description
[ "Converts", "the", "given", "string", "description", "of", "a", "scope", "to", "the", "corresponding", "PageContext", "constant", "." ]
69008a813568cb6f3e37ea7a80f8b1f2070edf14
https://github.com/JodaOrg/joda-time-jsptags/blob/69008a813568cb6f3e37ea7a80f8b1f2070edf14/src/main/java/org/joda/time/contrib/jsptag/Util.java#L69-L80
11,142
JodaOrg/joda-time-jsptags
src/main/java/org/joda/time/contrib/jsptag/Util.java
Util.findFormattingMatch
private static Locale findFormattingMatch(Locale pref, Locale[] avail) { Locale match = null; boolean langAndCountryMatch = false; for (int i = 0; i < avail.length; i++) { if (pref.equals(avail[i])) { // Exact match match = avail[i]; break; } else if (!"".equals(pref.getVariant()) && "".equals(avail[i].getVariant()) && pref.getLanguage().equals(avail[i].getLanguage()) && pref.getCountry().equals(avail[i].getCountry())) { // Language and country match; different variant match = avail[i]; langAndCountryMatch = true; } else if (!langAndCountryMatch && pref.getLanguage().equals(avail[i].getLanguage()) && ("".equals(avail[i].getCountry()))) { // Language match if (match == null) { match = avail[i]; } } } return match; }
java
private static Locale findFormattingMatch(Locale pref, Locale[] avail) { Locale match = null; boolean langAndCountryMatch = false; for (int i = 0; i < avail.length; i++) { if (pref.equals(avail[i])) { // Exact match match = avail[i]; break; } else if (!"".equals(pref.getVariant()) && "".equals(avail[i].getVariant()) && pref.getLanguage().equals(avail[i].getLanguage()) && pref.getCountry().equals(avail[i].getCountry())) { // Language and country match; different variant match = avail[i]; langAndCountryMatch = true; } else if (!langAndCountryMatch && pref.getLanguage().equals(avail[i].getLanguage()) && ("".equals(avail[i].getCountry()))) { // Language match if (match == null) { match = avail[i]; } } } return match; }
[ "private", "static", "Locale", "findFormattingMatch", "(", "Locale", "pref", ",", "Locale", "[", "]", "avail", ")", "{", "Locale", "match", "=", "null", ";", "boolean", "langAndCountryMatch", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "avail", ".", "length", ";", "i", "++", ")", "{", "if", "(", "pref", ".", "equals", "(", "avail", "[", "i", "]", ")", ")", "{", "// Exact match", "match", "=", "avail", "[", "i", "]", ";", "break", ";", "}", "else", "if", "(", "!", "\"\"", ".", "equals", "(", "pref", ".", "getVariant", "(", ")", ")", "&&", "\"\"", ".", "equals", "(", "avail", "[", "i", "]", ".", "getVariant", "(", ")", ")", "&&", "pref", ".", "getLanguage", "(", ")", ".", "equals", "(", "avail", "[", "i", "]", ".", "getLanguage", "(", ")", ")", "&&", "pref", ".", "getCountry", "(", ")", ".", "equals", "(", "avail", "[", "i", "]", ".", "getCountry", "(", ")", ")", ")", "{", "// Language and country match; different variant", "match", "=", "avail", "[", "i", "]", ";", "langAndCountryMatch", "=", "true", ";", "}", "else", "if", "(", "!", "langAndCountryMatch", "&&", "pref", ".", "getLanguage", "(", ")", ".", "equals", "(", "avail", "[", "i", "]", ".", "getLanguage", "(", ")", ")", "&&", "(", "\"\"", ".", "equals", "(", "avail", "[", "i", "]", ".", "getCountry", "(", ")", ")", ")", ")", "{", "// Language match", "if", "(", "match", "==", "null", ")", "{", "match", "=", "avail", "[", "i", "]", ";", "}", "}", "}", "return", "match", ";", "}" ]
Returns the best match between the given preferred locale and the given available locales. The best match is given as the first available locale that exactly matches the given preferred locale ("exact match"). If no exact match exists, the best match is given to an available locale that meets the following criteria (in order of priority): - available locale's variant is empty and exact match for both language and country - available locale's variant and country are empty, and exact match for language. @param pref the preferred locale @param avail the available formatting locales @return Available locale that best matches the given preferred locale, or <tt>null</tt> if no match exists
[ "Returns", "the", "best", "match", "between", "the", "given", "preferred", "locale", "and", "the", "given", "available", "locales", "." ]
69008a813568cb6f3e37ea7a80f8b1f2070edf14
https://github.com/JodaOrg/joda-time-jsptags/blob/69008a813568cb6f3e37ea7a80f8b1f2070edf14/src/main/java/org/joda/time/contrib/jsptag/Util.java#L406-L431
11,143
JodaOrg/joda-time-jsptags
src/main/java/org/joda/time/contrib/jsptag/Util.java
Util.getLocalizationContext
public static LocalizationContext getLocalizationContext(PageContext pc) { LocalizationContext locCtxt = null; Object obj = Config.find(pc, Config.FMT_LOCALIZATION_CONTEXT); if (obj == null) { return null; } if (obj instanceof LocalizationContext) { locCtxt = (LocalizationContext) obj; } else { // localization context is a bundle basename locCtxt = getLocalizationContext(pc, (String) obj); } return locCtxt; }
java
public static LocalizationContext getLocalizationContext(PageContext pc) { LocalizationContext locCtxt = null; Object obj = Config.find(pc, Config.FMT_LOCALIZATION_CONTEXT); if (obj == null) { return null; } if (obj instanceof LocalizationContext) { locCtxt = (LocalizationContext) obj; } else { // localization context is a bundle basename locCtxt = getLocalizationContext(pc, (String) obj); } return locCtxt; }
[ "public", "static", "LocalizationContext", "getLocalizationContext", "(", "PageContext", "pc", ")", "{", "LocalizationContext", "locCtxt", "=", "null", ";", "Object", "obj", "=", "Config", ".", "find", "(", "pc", ",", "Config", ".", "FMT_LOCALIZATION_CONTEXT", ")", ";", "if", "(", "obj", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "obj", "instanceof", "LocalizationContext", ")", "{", "locCtxt", "=", "(", "LocalizationContext", ")", "obj", ";", "}", "else", "{", "// localization context is a bundle basename", "locCtxt", "=", "getLocalizationContext", "(", "pc", ",", "(", "String", ")", "obj", ")", ";", "}", "return", "locCtxt", ";", "}" ]
Gets the default I18N localization context. @param pc Page in which to look up the default I18N localization context
[ "Gets", "the", "default", "I18N", "localization", "context", "." ]
69008a813568cb6f3e37ea7a80f8b1f2070edf14
https://github.com/JodaOrg/joda-time-jsptags/blob/69008a813568cb6f3e37ea7a80f8b1f2070edf14/src/main/java/org/joda/time/contrib/jsptag/Util.java#L438-L454
11,144
nmorel/gwt-jackson-rest
api/src/main/java/com/github/nmorel/gwtjackson/rest/api/RestRequestBuilder.java
RestRequestBuilder.addQueryParam
public RestRequestBuilder<B, R> addQueryParam( String name, Collection<?> values ) { if ( null != values ) { List<Object> allValues = getQueryParams( name ); allValues.addAll( values ); } return this; }
java
public RestRequestBuilder<B, R> addQueryParam( String name, Collection<?> values ) { if ( null != values ) { List<Object> allValues = getQueryParams( name ); allValues.addAll( values ); } return this; }
[ "public", "RestRequestBuilder", "<", "B", ",", "R", ">", "addQueryParam", "(", "String", "name", ",", "Collection", "<", "?", ">", "values", ")", "{", "if", "(", "null", "!=", "values", ")", "{", "List", "<", "Object", ">", "allValues", "=", "getQueryParams", "(", "name", ")", ";", "allValues", ".", "addAll", "(", "values", ")", ";", "}", "return", "this", ";", "}" ]
Add a query parameter. If a null or empty collection is passed, the param is ignored. @param name Name of the parameter @param values Value of the parameter @return this builder
[ "Add", "a", "query", "parameter", ".", "If", "a", "null", "or", "empty", "collection", "is", "passed", "the", "param", "is", "ignored", "." ]
2493554a4e61a33644931da58d27145553572f09
https://github.com/nmorel/gwt-jackson-rest/blob/2493554a4e61a33644931da58d27145553572f09/api/src/main/java/com/github/nmorel/gwtjackson/rest/api/RestRequestBuilder.java#L188-L194
11,145
nmorel/gwt-jackson-rest
api/src/main/java/com/github/nmorel/gwtjackson/rest/api/RestRequestBuilder.java
RestRequestBuilder.addQueryParam
public RestRequestBuilder<B, R> addQueryParam( String name, Object[] values ) { if ( null != values ) { List<Object> allValues = getQueryParams( name ); for ( Object value : values ) { allValues.add( value ); } } return this; }
java
public RestRequestBuilder<B, R> addQueryParam( String name, Object[] values ) { if ( null != values ) { List<Object> allValues = getQueryParams( name ); for ( Object value : values ) { allValues.add( value ); } } return this; }
[ "public", "RestRequestBuilder", "<", "B", ",", "R", ">", "addQueryParam", "(", "String", "name", ",", "Object", "[", "]", "values", ")", "{", "if", "(", "null", "!=", "values", ")", "{", "List", "<", "Object", ">", "allValues", "=", "getQueryParams", "(", "name", ")", ";", "for", "(", "Object", "value", ":", "values", ")", "{", "allValues", ".", "add", "(", "value", ")", ";", "}", "}", "return", "this", ";", "}" ]
Add a query parameter. If a null or empty array is passed, the param is ignored. @param name Name of the parameter @param values Value of the parameter @return this builder
[ "Add", "a", "query", "parameter", ".", "If", "a", "null", "or", "empty", "array", "is", "passed", "the", "param", "is", "ignored", "." ]
2493554a4e61a33644931da58d27145553572f09
https://github.com/nmorel/gwt-jackson-rest/blob/2493554a4e61a33644931da58d27145553572f09/api/src/main/java/com/github/nmorel/gwtjackson/rest/api/RestRequestBuilder.java#L204-L212
11,146
arquillian/arquillian-extension-warp
impl/src/main/java/org/jboss/arquillian/warp/impl/utils/Base64.java
Base64.encodeInteger
public static byte[] encodeInteger(BigInteger bigInt) { if (bigInt == null) { throw new NullPointerException("encodeInteger called with null parameter"); } return encodeBase64(toIntegerBytes(bigInt), false); }
java
public static byte[] encodeInteger(BigInteger bigInt) { if (bigInt == null) { throw new NullPointerException("encodeInteger called with null parameter"); } return encodeBase64(toIntegerBytes(bigInt), false); }
[ "public", "static", "byte", "[", "]", "encodeInteger", "(", "BigInteger", "bigInt", ")", "{", "if", "(", "bigInt", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"encodeInteger called with null parameter\"", ")", ";", "}", "return", "encodeBase64", "(", "toIntegerBytes", "(", "bigInt", ")", ",", "false", ")", ";", "}" ]
Encodes to a byte64-encoded integer according to crypto standards such as W3C's XML-Signature @param bigInt a BigInteger @return A byte array containing base64 character data @throws NullPointerException if null is passed in @since 1.4
[ "Encodes", "to", "a", "byte64", "-", "encoded", "integer", "according", "to", "crypto", "standards", "such", "as", "W3C", "s", "XML", "-", "Signature" ]
e958f4d782851baf7f40e39835d3d1ad185b74dd
https://github.com/arquillian/arquillian-extension-warp/blob/e958f4d782851baf7f40e39835d3d1ad185b74dd/impl/src/main/java/org/jboss/arquillian/warp/impl/utils/Base64.java#L662-L667
11,147
nmorel/gwt-jackson-rest
processor/src/main/java/com/github/nmorel/gwtjackson/rest/processor/RestServiceMethod.java
RestServiceMethod.removeEnclosedCurlyBraces
private String removeEnclosedCurlyBraces( String str ) { final char curlyReplacement = 6; char[] chars = str.toCharArray(); int open = 0; for ( int i = 0; i < chars.length; i++ ) { if ( chars[i] == '{' ) { if ( open != 0 ) chars[i] = curlyReplacement; open++; } else if ( chars[i] == '}' ) { open--; if ( open != 0 ) { chars[i] = curlyReplacement; } } } char[] res = new char[chars.length]; int j = 0; for( int i = 0; i < chars.length; i++ ) { if( chars[i] != curlyReplacement ) { res[j++] = chars[i]; } } return new String( Arrays.copyOf( res, j ) ); }
java
private String removeEnclosedCurlyBraces( String str ) { final char curlyReplacement = 6; char[] chars = str.toCharArray(); int open = 0; for ( int i = 0; i < chars.length; i++ ) { if ( chars[i] == '{' ) { if ( open != 0 ) chars[i] = curlyReplacement; open++; } else if ( chars[i] == '}' ) { open--; if ( open != 0 ) { chars[i] = curlyReplacement; } } } char[] res = new char[chars.length]; int j = 0; for( int i = 0; i < chars.length; i++ ) { if( chars[i] != curlyReplacement ) { res[j++] = chars[i]; } } return new String( Arrays.copyOf( res, j ) ); }
[ "private", "String", "removeEnclosedCurlyBraces", "(", "String", "str", ")", "{", "final", "char", "curlyReplacement", "=", "6", ";", "char", "[", "]", "chars", "=", "str", ".", "toCharArray", "(", ")", ";", "int", "open", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "chars", ".", "length", ";", "i", "++", ")", "{", "if", "(", "chars", "[", "i", "]", "==", "'", "'", ")", "{", "if", "(", "open", "!=", "0", ")", "chars", "[", "i", "]", "=", "curlyReplacement", ";", "open", "++", ";", "}", "else", "if", "(", "chars", "[", "i", "]", "==", "'", "'", ")", "{", "open", "--", ";", "if", "(", "open", "!=", "0", ")", "{", "chars", "[", "i", "]", "=", "curlyReplacement", ";", "}", "}", "}", "char", "[", "]", "res", "=", "new", "char", "[", "chars", ".", "length", "]", ";", "int", "j", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "chars", ".", "length", ";", "i", "++", ")", "{", "if", "(", "chars", "[", "i", "]", "!=", "curlyReplacement", ")", "{", "res", "[", "j", "++", "]", "=", "chars", "[", "i", "]", ";", "}", "}", "return", "new", "String", "(", "Arrays", ".", "copyOf", "(", "res", ",", "j", ")", ")", ";", "}" ]
Enclosed curly braces cannot be matched with a regex. Thus we remove them before applying the replaceAll method
[ "Enclosed", "curly", "braces", "cannot", "be", "matched", "with", "a", "regex", ".", "Thus", "we", "remove", "them", "before", "applying", "the", "replaceAll", "method" ]
2493554a4e61a33644931da58d27145553572f09
https://github.com/nmorel/gwt-jackson-rest/blob/2493554a4e61a33644931da58d27145553572f09/processor/src/main/java/com/github/nmorel/gwtjackson/rest/processor/RestServiceMethod.java#L91-L118
11,148
arquillian/arquillian-extension-warp
api/src/main/java/org/jboss/arquillian/warp/Warp.java
Warp.initiate
public static WarpExecutionBuilder initiate(Activity activity) { WarpRuntime runtime = WarpRuntime.getInstance(); if (runtime == null) { throw new IllegalStateException( "The Warp runtime isn't initialized. You need to make sure arquillian-warp-impl is on classpath and annotate a test class with @WarpTest in order to initialize Warp."); } return runtime.getWarpActivityBuilder().initiate(activity); }
java
public static WarpExecutionBuilder initiate(Activity activity) { WarpRuntime runtime = WarpRuntime.getInstance(); if (runtime == null) { throw new IllegalStateException( "The Warp runtime isn't initialized. You need to make sure arquillian-warp-impl is on classpath and annotate a test class with @WarpTest in order to initialize Warp."); } return runtime.getWarpActivityBuilder().initiate(activity); }
[ "public", "static", "WarpExecutionBuilder", "initiate", "(", "Activity", "activity", ")", "{", "WarpRuntime", "runtime", "=", "WarpRuntime", ".", "getInstance", "(", ")", ";", "if", "(", "runtime", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"The Warp runtime isn't initialized. You need to make sure arquillian-warp-impl is on classpath and annotate a test class with @WarpTest in order to initialize Warp.\"", ")", ";", "}", "return", "runtime", ".", "getWarpActivityBuilder", "(", ")", ".", "initiate", "(", "activity", ")", ";", "}" ]
Takes client activity which should be performed in order to cause server request. @param activity the client activity to execute @return {@link WarpActivityBuilder} instance
[ "Takes", "client", "activity", "which", "should", "be", "performed", "in", "order", "to", "cause", "server", "request", "." ]
e958f4d782851baf7f40e39835d3d1ad185b74dd
https://github.com/arquillian/arquillian-extension-warp/blob/e958f4d782851baf7f40e39835d3d1ad185b74dd/api/src/main/java/org/jboss/arquillian/warp/Warp.java#L36-L46
11,149
joakime/android-apk-parser
src/main/java/net/erdfelt/android/apk/io/LEInputStream.java
LEInputStream.readInt
public int readInt() throws IOException { int value = 0; value += (read() & 0xff) << 0; value += (read() & 0xff) << 8; value += (read() & 0xff) << 16; value += (read() & 0xff) << 24; return (int) value; }
java
public int readInt() throws IOException { int value = 0; value += (read() & 0xff) << 0; value += (read() & 0xff) << 8; value += (read() & 0xff) << 16; value += (read() & 0xff) << 24; return (int) value; }
[ "public", "int", "readInt", "(", ")", "throws", "IOException", "{", "int", "value", "=", "0", ";", "value", "+=", "(", "read", "(", ")", "&", "0xff", ")", "<<", "0", ";", "value", "+=", "(", "read", "(", ")", "&", "0xff", ")", "<<", "8", ";", "value", "+=", "(", "read", "(", ")", "&", "0xff", ")", "<<", "16", ";", "value", "+=", "(", "read", "(", ")", "&", "0xff", ")", "<<", "24", ";", "return", "(", "int", ")", "value", ";", "}" ]
Read 32bit word as integer. @return the integer value @throws IOException
[ "Read", "32bit", "word", "as", "integer", "." ]
fe7be2f15ae1134834fea826eb2b94073b3c93e3
https://github.com/joakime/android-apk-parser/blob/fe7be2f15ae1134834fea826eb2b94073b3c93e3/src/main/java/net/erdfelt/android/apk/io/LEInputStream.java#L53-L60
11,150
joakime/android-apk-parser
src/main/java/net/erdfelt/android/apk/io/LEInputStream.java
LEInputStream.readIntArray
public int[] readIntArray(int length) throws IOException { int arr[] = new int[length]; for (int i = 0; i < length; i++) { arr[i] = readInt(); } return arr; }
java
public int[] readIntArray(int length) throws IOException { int arr[] = new int[length]; for (int i = 0; i < length; i++) { arr[i] = readInt(); } return arr; }
[ "public", "int", "[", "]", "readIntArray", "(", "int", "length", ")", "throws", "IOException", "{", "int", "arr", "[", "]", "=", "new", "int", "[", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "arr", "[", "i", "]", "=", "readInt", "(", ")", ";", "}", "return", "arr", ";", "}" ]
Read an array of 32bit words. @param length size of the array (in 32bit word count, not byte count) @return the array of 32bit words @throws IOException
[ "Read", "an", "array", "of", "32bit", "words", "." ]
fe7be2f15ae1134834fea826eb2b94073b3c93e3
https://github.com/joakime/android-apk-parser/blob/fe7be2f15ae1134834fea826eb2b94073b3c93e3/src/main/java/net/erdfelt/android/apk/io/LEInputStream.java#L85-L91
11,151
joakime/android-apk-parser
src/main/java/net/erdfelt/android/apk/io/LEInputStream.java
LEInputStream.readByteArray
public byte[] readByteArray(int length) throws IOException { byte buf[] = new byte[length]; for (int i = 0; i < length; i++) { buf[i] = (byte) read(); } return buf; }
java
public byte[] readByteArray(int length) throws IOException { byte buf[] = new byte[length]; for (int i = 0; i < length; i++) { buf[i] = (byte) read(); } return buf; }
[ "public", "byte", "[", "]", "readByteArray", "(", "int", "length", ")", "throws", "IOException", "{", "byte", "buf", "[", "]", "=", "new", "byte", "[", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "buf", "[", "i", "]", "=", "(", "byte", ")", "read", "(", ")", ";", "}", "return", "buf", ";", "}" ]
Read an array of bytes. @param length size of the array (in bytes) @return the array of bytes @throws IOException
[ "Read", "an", "array", "of", "bytes", "." ]
fe7be2f15ae1134834fea826eb2b94073b3c93e3
https://github.com/joakime/android-apk-parser/blob/fe7be2f15ae1134834fea826eb2b94073b3c93e3/src/main/java/net/erdfelt/android/apk/io/LEInputStream.java#L101-L107
11,152
arquillian/arquillian-extension-warp
impl/src/main/java/org/jboss/arquillian/warp/impl/utils/Rethrow.java
Rethrow.asUnchecked
public static void asUnchecked(Throwable t, Class<? extends RuntimeException> checkedExceptionWrapper) { if (t instanceof AssertionError) { throw (AssertionError) t; } else if (t instanceof RuntimeException) { throw (RuntimeException) t; } else { RuntimeException exception; try { exception = checkedExceptionWrapper.getConstructor(Throwable.class).newInstance(t); } catch (Exception e) { throw new RuntimeException(t); } throw exception; } }
java
public static void asUnchecked(Throwable t, Class<? extends RuntimeException> checkedExceptionWrapper) { if (t instanceof AssertionError) { throw (AssertionError) t; } else if (t instanceof RuntimeException) { throw (RuntimeException) t; } else { RuntimeException exception; try { exception = checkedExceptionWrapper.getConstructor(Throwable.class).newInstance(t); } catch (Exception e) { throw new RuntimeException(t); } throw exception; } }
[ "public", "static", "void", "asUnchecked", "(", "Throwable", "t", ",", "Class", "<", "?", "extends", "RuntimeException", ">", "checkedExceptionWrapper", ")", "{", "if", "(", "t", "instanceof", "AssertionError", ")", "{", "throw", "(", "AssertionError", ")", "t", ";", "}", "else", "if", "(", "t", "instanceof", "RuntimeException", ")", "{", "throw", "(", "RuntimeException", ")", "t", ";", "}", "else", "{", "RuntimeException", "exception", ";", "try", "{", "exception", "=", "checkedExceptionWrapper", ".", "getConstructor", "(", "Throwable", ".", "class", ")", ".", "newInstance", "(", "t", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "t", ")", ";", "}", "throw", "exception", ";", "}", "}" ]
Checks whether given throwable is unchecked and if not, it will be wrapped as unchecked exception of given type
[ "Checks", "whether", "given", "throwable", "is", "unchecked", "and", "if", "not", "it", "will", "be", "wrapped", "as", "unchecked", "exception", "of", "given", "type" ]
e958f4d782851baf7f40e39835d3d1ad185b74dd
https://github.com/arquillian/arquillian-extension-warp/blob/e958f4d782851baf7f40e39835d3d1ad185b74dd/impl/src/main/java/org/jboss/arquillian/warp/impl/utils/Rethrow.java#L41-L55
11,153
JodaOrg/joda-time-jsptags
src/main/java/org/joda/time/contrib/jsptag/Resources.java
Resources.getMessage
public static String getMessage(String name, Object[] a) throws MissingResourceException { String res = rb.getString(name); return MessageFormat.format(res, a); }
java
public static String getMessage(String name, Object[] a) throws MissingResourceException { String res = rb.getString(name); return MessageFormat.format(res, a); }
[ "public", "static", "String", "getMessage", "(", "String", "name", ",", "Object", "[", "]", "a", ")", "throws", "MissingResourceException", "{", "String", "res", "=", "rb", ".", "getString", "(", "name", ")", ";", "return", "MessageFormat", ".", "format", "(", "res", ",", "a", ")", ";", "}" ]
Retrieves a message with arbitrarily many arguments.
[ "Retrieves", "a", "message", "with", "arbitrarily", "many", "arguments", "." ]
69008a813568cb6f3e37ea7a80f8b1f2070edf14
https://github.com/JodaOrg/joda-time-jsptags/blob/69008a813568cb6f3e37ea7a80f8b1f2070edf14/src/main/java/org/joda/time/contrib/jsptag/Resources.java#L64-L68
11,154
JodaOrg/joda-time-jsptags
src/main/java/org/joda/time/contrib/jsptag/Resources.java
Resources.getMessage
public static String getMessage(String name, Object a1, Object a2, Object a3, Object a4) throws MissingResourceException { return getMessage(name, new Object[] { a1, a2, a3, a4 }); }
java
public static String getMessage(String name, Object a1, Object a2, Object a3, Object a4) throws MissingResourceException { return getMessage(name, new Object[] { a1, a2, a3, a4 }); }
[ "public", "static", "String", "getMessage", "(", "String", "name", ",", "Object", "a1", ",", "Object", "a2", ",", "Object", "a3", ",", "Object", "a4", ")", "throws", "MissingResourceException", "{", "return", "getMessage", "(", "name", ",", "new", "Object", "[", "]", "{", "a1", ",", "a2", ",", "a3", ",", "a4", "}", ")", ";", "}" ]
Retrieves a message with four arguments.
[ "Retrieves", "a", "message", "with", "four", "arguments", "." ]
69008a813568cb6f3e37ea7a80f8b1f2070edf14
https://github.com/JodaOrg/joda-time-jsptags/blob/69008a813568cb6f3e37ea7a80f8b1f2070edf14/src/main/java/org/joda/time/contrib/jsptag/Resources.java#L92-L99
11,155
arquillian/arquillian-extension-warp
impl/src/main/java/org/jboss/arquillian/warp/impl/client/verification/SecurityActions.java
SecurityActions.getAncestors
static Class<?>[] getAncestors(Class<?> clazz) { Set<Class<?>> classes = new HashSet<Class<?>>(); while (clazz != null) { classes.add(clazz); if (clazz.getSuperclass() != null) { classes.add(clazz.getSuperclass()); } classes.addAll(Arrays.asList(clazz.getInterfaces())); for (Class<?> interfaze : clazz.getInterfaces()) { classes.addAll(Arrays.asList(getAncestors(interfaze))); } clazz = clazz.getSuperclass(); } return classes.toArray(new Class<?>[classes.size()]); }
java
static Class<?>[] getAncestors(Class<?> clazz) { Set<Class<?>> classes = new HashSet<Class<?>>(); while (clazz != null) { classes.add(clazz); if (clazz.getSuperclass() != null) { classes.add(clazz.getSuperclass()); } classes.addAll(Arrays.asList(clazz.getInterfaces())); for (Class<?> interfaze : clazz.getInterfaces()) { classes.addAll(Arrays.asList(getAncestors(interfaze))); } clazz = clazz.getSuperclass(); } return classes.toArray(new Class<?>[classes.size()]); }
[ "static", "Class", "<", "?", ">", "[", "]", "getAncestors", "(", "Class", "<", "?", ">", "clazz", ")", "{", "Set", "<", "Class", "<", "?", ">", ">", "classes", "=", "new", "HashSet", "<", "Class", "<", "?", ">", ">", "(", ")", ";", "while", "(", "clazz", "!=", "null", ")", "{", "classes", ".", "add", "(", "clazz", ")", ";", "if", "(", "clazz", ".", "getSuperclass", "(", ")", "!=", "null", ")", "{", "classes", ".", "add", "(", "clazz", ".", "getSuperclass", "(", ")", ")", ";", "}", "classes", ".", "addAll", "(", "Arrays", ".", "asList", "(", "clazz", ".", "getInterfaces", "(", ")", ")", ")", ";", "for", "(", "Class", "<", "?", ">", "interfaze", ":", "clazz", ".", "getInterfaces", "(", ")", ")", "{", "classes", ".", "addAll", "(", "Arrays", ".", "asList", "(", "getAncestors", "(", "interfaze", ")", ")", ")", ";", "}", "clazz", "=", "clazz", ".", "getSuperclass", "(", ")", ";", "}", "return", "classes", ".", "toArray", "(", "new", "Class", "<", "?", ">", "[", "classes", ".", "size", "(", ")", "]", ")", ";", "}" ]
Get all subclasses and interfaces in whole class hierarchy
[ "Get", "all", "subclasses", "and", "interfaces", "in", "whole", "class", "hierarchy" ]
e958f4d782851baf7f40e39835d3d1ad185b74dd
https://github.com/arquillian/arquillian-extension-warp/blob/e958f4d782851baf7f40e39835d3d1ad185b74dd/impl/src/main/java/org/jboss/arquillian/warp/impl/client/verification/SecurityActions.java#L293-L309
11,156
nmorel/gwt-jackson-rest
processor/src/main/java/com/github/nmorel/gwtjackson/rest/processor/GenRestBuilderProcessor.java
GenRestBuilderProcessor.generateBuilder
private TypeSpec generateBuilder( RestService restService ) { TypeSpec.Builder typeBuilder = TypeSpec.classBuilder( restService.getBuilderSimpleClassName() ) .addModifiers( Modifier.PUBLIC, Modifier.FINAL ) .addJavadoc( "Generated REST service builder for {@link $L}.\n", restService.getTypeElement().getQualifiedName() ) .addMethod( MethodSpec.constructorBuilder().addModifiers( Modifier.PRIVATE ).build() ); Map<TypeMirror, MethodSpec> mapperGetters = buildMappers( typeBuilder, restService ); for ( RestServiceMethod method : restService.getMethods() ) { buildMethod( typeBuilder, mapperGetters, method ); } return typeBuilder.build(); }
java
private TypeSpec generateBuilder( RestService restService ) { TypeSpec.Builder typeBuilder = TypeSpec.classBuilder( restService.getBuilderSimpleClassName() ) .addModifiers( Modifier.PUBLIC, Modifier.FINAL ) .addJavadoc( "Generated REST service builder for {@link $L}.\n", restService.getTypeElement().getQualifiedName() ) .addMethod( MethodSpec.constructorBuilder().addModifiers( Modifier.PRIVATE ).build() ); Map<TypeMirror, MethodSpec> mapperGetters = buildMappers( typeBuilder, restService ); for ( RestServiceMethod method : restService.getMethods() ) { buildMethod( typeBuilder, mapperGetters, method ); } return typeBuilder.build(); }
[ "private", "TypeSpec", "generateBuilder", "(", "RestService", "restService", ")", "{", "TypeSpec", ".", "Builder", "typeBuilder", "=", "TypeSpec", ".", "classBuilder", "(", "restService", ".", "getBuilderSimpleClassName", "(", ")", ")", ".", "addModifiers", "(", "Modifier", ".", "PUBLIC", ",", "Modifier", ".", "FINAL", ")", ".", "addJavadoc", "(", "\"Generated REST service builder for {@link $L}.\\n\"", ",", "restService", ".", "getTypeElement", "(", ")", ".", "getQualifiedName", "(", ")", ")", ".", "addMethod", "(", "MethodSpec", ".", "constructorBuilder", "(", ")", ".", "addModifiers", "(", "Modifier", ".", "PRIVATE", ")", ".", "build", "(", ")", ")", ";", "Map", "<", "TypeMirror", ",", "MethodSpec", ">", "mapperGetters", "=", "buildMappers", "(", "typeBuilder", ",", "restService", ")", ";", "for", "(", "RestServiceMethod", "method", ":", "restService", ".", "getMethods", "(", ")", ")", "{", "buildMethod", "(", "typeBuilder", ",", "mapperGetters", ",", "method", ")", ";", "}", "return", "typeBuilder", ".", "build", "(", ")", ";", "}" ]
Generate the rest service builder @param restService The rest service
[ "Generate", "the", "rest", "service", "builder" ]
2493554a4e61a33644931da58d27145553572f09
https://github.com/nmorel/gwt-jackson-rest/blob/2493554a4e61a33644931da58d27145553572f09/processor/src/main/java/com/github/nmorel/gwtjackson/rest/processor/GenRestBuilderProcessor.java#L153-L167
11,157
nmorel/gwt-jackson-rest
processor/src/main/java/com/github/nmorel/gwtjackson/rest/processor/GenRestBuilderProcessor.java
GenRestBuilderProcessor.note
public void note( Element e, String msg, Object... args ) { messager.printMessage( Diagnostic.Kind.NOTE, String.format( msg, args ), e ); }
java
public void note( Element e, String msg, Object... args ) { messager.printMessage( Diagnostic.Kind.NOTE, String.format( msg, args ), e ); }
[ "public", "void", "note", "(", "Element", "e", ",", "String", "msg", ",", "Object", "...", "args", ")", "{", "messager", ".", "printMessage", "(", "Diagnostic", ".", "Kind", ".", "NOTE", ",", "String", ".", "format", "(", "msg", ",", "args", ")", ",", "e", ")", ";", "}" ]
Prints a note message @param e The element which has caused the error. Can be null @param msg The error message @param args if the error message contains %s, %d etc. placeholders this arguments will be used to replace them
[ "Prints", "a", "note", "message" ]
2493554a4e61a33644931da58d27145553572f09
https://github.com/nmorel/gwt-jackson-rest/blob/2493554a4e61a33644931da58d27145553572f09/processor/src/main/java/com/github/nmorel/gwtjackson/rest/processor/GenRestBuilderProcessor.java#L340-L342
11,158
nmorel/gwt-jackson-rest
processor/src/main/java/com/github/nmorel/gwtjackson/rest/processor/GenRestBuilderProcessor.java
GenRestBuilderProcessor.warn
public void warn( Element e, String msg, Object... args ) { messager.printMessage( Diagnostic.Kind.WARNING, String.format( msg, args ), e ); }
java
public void warn( Element e, String msg, Object... args ) { messager.printMessage( Diagnostic.Kind.WARNING, String.format( msg, args ), e ); }
[ "public", "void", "warn", "(", "Element", "e", ",", "String", "msg", ",", "Object", "...", "args", ")", "{", "messager", ".", "printMessage", "(", "Diagnostic", ".", "Kind", ".", "WARNING", ",", "String", ".", "format", "(", "msg", ",", "args", ")", ",", "e", ")", ";", "}" ]
Prints a warning message @param e The element which has caused the error. Can be null @param msg The error message @param args if the error message contains %s, %d etc. placeholders this arguments will be used to replace them
[ "Prints", "a", "warning", "message" ]
2493554a4e61a33644931da58d27145553572f09
https://github.com/nmorel/gwt-jackson-rest/blob/2493554a4e61a33644931da58d27145553572f09/processor/src/main/java/com/github/nmorel/gwtjackson/rest/processor/GenRestBuilderProcessor.java#L352-L354
11,159
nmorel/gwt-jackson-rest
processor/src/main/java/com/github/nmorel/gwtjackson/rest/processor/GenRestBuilderProcessor.java
GenRestBuilderProcessor.error
public void error( Element e, String msg, Object... args ) { messager.printMessage( Diagnostic.Kind.ERROR, String.format( msg, args ), e ); }
java
public void error( Element e, String msg, Object... args ) { messager.printMessage( Diagnostic.Kind.ERROR, String.format( msg, args ), e ); }
[ "public", "void", "error", "(", "Element", "e", ",", "String", "msg", ",", "Object", "...", "args", ")", "{", "messager", ".", "printMessage", "(", "Diagnostic", ".", "Kind", ".", "ERROR", ",", "String", ".", "format", "(", "msg", ",", "args", ")", ",", "e", ")", ";", "}" ]
Prints an error message @param e The element which has caused the error. Can be null @param msg The error message @param args if the error message contains %s, %d etc. placeholders this arguments will be used to replace them
[ "Prints", "an", "error", "message" ]
2493554a4e61a33644931da58d27145553572f09
https://github.com/nmorel/gwt-jackson-rest/blob/2493554a4e61a33644931da58d27145553572f09/processor/src/main/java/com/github/nmorel/gwtjackson/rest/processor/GenRestBuilderProcessor.java#L364-L366
11,160
datasift/datasift-java
src/main/java/com/datasift/client/managedsource/sources/FacebookPage.java
FacebookPage.addInstagramLinkedPage
public FacebookPage addInstagramLinkedPage(String pageid) { ResourceParams parameterSet = newResourceParams(); parameterSet.set("id", pageid); parameterSet.set("type", "instagram"); return this; }
java
public FacebookPage addInstagramLinkedPage(String pageid) { ResourceParams parameterSet = newResourceParams(); parameterSet.set("id", pageid); parameterSet.set("type", "instagram"); return this; }
[ "public", "FacebookPage", "addInstagramLinkedPage", "(", "String", "pageid", ")", "{", "ResourceParams", "parameterSet", "=", "newResourceParams", "(", ")", ";", "parameterSet", ".", "set", "(", "\"id\"", ",", "pageid", ")", ";", "parameterSet", ".", "set", "(", "\"type\"", ",", "\"instagram\"", ")", ";", "return", "this", ";", "}" ]
Add a facebook page to be crawled for instagram content @param pageid the ID of the page, usually numerical @return
[ "Add", "a", "facebook", "page", "to", "be", "crawled", "for", "instagram", "content" ]
09de124f2a1a507ff6181e59875c6f325290850e
https://github.com/datasift/datasift-java/blob/09de124f2a1a507ff6181e59875c6f325290850e/src/main/java/com/datasift/client/managedsource/sources/FacebookPage.java#L102-L107
11,161
datasift/datasift-java
src/main/java/com/datasift/client/managedsource/sources/FacebookPage.java
FacebookPage.addInstagramUser
public FacebookPage addInstagramUser(String username) { ResourceParams parameterSet = newResourceParams(); parameterSet.set("id", username); parameterSet.set("type", "instagram_user"); return this; }
java
public FacebookPage addInstagramUser(String username) { ResourceParams parameterSet = newResourceParams(); parameterSet.set("id", username); parameterSet.set("type", "instagram_user"); return this; }
[ "public", "FacebookPage", "addInstagramUser", "(", "String", "username", ")", "{", "ResourceParams", "parameterSet", "=", "newResourceParams", "(", ")", ";", "parameterSet", ".", "set", "(", "\"id\"", ",", "username", ")", ";", "parameterSet", ".", "set", "(", "\"type\"", ",", "\"instagram_user\"", ")", ";", "return", "this", ";", "}" ]
Add an instagram user to be crawled for content @param username ID of the user to be checked, usually a textual name @return
[ "Add", "an", "instagram", "user", "to", "be", "crawled", "for", "content" ]
09de124f2a1a507ff6181e59875c6f325290850e
https://github.com/datasift/datasift-java/blob/09de124f2a1a507ff6181e59875c6f325290850e/src/main/java/com/datasift/client/managedsource/sources/FacebookPage.java#L115-L120
11,162
arquillian/arquillian-extension-warp
impl/src/main/java/org/jboss/arquillian/warp/impl/client/commandBus/CommandBusOnClient.java
CommandBusOnClient.execute
private <T> T execute(String url, Class<T> returnType, Object requestObject) throws Exception { URLConnection connection = new URL(url).openConnection(); if (!(connection instanceof HttpURLConnection)) { throw new IllegalStateException("Not an http connection! " + connection); } HttpURLConnection httpConnection = (HttpURLConnection) connection; httpConnection.setUseCaches(false); httpConnection.setDefaultUseCaches(false); httpConnection.setDoInput(true); /* * With followRedirects enabled, simple URL redirects work as expected. But with port redirects (http->https) * followRedirects doesn't work and a HTTP 302 code is returned instead (ARQ-1365). * * In order to handle all redirects in one place, followRedirects is set to false and all HTTP 302 response codes are * treated accordingly within the execute method. */ httpConnection.setInstanceFollowRedirects(false); try { if (requestObject != null) { httpConnection.setRequestMethod("POST"); httpConnection.setDoOutput(true); httpConnection.setRequestProperty("Content-Type", "application/octet-stream"); } if (requestObject != null) { ObjectOutputStream ous = new ObjectOutputStream(httpConnection.getOutputStream()); try { ous.writeObject(requestObject); } catch (Exception e) { throw new RuntimeException("Error sending request Object, " + requestObject, e); } finally { ous.flush(); ous.close(); } } try { httpConnection.getResponseCode(); } catch (ConnectException e) { return null; // Could not connect } if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK) { ObjectInputStream ois = new ObjectInputStream(httpConnection.getInputStream()); Object o; try { o = ois.readObject(); } finally { ois.close(); } if (!returnType.isInstance(o)) { throw new IllegalStateException( "Error reading results, expected a " + returnType.getName() + " but got " + o); } return returnType.cast(o); } else if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_NO_CONTENT) { return null; } else if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_MOVED_TEMP) { String redirectUrl = httpConnection.getHeaderField("Location"); return execute(redirectUrl, returnType, requestObject); } else if (httpConnection.getResponseCode() != HttpURLConnection.HTTP_NOT_FOUND) { throw new IllegalStateException("Error launching test at " + url + ". " + "Got " + httpConnection.getResponseCode() + " (" + httpConnection.getResponseMessage() + ")"); } } finally { httpConnection.disconnect(); } return null; }
java
private <T> T execute(String url, Class<T> returnType, Object requestObject) throws Exception { URLConnection connection = new URL(url).openConnection(); if (!(connection instanceof HttpURLConnection)) { throw new IllegalStateException("Not an http connection! " + connection); } HttpURLConnection httpConnection = (HttpURLConnection) connection; httpConnection.setUseCaches(false); httpConnection.setDefaultUseCaches(false); httpConnection.setDoInput(true); /* * With followRedirects enabled, simple URL redirects work as expected. But with port redirects (http->https) * followRedirects doesn't work and a HTTP 302 code is returned instead (ARQ-1365). * * In order to handle all redirects in one place, followRedirects is set to false and all HTTP 302 response codes are * treated accordingly within the execute method. */ httpConnection.setInstanceFollowRedirects(false); try { if (requestObject != null) { httpConnection.setRequestMethod("POST"); httpConnection.setDoOutput(true); httpConnection.setRequestProperty("Content-Type", "application/octet-stream"); } if (requestObject != null) { ObjectOutputStream ous = new ObjectOutputStream(httpConnection.getOutputStream()); try { ous.writeObject(requestObject); } catch (Exception e) { throw new RuntimeException("Error sending request Object, " + requestObject, e); } finally { ous.flush(); ous.close(); } } try { httpConnection.getResponseCode(); } catch (ConnectException e) { return null; // Could not connect } if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK) { ObjectInputStream ois = new ObjectInputStream(httpConnection.getInputStream()); Object o; try { o = ois.readObject(); } finally { ois.close(); } if (!returnType.isInstance(o)) { throw new IllegalStateException( "Error reading results, expected a " + returnType.getName() + " but got " + o); } return returnType.cast(o); } else if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_NO_CONTENT) { return null; } else if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_MOVED_TEMP) { String redirectUrl = httpConnection.getHeaderField("Location"); return execute(redirectUrl, returnType, requestObject); } else if (httpConnection.getResponseCode() != HttpURLConnection.HTTP_NOT_FOUND) { throw new IllegalStateException("Error launching test at " + url + ". " + "Got " + httpConnection.getResponseCode() + " (" + httpConnection.getResponseMessage() + ")"); } } finally { httpConnection.disconnect(); } return null; }
[ "private", "<", "T", ">", "T", "execute", "(", "String", "url", ",", "Class", "<", "T", ">", "returnType", ",", "Object", "requestObject", ")", "throws", "Exception", "{", "URLConnection", "connection", "=", "new", "URL", "(", "url", ")", ".", "openConnection", "(", ")", ";", "if", "(", "!", "(", "connection", "instanceof", "HttpURLConnection", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Not an http connection! \"", "+", "connection", ")", ";", "}", "HttpURLConnection", "httpConnection", "=", "(", "HttpURLConnection", ")", "connection", ";", "httpConnection", ".", "setUseCaches", "(", "false", ")", ";", "httpConnection", ".", "setDefaultUseCaches", "(", "false", ")", ";", "httpConnection", ".", "setDoInput", "(", "true", ")", ";", "/*\n * With followRedirects enabled, simple URL redirects work as expected. But with port redirects (http->https)\n * followRedirects doesn't work and a HTTP 302 code is returned instead (ARQ-1365).\n *\n * In order to handle all redirects in one place, followRedirects is set to false and all HTTP 302 response codes are\n * treated accordingly within the execute method.\n */", "httpConnection", ".", "setInstanceFollowRedirects", "(", "false", ")", ";", "try", "{", "if", "(", "requestObject", "!=", "null", ")", "{", "httpConnection", ".", "setRequestMethod", "(", "\"POST\"", ")", ";", "httpConnection", ".", "setDoOutput", "(", "true", ")", ";", "httpConnection", ".", "setRequestProperty", "(", "\"Content-Type\"", ",", "\"application/octet-stream\"", ")", ";", "}", "if", "(", "requestObject", "!=", "null", ")", "{", "ObjectOutputStream", "ous", "=", "new", "ObjectOutputStream", "(", "httpConnection", ".", "getOutputStream", "(", ")", ")", ";", "try", "{", "ous", ".", "writeObject", "(", "requestObject", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error sending request Object, \"", "+", "requestObject", ",", "e", ")", ";", "}", "finally", "{", "ous", ".", "flush", "(", ")", ";", "ous", ".", "close", "(", ")", ";", "}", "}", "try", "{", "httpConnection", ".", "getResponseCode", "(", ")", ";", "}", "catch", "(", "ConnectException", "e", ")", "{", "return", "null", ";", "// Could not connect", "}", "if", "(", "httpConnection", ".", "getResponseCode", "(", ")", "==", "HttpURLConnection", ".", "HTTP_OK", ")", "{", "ObjectInputStream", "ois", "=", "new", "ObjectInputStream", "(", "httpConnection", ".", "getInputStream", "(", ")", ")", ";", "Object", "o", ";", "try", "{", "o", "=", "ois", ".", "readObject", "(", ")", ";", "}", "finally", "{", "ois", ".", "close", "(", ")", ";", "}", "if", "(", "!", "returnType", ".", "isInstance", "(", "o", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Error reading results, expected a \"", "+", "returnType", ".", "getName", "(", ")", "+", "\" but got \"", "+", "o", ")", ";", "}", "return", "returnType", ".", "cast", "(", "o", ")", ";", "}", "else", "if", "(", "httpConnection", ".", "getResponseCode", "(", ")", "==", "HttpURLConnection", ".", "HTTP_NO_CONTENT", ")", "{", "return", "null", ";", "}", "else", "if", "(", "httpConnection", ".", "getResponseCode", "(", ")", "==", "HttpURLConnection", ".", "HTTP_MOVED_TEMP", ")", "{", "String", "redirectUrl", "=", "httpConnection", ".", "getHeaderField", "(", "\"Location\"", ")", ";", "return", "execute", "(", "redirectUrl", ",", "returnType", ",", "requestObject", ")", ";", "}", "else", "if", "(", "httpConnection", ".", "getResponseCode", "(", ")", "!=", "HttpURLConnection", ".", "HTTP_NOT_FOUND", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Error launching test at \"", "+", "url", "+", "\". \"", "+", "\"Got \"", "+", "httpConnection", ".", "getResponseCode", "(", ")", "+", "\" (\"", "+", "httpConnection", ".", "getResponseMessage", "(", ")", "+", "\")\"", ")", ";", "}", "}", "finally", "{", "httpConnection", ".", "disconnect", "(", ")", ";", "}", "return", "null", ";", "}" ]
Executes the request to the remote url
[ "Executes", "the", "request", "to", "the", "remote", "url" ]
e958f4d782851baf7f40e39835d3d1ad185b74dd
https://github.com/arquillian/arquillian-extension-warp/blob/e958f4d782851baf7f40e39835d3d1ad185b74dd/impl/src/main/java/org/jboss/arquillian/warp/impl/client/commandBus/CommandBusOnClient.java#L196-L268
11,163
EXIficient/exificient-grammars
src/main/java/com/siemens/ct/exi/grammars/persistency/GrammarIdDispenser.java
GrammarIdDispenser.getEqualGrammar
private Grammar getEqualGrammar(Grammar gr) { for (Grammar gx : this.grammars) { if (gr == gx) { // System.out.println("Exactly the same grammar found: " + gx); return gx; } if (isSameGrammarType(gr, gx)) { // type of grammar the same if (gr.getNumberOfEvents() == gx.getNumberOfEvents()) { List<Grammar> handled = new ArrayList<Grammar>(); if (isEqualGrammar(gr, gx, handled)) { // the same grammar found // System.out.println("Same grammar found for: " + gx + // " == " + gr); return gx; } } } } return null; }
java
private Grammar getEqualGrammar(Grammar gr) { for (Grammar gx : this.grammars) { if (gr == gx) { // System.out.println("Exactly the same grammar found: " + gx); return gx; } if (isSameGrammarType(gr, gx)) { // type of grammar the same if (gr.getNumberOfEvents() == gx.getNumberOfEvents()) { List<Grammar> handled = new ArrayList<Grammar>(); if (isEqualGrammar(gr, gx, handled)) { // the same grammar found // System.out.println("Same grammar found for: " + gx + // " == " + gr); return gx; } } } } return null; }
[ "private", "Grammar", "getEqualGrammar", "(", "Grammar", "gr", ")", "{", "for", "(", "Grammar", "gx", ":", "this", ".", "grammars", ")", "{", "if", "(", "gr", "==", "gx", ")", "{", "// System.out.println(\"Exactly the same grammar found: \" + gx);", "return", "gx", ";", "}", "if", "(", "isSameGrammarType", "(", "gr", ",", "gx", ")", ")", "{", "// type of grammar the same", "if", "(", "gr", ".", "getNumberOfEvents", "(", ")", "==", "gx", ".", "getNumberOfEvents", "(", ")", ")", "{", "List", "<", "Grammar", ">", "handled", "=", "new", "ArrayList", "<", "Grammar", ">", "(", ")", ";", "if", "(", "isEqualGrammar", "(", "gr", ",", "gx", ",", "handled", ")", ")", "{", "// the same grammar found", "// System.out.println(\"Same grammar found for: \" + gx +", "// \" == \" + gr);", "return", "gx", ";", "}", "}", "}", "}", "return", "null", ";", "}" ]
!= null ... found equal grammar
[ "!", "=", "null", "...", "found", "equal", "grammar" ]
d96477062ebdd4245920e44cc1995259699fc7fb
https://github.com/EXIficient/exificient-grammars/blob/d96477062ebdd4245920e44cc1995259699fc7fb/src/main/java/com/siemens/ct/exi/grammars/persistency/GrammarIdDispenser.java#L91-L116
11,164
EXIficient/exificient-grammars
src/main/java/com/siemens/ct/exi/grammars/regex/RegularExpression.java
RegularExpression.compile
private synchronized void compile(Token tok) { if (this.operations != null) return; this.numberOfClosures = 0; this.operations = this.compile(tok, null, false); }
java
private synchronized void compile(Token tok) { if (this.operations != null) return; this.numberOfClosures = 0; this.operations = this.compile(tok, null, false); }
[ "private", "synchronized", "void", "compile", "(", "Token", "tok", ")", "{", "if", "(", "this", ".", "operations", "!=", "null", ")", "return", ";", "this", ".", "numberOfClosures", "=", "0", ";", "this", ".", "operations", "=", "this", ".", "compile", "(", "tok", ",", "null", ",", "false", ")", ";", "}" ]
Compiles a token tree into an operation flow.
[ "Compiles", "a", "token", "tree", "into", "an", "operation", "flow", "." ]
d96477062ebdd4245920e44cc1995259699fc7fb
https://github.com/EXIficient/exificient-grammars/blob/d96477062ebdd4245920e44cc1995259699fc7fb/src/main/java/com/siemens/ct/exi/grammars/regex/RegularExpression.java#L590-L595
11,165
EXIficient/exificient-grammars
src/main/java/com/siemens/ct/exi/grammars/XSDGrammarsBuilder.java
XSDGrammarsBuilder.translateSimpleTypeDefinitionToFSA
protected SchemaInformedFirstStartTagGrammar translateSimpleTypeDefinitionToFSA( XSSimpleTypeDefinition std) throws EXIException { /* * Simple content */ // QName valueType = this.getValueType(std); Characters chSchemaValid = new Characters(getDatatype(std)); // valueType, SchemaInformedGrammar simpleContentEnd = SIMPLE_END_ELEMENT_RULE; SchemaInformedElement simpleContent = new SchemaInformedElement(); simpleContent.addProduction(chSchemaValid, simpleContentEnd); // Type i SchemaInformedFirstStartTagGrammar type_i = new SchemaInformedFirstStartTag( handleAttributes(simpleContent, simpleContent, null, null)); type_i.setTypeEmpty(SIMPLE_END_ELEMENT_EMPTY_RULE); return type_i; }
java
protected SchemaInformedFirstStartTagGrammar translateSimpleTypeDefinitionToFSA( XSSimpleTypeDefinition std) throws EXIException { /* * Simple content */ // QName valueType = this.getValueType(std); Characters chSchemaValid = new Characters(getDatatype(std)); // valueType, SchemaInformedGrammar simpleContentEnd = SIMPLE_END_ELEMENT_RULE; SchemaInformedElement simpleContent = new SchemaInformedElement(); simpleContent.addProduction(chSchemaValid, simpleContentEnd); // Type i SchemaInformedFirstStartTagGrammar type_i = new SchemaInformedFirstStartTag( handleAttributes(simpleContent, simpleContent, null, null)); type_i.setTypeEmpty(SIMPLE_END_ELEMENT_EMPTY_RULE); return type_i; }
[ "protected", "SchemaInformedFirstStartTagGrammar", "translateSimpleTypeDefinitionToFSA", "(", "XSSimpleTypeDefinition", "std", ")", "throws", "EXIException", "{", "/*\r\n\t\t * Simple content\r\n\t\t */", "// QName valueType = this.getValueType(std);\r", "Characters", "chSchemaValid", "=", "new", "Characters", "(", "getDatatype", "(", "std", ")", ")", ";", "// valueType,\r", "SchemaInformedGrammar", "simpleContentEnd", "=", "SIMPLE_END_ELEMENT_RULE", ";", "SchemaInformedElement", "simpleContent", "=", "new", "SchemaInformedElement", "(", ")", ";", "simpleContent", ".", "addProduction", "(", "chSchemaValid", ",", "simpleContentEnd", ")", ";", "// Type i\r", "SchemaInformedFirstStartTagGrammar", "type_i", "=", "new", "SchemaInformedFirstStartTag", "(", "handleAttributes", "(", "simpleContent", ",", "simpleContent", ",", "null", ",", "null", ")", ")", ";", "type_i", ".", "setTypeEmpty", "(", "SIMPLE_END_ELEMENT_EMPTY_RULE", ")", ";", "return", "type_i", ";", "}" ]
protected SchemaInformedElement translateSimpleTypeDefinitionToFSA(
[ "protected", "SchemaInformedElement", "translateSimpleTypeDefinitionToFSA", "(" ]
d96477062ebdd4245920e44cc1995259699fc7fb
https://github.com/EXIficient/exificient-grammars/blob/d96477062ebdd4245920e44cc1995259699fc7fb/src/main/java/com/siemens/ct/exi/grammars/XSDGrammarsBuilder.java#L1753-L1774
11,166
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/vorbis/sampled/DecodedVorbisAudioInputStream.java
DecodedVorbisAudioInputStream.init_jorbis
private void init_jorbis() { oggSyncState_ = new SyncState(); oggStreamState_ = new StreamState(); oggPage_ = new Page(); oggPacket_ = new Packet(); vorbisInfo = new Info(); vorbisComment = new Comment(); vorbisDspState = new DspState(); vorbisBlock = new Block(vorbisDspState); buffer = null; bytes = 0; currentBytes = 0L; oggSyncState_.init(); }
java
private void init_jorbis() { oggSyncState_ = new SyncState(); oggStreamState_ = new StreamState(); oggPage_ = new Page(); oggPacket_ = new Packet(); vorbisInfo = new Info(); vorbisComment = new Comment(); vorbisDspState = new DspState(); vorbisBlock = new Block(vorbisDspState); buffer = null; bytes = 0; currentBytes = 0L; oggSyncState_.init(); }
[ "private", "void", "init_jorbis", "(", ")", "{", "oggSyncState_", "=", "new", "SyncState", "(", ")", ";", "oggStreamState_", "=", "new", "StreamState", "(", ")", ";", "oggPage_", "=", "new", "Page", "(", ")", ";", "oggPacket_", "=", "new", "Packet", "(", ")", ";", "vorbisInfo", "=", "new", "Info", "(", ")", ";", "vorbisComment", "=", "new", "Comment", "(", ")", ";", "vorbisDspState", "=", "new", "DspState", "(", ")", ";", "vorbisBlock", "=", "new", "Block", "(", "vorbisDspState", ")", ";", "buffer", "=", "null", ";", "bytes", "=", "0", ";", "currentBytes", "=", "0L", ";", "oggSyncState_", ".", "init", "(", ")", ";", "}" ]
Initializes all the jOrbis and jOgg vars that are used for song playback.
[ "Initializes", "all", "the", "jOrbis", "and", "jOgg", "vars", "that", "are", "used", "for", "song", "playback", "." ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/sampled/DecodedVorbisAudioInputStream.java#L96-L109
11,167
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/vorbis/sampled/DecodedVorbisAudioInputStream.java
DecodedVorbisAudioInputStream.outputSamples
private void outputSamples() { int samples; while ((samples = vorbisDspState.synthesis_pcmout(_pcmf, _index)) > 0) { float[][] pcmf = _pcmf[0]; bout = (samples < convsize ? samples : convsize); // convert doubles to 16 bit signed ints (host order) and // interleave for (i = 0; i < vorbisInfo.channels; i++) { int pointer = i * 2; //int ptr=i; int mono = _index[i]; for (int j = 0; j < bout; j++) { double fVal = pcmf[i][mono + j] * 32767.; int val = (int) (fVal); if (val > 32767) { val = 32767; } if (val < -32768) { val = -32768; } if (val < 0) { val = val | 0x8000; } convbuffer[pointer] = (byte) (val); convbuffer[pointer + 1] = (byte) (val >>> 8); pointer += 2 * (vorbisInfo.channels); } } LOG.log(Level.FINE, "about to write: {0}", 2 * vorbisInfo.channels * bout); if (getCircularBuffer().availableWrite() < 2 * vorbisInfo.channels * bout) { LOG.log(Level.FINE, "Too much data in this data packet, better return, let the channel drain, and try again..."); playState = playState_BufferFull; return; } getCircularBuffer().write(convbuffer, 0, 2 * vorbisInfo.channels * bout); if (bytes < bufferSize_) { LOG.log(Level.FINE, "Finished with final buffer of music?"); } if (vorbisDspState.synthesis_read(bout) != 0) { LOG.log(Level.FINE, "VorbisDspState.synthesis_read returned -1."); } } // while(samples...) playState = playState_ReadData; }
java
private void outputSamples() { int samples; while ((samples = vorbisDspState.synthesis_pcmout(_pcmf, _index)) > 0) { float[][] pcmf = _pcmf[0]; bout = (samples < convsize ? samples : convsize); // convert doubles to 16 bit signed ints (host order) and // interleave for (i = 0; i < vorbisInfo.channels; i++) { int pointer = i * 2; //int ptr=i; int mono = _index[i]; for (int j = 0; j < bout; j++) { double fVal = pcmf[i][mono + j] * 32767.; int val = (int) (fVal); if (val > 32767) { val = 32767; } if (val < -32768) { val = -32768; } if (val < 0) { val = val | 0x8000; } convbuffer[pointer] = (byte) (val); convbuffer[pointer + 1] = (byte) (val >>> 8); pointer += 2 * (vorbisInfo.channels); } } LOG.log(Level.FINE, "about to write: {0}", 2 * vorbisInfo.channels * bout); if (getCircularBuffer().availableWrite() < 2 * vorbisInfo.channels * bout) { LOG.log(Level.FINE, "Too much data in this data packet, better return, let the channel drain, and try again..."); playState = playState_BufferFull; return; } getCircularBuffer().write(convbuffer, 0, 2 * vorbisInfo.channels * bout); if (bytes < bufferSize_) { LOG.log(Level.FINE, "Finished with final buffer of music?"); } if (vorbisDspState.synthesis_read(bout) != 0) { LOG.log(Level.FINE, "VorbisDspState.synthesis_read returned -1."); } } // while(samples...) playState = playState_ReadData; }
[ "private", "void", "outputSamples", "(", ")", "{", "int", "samples", ";", "while", "(", "(", "samples", "=", "vorbisDspState", ".", "synthesis_pcmout", "(", "_pcmf", ",", "_index", ")", ")", ">", "0", ")", "{", "float", "[", "]", "[", "]", "pcmf", "=", "_pcmf", "[", "0", "]", ";", "bout", "=", "(", "samples", "<", "convsize", "?", "samples", ":", "convsize", ")", ";", "// convert doubles to 16 bit signed ints (host order) and", "// interleave", "for", "(", "i", "=", "0", ";", "i", "<", "vorbisInfo", ".", "channels", ";", "i", "++", ")", "{", "int", "pointer", "=", "i", "*", "2", ";", "//int ptr=i;", "int", "mono", "=", "_index", "[", "i", "]", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "bout", ";", "j", "++", ")", "{", "double", "fVal", "=", "pcmf", "[", "i", "]", "[", "mono", "+", "j", "]", "*", "32767.", ";", "int", "val", "=", "(", "int", ")", "(", "fVal", ")", ";", "if", "(", "val", ">", "32767", ")", "{", "val", "=", "32767", ";", "}", "if", "(", "val", "<", "-", "32768", ")", "{", "val", "=", "-", "32768", ";", "}", "if", "(", "val", "<", "0", ")", "{", "val", "=", "val", "|", "0x8000", ";", "}", "convbuffer", "[", "pointer", "]", "=", "(", "byte", ")", "(", "val", ")", ";", "convbuffer", "[", "pointer", "+", "1", "]", "=", "(", "byte", ")", "(", "val", ">>>", "8", ")", ";", "pointer", "+=", "2", "*", "(", "vorbisInfo", ".", "channels", ")", ";", "}", "}", "LOG", ".", "log", "(", "Level", ".", "FINE", ",", "\"about to write: {0}\"", ",", "2", "*", "vorbisInfo", ".", "channels", "*", "bout", ")", ";", "if", "(", "getCircularBuffer", "(", ")", ".", "availableWrite", "(", ")", "<", "2", "*", "vorbisInfo", ".", "channels", "*", "bout", ")", "{", "LOG", ".", "log", "(", "Level", ".", "FINE", ",", "\"Too much data in this data packet, better return, let the channel drain, and try again...\"", ")", ";", "playState", "=", "playState_BufferFull", ";", "return", ";", "}", "getCircularBuffer", "(", ")", ".", "write", "(", "convbuffer", ",", "0", ",", "2", "*", "vorbisInfo", ".", "channels", "*", "bout", ")", ";", "if", "(", "bytes", "<", "bufferSize_", ")", "{", "LOG", ".", "log", "(", "Level", ".", "FINE", ",", "\"Finished with final buffer of music?\"", ")", ";", "}", "if", "(", "vorbisDspState", ".", "synthesis_read", "(", "bout", ")", "!=", "0", ")", "{", "LOG", ".", "log", "(", "Level", ".", "FINE", ",", "\"VorbisDspState.synthesis_read returned -1.\"", ")", ";", "}", "}", "// while(samples...)", "playState", "=", "playState_ReadData", ";", "}" ]
This routine was extracted so that when the output buffer fills up, we can break out of the loop, let the music channel drain, then continue from where we were.
[ "This", "routine", "was", "extracted", "so", "that", "when", "the", "output", "buffer", "fills", "up", "we", "can", "break", "out", "of", "the", "loop", "let", "the", "music", "channel", "drain", "then", "continue", "from", "where", "we", "were", "." ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/sampled/DecodedVorbisAudioInputStream.java#L265-L308
11,168
EXIficient/exificient-grammars
src/main/java/com/siemens/ct/exi/grammars/regex/Match.java
Match.getBeginning
public int getBeginning(int index) { if (this.beginpos == null) throw new IllegalStateException("A result is not set."); if (index < 0 || this.nofgroups <= index) throw new IllegalArgumentException( "The parameter must be less than " + this.nofgroups + ": " + index); return this.beginpos[index]; }
java
public int getBeginning(int index) { if (this.beginpos == null) throw new IllegalStateException("A result is not set."); if (index < 0 || this.nofgroups <= index) throw new IllegalArgumentException( "The parameter must be less than " + this.nofgroups + ": " + index); return this.beginpos[index]; }
[ "public", "int", "getBeginning", "(", "int", "index", ")", "{", "if", "(", "this", ".", "beginpos", "==", "null", ")", "throw", "new", "IllegalStateException", "(", "\"A result is not set.\"", ")", ";", "if", "(", "index", "<", "0", "||", "this", ".", "nofgroups", "<=", "index", ")", "throw", "new", "IllegalArgumentException", "(", "\"The parameter must be less than \"", "+", "this", ".", "nofgroups", "+", "\": \"", "+", "index", ")", ";", "return", "this", ".", "beginpos", "[", "index", "]", ";", "}" ]
Return a start position in the target text matched to specified regular expression group. @param index Less than <code>getNumberOfGroups()</code>.
[ "Return", "a", "start", "position", "in", "the", "target", "text", "matched", "to", "specified", "regular", "expression", "group", "." ]
d96477062ebdd4245920e44cc1995259699fc7fb
https://github.com/EXIficient/exificient-grammars/blob/d96477062ebdd4245920e44cc1995259699fc7fb/src/main/java/com/siemens/ct/exi/grammars/regex/Match.java#L145-L153
11,169
EXIficient/exificient-grammars
src/main/java/com/siemens/ct/exi/grammars/regex/Match.java
Match.getEnd
public int getEnd(int index) { if (this.endpos == null) throw new IllegalStateException("A result is not set."); if (index < 0 || this.nofgroups <= index) throw new IllegalArgumentException( "The parameter must be less than " + this.nofgroups + ": " + index); return this.endpos[index]; }
java
public int getEnd(int index) { if (this.endpos == null) throw new IllegalStateException("A result is not set."); if (index < 0 || this.nofgroups <= index) throw new IllegalArgumentException( "The parameter must be less than " + this.nofgroups + ": " + index); return this.endpos[index]; }
[ "public", "int", "getEnd", "(", "int", "index", ")", "{", "if", "(", "this", ".", "endpos", "==", "null", ")", "throw", "new", "IllegalStateException", "(", "\"A result is not set.\"", ")", ";", "if", "(", "index", "<", "0", "||", "this", ".", "nofgroups", "<=", "index", ")", "throw", "new", "IllegalArgumentException", "(", "\"The parameter must be less than \"", "+", "this", ".", "nofgroups", "+", "\": \"", "+", "index", ")", ";", "return", "this", ".", "endpos", "[", "index", "]", ";", "}" ]
Return an end position in the target text matched to specified regular expression group. @param index Less than <code>getNumberOfGroups()</code>.
[ "Return", "an", "end", "position", "in", "the", "target", "text", "matched", "to", "specified", "regular", "expression", "group", "." ]
d96477062ebdd4245920e44cc1995259699fc7fb
https://github.com/EXIficient/exificient-grammars/blob/d96477062ebdd4245920e44cc1995259699fc7fb/src/main/java/com/siemens/ct/exi/grammars/regex/Match.java#L162-L170
11,170
EXIficient/exificient-grammars
src/main/java/com/siemens/ct/exi/grammars/regex/Match.java
Match.getCapturedText
public String getCapturedText(int index) { if (this.beginpos == null) throw new IllegalStateException("match() has never been called."); if (index < 0 || this.nofgroups <= index) throw new IllegalArgumentException( "The parameter must be less than " + this.nofgroups + ": " + index); String ret; int begin = this.beginpos[index], end = this.endpos[index]; if (begin < 0 || end < 0) return null; if (this.ciSource != null) { ret = REUtil.substring(this.ciSource, begin, end); } else if (this.strSource != null) { ret = this.strSource.substring(begin, end); } else { ret = new String(this.charSource, begin, end - begin); } return ret; }
java
public String getCapturedText(int index) { if (this.beginpos == null) throw new IllegalStateException("match() has never been called."); if (index < 0 || this.nofgroups <= index) throw new IllegalArgumentException( "The parameter must be less than " + this.nofgroups + ": " + index); String ret; int begin = this.beginpos[index], end = this.endpos[index]; if (begin < 0 || end < 0) return null; if (this.ciSource != null) { ret = REUtil.substring(this.ciSource, begin, end); } else if (this.strSource != null) { ret = this.strSource.substring(begin, end); } else { ret = new String(this.charSource, begin, end - begin); } return ret; }
[ "public", "String", "getCapturedText", "(", "int", "index", ")", "{", "if", "(", "this", ".", "beginpos", "==", "null", ")", "throw", "new", "IllegalStateException", "(", "\"match() has never been called.\"", ")", ";", "if", "(", "index", "<", "0", "||", "this", ".", "nofgroups", "<=", "index", ")", "throw", "new", "IllegalArgumentException", "(", "\"The parameter must be less than \"", "+", "this", ".", "nofgroups", "+", "\": \"", "+", "index", ")", ";", "String", "ret", ";", "int", "begin", "=", "this", ".", "beginpos", "[", "index", "]", ",", "end", "=", "this", ".", "endpos", "[", "index", "]", ";", "if", "(", "begin", "<", "0", "||", "end", "<", "0", ")", "return", "null", ";", "if", "(", "this", ".", "ciSource", "!=", "null", ")", "{", "ret", "=", "REUtil", ".", "substring", "(", "this", ".", "ciSource", ",", "begin", ",", "end", ")", ";", "}", "else", "if", "(", "this", ".", "strSource", "!=", "null", ")", "{", "ret", "=", "this", ".", "strSource", ".", "substring", "(", "begin", ",", "end", ")", ";", "}", "else", "{", "ret", "=", "new", "String", "(", "this", ".", "charSource", ",", "begin", ",", "end", "-", "begin", ")", ";", "}", "return", "ret", ";", "}" ]
Return an substring of the target text matched to specified regular expression group. @param index Less than <code>getNumberOfGroups()</code>.
[ "Return", "an", "substring", "of", "the", "target", "text", "matched", "to", "specified", "regular", "expression", "group", "." ]
d96477062ebdd4245920e44cc1995259699fc7fb
https://github.com/EXIficient/exificient-grammars/blob/d96477062ebdd4245920e44cc1995259699fc7fb/src/main/java/com/siemens/ct/exi/grammars/regex/Match.java#L179-L198
11,171
EXIficient/exificient-grammars
src/main/java/com/siemens/ct/exi/grammars/regex/RangeToken.java
RangeToken.addRange
protected void addRange(int start, int end) { this.icaseCache = null; // System.err.println("Token#addRange(): "+start+" "+end); int r1, r2; if (start <= end) { r1 = start; r2 = end; } else { r1 = end; r2 = start; } int pos = 0; if (this.ranges == null) { this.ranges = new int[2]; this.ranges[0] = r1; this.ranges[1] = r2; this.setSorted(true); } else { pos = this.ranges.length; if (this.ranges[pos - 1] + 1 == r1) { this.ranges[pos - 1] = r2; return; } int[] temp = new int[pos + 2]; System.arraycopy(this.ranges, 0, temp, 0, pos); this.ranges = temp; if (this.ranges[pos - 1] >= r1) this.setSorted(false); this.ranges[pos++] = r1; this.ranges[pos] = r2; if (!this.sorted) this.sortRanges(); } }
java
protected void addRange(int start, int end) { this.icaseCache = null; // System.err.println("Token#addRange(): "+start+" "+end); int r1, r2; if (start <= end) { r1 = start; r2 = end; } else { r1 = end; r2 = start; } int pos = 0; if (this.ranges == null) { this.ranges = new int[2]; this.ranges[0] = r1; this.ranges[1] = r2; this.setSorted(true); } else { pos = this.ranges.length; if (this.ranges[pos - 1] + 1 == r1) { this.ranges[pos - 1] = r2; return; } int[] temp = new int[pos + 2]; System.arraycopy(this.ranges, 0, temp, 0, pos); this.ranges = temp; if (this.ranges[pos - 1] >= r1) this.setSorted(false); this.ranges[pos++] = r1; this.ranges[pos] = r2; if (!this.sorted) this.sortRanges(); } }
[ "protected", "void", "addRange", "(", "int", "start", ",", "int", "end", ")", "{", "this", ".", "icaseCache", "=", "null", ";", "// System.err.println(\"Token#addRange(): \"+start+\" \"+end);\r", "int", "r1", ",", "r2", ";", "if", "(", "start", "<=", "end", ")", "{", "r1", "=", "start", ";", "r2", "=", "end", ";", "}", "else", "{", "r1", "=", "end", ";", "r2", "=", "start", ";", "}", "int", "pos", "=", "0", ";", "if", "(", "this", ".", "ranges", "==", "null", ")", "{", "this", ".", "ranges", "=", "new", "int", "[", "2", "]", ";", "this", ".", "ranges", "[", "0", "]", "=", "r1", ";", "this", ".", "ranges", "[", "1", "]", "=", "r2", ";", "this", ".", "setSorted", "(", "true", ")", ";", "}", "else", "{", "pos", "=", "this", ".", "ranges", ".", "length", ";", "if", "(", "this", ".", "ranges", "[", "pos", "-", "1", "]", "+", "1", "==", "r1", ")", "{", "this", ".", "ranges", "[", "pos", "-", "1", "]", "=", "r2", ";", "return", ";", "}", "int", "[", "]", "temp", "=", "new", "int", "[", "pos", "+", "2", "]", ";", "System", ".", "arraycopy", "(", "this", ".", "ranges", ",", "0", ",", "temp", ",", "0", ",", "pos", ")", ";", "this", ".", "ranges", "=", "temp", ";", "if", "(", "this", ".", "ranges", "[", "pos", "-", "1", "]", ">=", "r1", ")", "this", ".", "setSorted", "(", "false", ")", ";", "this", ".", "ranges", "[", "pos", "++", "]", "=", "r1", ";", "this", ".", "ranges", "[", "pos", "]", "=", "r2", ";", "if", "(", "!", "this", ".", "sorted", ")", "this", ".", "sortRanges", "(", ")", ";", "}", "}" ]
for RANGE or NRANGE
[ "for", "RANGE", "or", "NRANGE" ]
d96477062ebdd4245920e44cc1995259699fc7fb
https://github.com/EXIficient/exificient-grammars/blob/d96477062ebdd4245920e44cc1995259699fc7fb/src/main/java/com/siemens/ct/exi/grammars/regex/RangeToken.java#L46-L80
11,172
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisAudioFileReader.java
VorbisAudioFileReader.getAudioFileFormat
@Override public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException { LOG.log(Level.FINE, "getAudioFileFormat(File file)"); try (InputStream inputStream = new BufferedInputStream(new FileInputStream(file))) { inputStream.mark(MARK_LIMIT); getAudioFileFormat(inputStream); inputStream.reset(); // Get Vorbis file info such as length in seconds. VorbisFile vf = new VorbisFile(file.getAbsolutePath()); return getAudioFileFormat(inputStream, (int) file.length(), (int) Math.round(vf.time_total(-1) * 1000)); } catch (SoundException e) { throw new IOException(e.getMessage()); } }
java
@Override public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException { LOG.log(Level.FINE, "getAudioFileFormat(File file)"); try (InputStream inputStream = new BufferedInputStream(new FileInputStream(file))) { inputStream.mark(MARK_LIMIT); getAudioFileFormat(inputStream); inputStream.reset(); // Get Vorbis file info such as length in seconds. VorbisFile vf = new VorbisFile(file.getAbsolutePath()); return getAudioFileFormat(inputStream, (int) file.length(), (int) Math.round(vf.time_total(-1) * 1000)); } catch (SoundException e) { throw new IOException(e.getMessage()); } }
[ "@", "Override", "public", "AudioFileFormat", "getAudioFileFormat", "(", "File", "file", ")", "throws", "UnsupportedAudioFileException", ",", "IOException", "{", "LOG", ".", "log", "(", "Level", ".", "FINE", ",", "\"getAudioFileFormat(File file)\"", ")", ";", "try", "(", "InputStream", "inputStream", "=", "new", "BufferedInputStream", "(", "new", "FileInputStream", "(", "file", ")", ")", ")", "{", "inputStream", ".", "mark", "(", "MARK_LIMIT", ")", ";", "getAudioFileFormat", "(", "inputStream", ")", ";", "inputStream", ".", "reset", "(", ")", ";", "// Get Vorbis file info such as length in seconds.", "VorbisFile", "vf", "=", "new", "VorbisFile", "(", "file", ".", "getAbsolutePath", "(", ")", ")", ";", "return", "getAudioFileFormat", "(", "inputStream", ",", "(", "int", ")", "file", ".", "length", "(", ")", ",", "(", "int", ")", "Math", ".", "round", "(", "vf", ".", "time_total", "(", "-", "1", ")", "*", "1000", ")", ")", ";", "}", "catch", "(", "SoundException", "e", ")", "{", "throw", "new", "IOException", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}" ]
Return the AudioFileFormat from the given file. @return @throws javax.sound.sampled.UnsupportedAudioFileException @throws java.io.IOException
[ "Return", "the", "AudioFileFormat", "from", "the", "given", "file", "." ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisAudioFileReader.java#L96-L109
11,173
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisAudioFileReader.java
VorbisAudioFileReader.getAudioFileFormat
@Override public AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException { LOG.log(Level.FINE, "getAudioFileFormat(URL url)"); InputStream inputStream = url.openStream(); try { return getAudioFileFormat(inputStream); } finally { if (inputStream != null) { inputStream.close(); } } }
java
@Override public AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException { LOG.log(Level.FINE, "getAudioFileFormat(URL url)"); InputStream inputStream = url.openStream(); try { return getAudioFileFormat(inputStream); } finally { if (inputStream != null) { inputStream.close(); } } }
[ "@", "Override", "public", "AudioFileFormat", "getAudioFileFormat", "(", "URL", "url", ")", "throws", "UnsupportedAudioFileException", ",", "IOException", "{", "LOG", ".", "log", "(", "Level", ".", "FINE", ",", "\"getAudioFileFormat(URL url)\"", ")", ";", "InputStream", "inputStream", "=", "url", ".", "openStream", "(", ")", ";", "try", "{", "return", "getAudioFileFormat", "(", "inputStream", ")", ";", "}", "finally", "{", "if", "(", "inputStream", "!=", "null", ")", "{", "inputStream", ".", "close", "(", ")", ";", "}", "}", "}" ]
Return the AudioFileFormat from the given URL. @return @throws javax.sound.sampled.UnsupportedAudioFileException @throws java.io.IOException
[ "Return", "the", "AudioFileFormat", "from", "the", "given", "URL", "." ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisAudioFileReader.java#L118-L129
11,174
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisAudioFileReader.java
VorbisAudioFileReader.getAudioFileFormat
@Override public AudioFileFormat getAudioFileFormat(InputStream inputStream) throws UnsupportedAudioFileException, IOException { LOG.log(Level.FINE, "getAudioFileFormat(InputStream inputStream)"); try { if (!inputStream.markSupported()) { inputStream = new BufferedInputStream(inputStream); } inputStream.mark(MARK_LIMIT); return getAudioFileFormat(inputStream, AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED); } finally { inputStream.reset(); } }
java
@Override public AudioFileFormat getAudioFileFormat(InputStream inputStream) throws UnsupportedAudioFileException, IOException { LOG.log(Level.FINE, "getAudioFileFormat(InputStream inputStream)"); try { if (!inputStream.markSupported()) { inputStream = new BufferedInputStream(inputStream); } inputStream.mark(MARK_LIMIT); return getAudioFileFormat(inputStream, AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED); } finally { inputStream.reset(); } }
[ "@", "Override", "public", "AudioFileFormat", "getAudioFileFormat", "(", "InputStream", "inputStream", ")", "throws", "UnsupportedAudioFileException", ",", "IOException", "{", "LOG", ".", "log", "(", "Level", ".", "FINE", ",", "\"getAudioFileFormat(InputStream inputStream)\"", ")", ";", "try", "{", "if", "(", "!", "inputStream", ".", "markSupported", "(", ")", ")", "{", "inputStream", "=", "new", "BufferedInputStream", "(", "inputStream", ")", ";", "}", "inputStream", ".", "mark", "(", "MARK_LIMIT", ")", ";", "return", "getAudioFileFormat", "(", "inputStream", ",", "AudioSystem", ".", "NOT_SPECIFIED", ",", "AudioSystem", ".", "NOT_SPECIFIED", ")", ";", "}", "finally", "{", "inputStream", ".", "reset", "(", ")", ";", "}", "}" ]
Return the AudioFileFormat from the given InputStream. @return @throws javax.sound.sampled.UnsupportedAudioFileException @throws java.io.IOException
[ "Return", "the", "AudioFileFormat", "from", "the", "given", "InputStream", "." ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisAudioFileReader.java#L138-L150
11,175
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisAudioFileReader.java
VorbisAudioFileReader.getAudioFileFormat
@Override public AudioFileFormat getAudioFileFormat(InputStream inputStream, long medialength) throws UnsupportedAudioFileException, IOException { return getAudioFileFormat(inputStream, (int) medialength, AudioSystem.NOT_SPECIFIED); }
java
@Override public AudioFileFormat getAudioFileFormat(InputStream inputStream, long medialength) throws UnsupportedAudioFileException, IOException { return getAudioFileFormat(inputStream, (int) medialength, AudioSystem.NOT_SPECIFIED); }
[ "@", "Override", "public", "AudioFileFormat", "getAudioFileFormat", "(", "InputStream", "inputStream", ",", "long", "medialength", ")", "throws", "UnsupportedAudioFileException", ",", "IOException", "{", "return", "getAudioFileFormat", "(", "inputStream", ",", "(", "int", ")", "medialength", ",", "AudioSystem", ".", "NOT_SPECIFIED", ")", ";", "}" ]
Return the AudioFileFormat from the given InputStream and length in bytes. @param medialength @return @throws javax.sound.sampled.UnsupportedAudioFileException @throws java.io.IOException
[ "Return", "the", "AudioFileFormat", "from", "the", "given", "InputStream", "and", "length", "in", "bytes", "." ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisAudioFileReader.java#L161-L164
11,176
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisAudioFileReader.java
VorbisAudioFileReader.getAudioInputStream
@Override public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException { LOG.log(Level.FINE, "getAudioInputStream(File file)"); InputStream inputStream = new FileInputStream(file); try { return getAudioInputStream(inputStream); } catch (UnsupportedAudioFileException | IOException e) { inputStream.close(); throw e; } }
java
@Override public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException { LOG.log(Level.FINE, "getAudioInputStream(File file)"); InputStream inputStream = new FileInputStream(file); try { return getAudioInputStream(inputStream); } catch (UnsupportedAudioFileException | IOException e) { inputStream.close(); throw e; } }
[ "@", "Override", "public", "AudioInputStream", "getAudioInputStream", "(", "File", "file", ")", "throws", "UnsupportedAudioFileException", ",", "IOException", "{", "LOG", ".", "log", "(", "Level", ".", "FINE", ",", "\"getAudioInputStream(File file)\"", ")", ";", "InputStream", "inputStream", "=", "new", "FileInputStream", "(", "file", ")", ";", "try", "{", "return", "getAudioInputStream", "(", "inputStream", ")", ";", "}", "catch", "(", "UnsupportedAudioFileException", "|", "IOException", "e", ")", "{", "inputStream", ".", "close", "(", ")", ";", "throw", "e", ";", "}", "}" ]
Return the AudioInputStream from the given File. @return @throws javax.sound.sampled.UnsupportedAudioFileException @throws java.io.IOException
[ "Return", "the", "AudioInputStream", "from", "the", "given", "File", "." ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisAudioFileReader.java#L313-L323
11,177
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisAudioFileReader.java
VorbisAudioFileReader.getAudioInputStream
@Override public AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException { LOG.log(Level.FINE, "getAudioInputStream(URL url)"); InputStream inputStream = url.openStream(); try { return getAudioInputStream(inputStream); } catch (UnsupportedAudioFileException | IOException e) { if (inputStream != null) { inputStream.close(); } throw e; } }
java
@Override public AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException { LOG.log(Level.FINE, "getAudioInputStream(URL url)"); InputStream inputStream = url.openStream(); try { return getAudioInputStream(inputStream); } catch (UnsupportedAudioFileException | IOException e) { if (inputStream != null) { inputStream.close(); } throw e; } }
[ "@", "Override", "public", "AudioInputStream", "getAudioInputStream", "(", "URL", "url", ")", "throws", "UnsupportedAudioFileException", ",", "IOException", "{", "LOG", ".", "log", "(", "Level", ".", "FINE", ",", "\"getAudioInputStream(URL url)\"", ")", ";", "InputStream", "inputStream", "=", "url", ".", "openStream", "(", ")", ";", "try", "{", "return", "getAudioInputStream", "(", "inputStream", ")", ";", "}", "catch", "(", "UnsupportedAudioFileException", "|", "IOException", "e", ")", "{", "if", "(", "inputStream", "!=", "null", ")", "{", "inputStream", ".", "close", "(", ")", ";", "}", "throw", "e", ";", "}", "}" ]
Return the AudioInputStream from the given URL. @return @throws javax.sound.sampled.UnsupportedAudioFileException @throws java.io.IOException
[ "Return", "the", "AudioInputStream", "from", "the", "given", "URL", "." ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisAudioFileReader.java#L332-L344
11,178
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/vorbis/jcraft/jorbis/VorbisFile.java
VorbisFile.decode_clear
void decode_clear() { os.clear(); vd.clear(); vb.clear(); decode_ready = false; bittrack = 0.f; samptrack = 0.f; }
java
void decode_clear() { os.clear(); vd.clear(); vb.clear(); decode_ready = false; bittrack = 0.f; samptrack = 0.f; }
[ "void", "decode_clear", "(", ")", "{", "os", ".", "clear", "(", ")", ";", "vd", ".", "clear", "(", ")", ";", "vb", ".", "clear", "(", ")", ";", "decode_ready", "=", "false", ";", "bittrack", "=", "0.f", ";", "samptrack", "=", "0.f", ";", "}" ]
clear out the current logical bitstream decoder
[ "clear", "out", "the", "current", "logical", "bitstream", "decoder" ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/jcraft/jorbis/VorbisFile.java#L469-L476
11,179
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/vorbis/jcraft/jorbis/VorbisFile.java
VorbisFile.process_packet
int process_packet(int readp) { Page og = new Page(); // handle one packet. Try to fetch it from current stream state // extract packets from page while (true) { // process a packet if we can. If the machine isn't loaded, // neither is a page if (decode_ready) { Packet op = new Packet(); int result = os.packetout(op); long granulepos; // if(result==-1)return(-1); // hole in the data. For now, swallow // and go. We'll need to add a real // error code in a bit. if (result > 0) { // got a packet. process it granulepos = op.granulepos; if (vb.synthesis(op) == 0) { // lazy check for lazy // header handling. The // header packets aren't // audio, so if/when we // submit them, // vorbis_synthesis will // reject them // suck in the synthesis data and track bitrate { int oldsamples = vd.synthesis_pcmout(null, null); vd.synthesis_blockin(vb); samptrack += vd.synthesis_pcmout(null, null) - oldsamples; bittrack += op.bytes * 8; } // update the pcm offset. if (granulepos != -1 && op.e_o_s == 0) { int link = (seekable ? current_link : 0); int samples; // this packet has a pcm_offset on it (the last packet // completed on a page carries the offset) After processing // (above), we know the pcm position of the *last* sample // ready to be returned. Find the offset of the *first* // // As an aside, this trick is inaccurate if we begin // reading anew right at the last page; the end-of-stream // granulepos declares the last frame in the stream, and the // last packet of the last page may be a partial frame. // So, we need a previous granulepos from an in-sequence page // to have a reference point. Thus the !op.e_o_s clause above samples = vd.synthesis_pcmout(null, null); granulepos -= samples; for (int i = 0; i < link; i++) { granulepos += pcmlengths[i]; } pcm_offset = granulepos; } return (1); } } } if (readp == 0) { return (0); } if (get_next_page(og, -1) < 0) { return (0); // eof. leave unitialized } // bitrate tracking; add the header's bytes here, the body bytes // are done by packet above bittrack += og.header_len * 8; // has our decoding just traversed a bitstream boundary? if (decode_ready) { if (current_serialno != og.serialno()) { decode_clear(); } } // Do we need to load a new machine before submitting the page? // This is different in the seekable and non-seekable cases. // // In the seekable case, we already have all the header // information loaded and cached; we just initialize the machine // with it and continue on our merry way. // // In the non-seekable (streaming) case, we'll only be at a // boundary if we just left the previous logical bitstream and // we're now nominally at the header of the next bitstream if (!decode_ready) { int i; if (seekable) { current_serialno = og.serialno(); // match the serialno to bitstream section. We use this rather than // offset positions to avoid problems near logical bitstream // boundaries for (i = 0; i < links; i++) { if (serialnos[i] == current_serialno) { break; } } if (i == links) { return (-1); // sign of a bogus stream. error out, } // leave machine uninitialized current_link = i; os.init(current_serialno); os.reset(); } else { // we're streaming // fetch the three header packets, build the info struct int foo[] = new int[1]; int ret = fetch_headers(vi[0], vc[0], foo, og); current_serialno = foo[0]; if (ret != 0) { return ret; } current_link++; i = 0; } make_decode_ready(); } os.pagein(og); } }
java
int process_packet(int readp) { Page og = new Page(); // handle one packet. Try to fetch it from current stream state // extract packets from page while (true) { // process a packet if we can. If the machine isn't loaded, // neither is a page if (decode_ready) { Packet op = new Packet(); int result = os.packetout(op); long granulepos; // if(result==-1)return(-1); // hole in the data. For now, swallow // and go. We'll need to add a real // error code in a bit. if (result > 0) { // got a packet. process it granulepos = op.granulepos; if (vb.synthesis(op) == 0) { // lazy check for lazy // header handling. The // header packets aren't // audio, so if/when we // submit them, // vorbis_synthesis will // reject them // suck in the synthesis data and track bitrate { int oldsamples = vd.synthesis_pcmout(null, null); vd.synthesis_blockin(vb); samptrack += vd.synthesis_pcmout(null, null) - oldsamples; bittrack += op.bytes * 8; } // update the pcm offset. if (granulepos != -1 && op.e_o_s == 0) { int link = (seekable ? current_link : 0); int samples; // this packet has a pcm_offset on it (the last packet // completed on a page carries the offset) After processing // (above), we know the pcm position of the *last* sample // ready to be returned. Find the offset of the *first* // // As an aside, this trick is inaccurate if we begin // reading anew right at the last page; the end-of-stream // granulepos declares the last frame in the stream, and the // last packet of the last page may be a partial frame. // So, we need a previous granulepos from an in-sequence page // to have a reference point. Thus the !op.e_o_s clause above samples = vd.synthesis_pcmout(null, null); granulepos -= samples; for (int i = 0; i < link; i++) { granulepos += pcmlengths[i]; } pcm_offset = granulepos; } return (1); } } } if (readp == 0) { return (0); } if (get_next_page(og, -1) < 0) { return (0); // eof. leave unitialized } // bitrate tracking; add the header's bytes here, the body bytes // are done by packet above bittrack += og.header_len * 8; // has our decoding just traversed a bitstream boundary? if (decode_ready) { if (current_serialno != og.serialno()) { decode_clear(); } } // Do we need to load a new machine before submitting the page? // This is different in the seekable and non-seekable cases. // // In the seekable case, we already have all the header // information loaded and cached; we just initialize the machine // with it and continue on our merry way. // // In the non-seekable (streaming) case, we'll only be at a // boundary if we just left the previous logical bitstream and // we're now nominally at the header of the next bitstream if (!decode_ready) { int i; if (seekable) { current_serialno = og.serialno(); // match the serialno to bitstream section. We use this rather than // offset positions to avoid problems near logical bitstream // boundaries for (i = 0; i < links; i++) { if (serialnos[i] == current_serialno) { break; } } if (i == links) { return (-1); // sign of a bogus stream. error out, } // leave machine uninitialized current_link = i; os.init(current_serialno); os.reset(); } else { // we're streaming // fetch the three header packets, build the info struct int foo[] = new int[1]; int ret = fetch_headers(vi[0], vc[0], foo, og); current_serialno = foo[0]; if (ret != 0) { return ret; } current_link++; i = 0; } make_decode_ready(); } os.pagein(og); } }
[ "int", "process_packet", "(", "int", "readp", ")", "{", "Page", "og", "=", "new", "Page", "(", ")", ";", "// handle one packet. Try to fetch it from current stream state", "// extract packets from page", "while", "(", "true", ")", "{", "// process a packet if we can. If the machine isn't loaded,", "// neither is a page", "if", "(", "decode_ready", ")", "{", "Packet", "op", "=", "new", "Packet", "(", ")", ";", "int", "result", "=", "os", ".", "packetout", "(", "op", ")", ";", "long", "granulepos", ";", "// if(result==-1)return(-1); // hole in the data. For now, swallow", "// and go. We'll need to add a real", "// error code in a bit.", "if", "(", "result", ">", "0", ")", "{", "// got a packet. process it", "granulepos", "=", "op", ".", "granulepos", ";", "if", "(", "vb", ".", "synthesis", "(", "op", ")", "==", "0", ")", "{", "// lazy check for lazy", "// header handling. The", "// header packets aren't", "// audio, so if/when we", "// submit them,", "// vorbis_synthesis will", "// reject them", "// suck in the synthesis data and track bitrate", "{", "int", "oldsamples", "=", "vd", ".", "synthesis_pcmout", "(", "null", ",", "null", ")", ";", "vd", ".", "synthesis_blockin", "(", "vb", ")", ";", "samptrack", "+=", "vd", ".", "synthesis_pcmout", "(", "null", ",", "null", ")", "-", "oldsamples", ";", "bittrack", "+=", "op", ".", "bytes", "*", "8", ";", "}", "// update the pcm offset.", "if", "(", "granulepos", "!=", "-", "1", "&&", "op", ".", "e_o_s", "==", "0", ")", "{", "int", "link", "=", "(", "seekable", "?", "current_link", ":", "0", ")", ";", "int", "samples", ";", "// this packet has a pcm_offset on it (the last packet", "// completed on a page carries the offset) After processing", "// (above), we know the pcm position of the *last* sample", "// ready to be returned. Find the offset of the *first*", "// ", "// As an aside, this trick is inaccurate if we begin", "// reading anew right at the last page; the end-of-stream", "// granulepos declares the last frame in the stream, and the", "// last packet of the last page may be a partial frame.", "// So, we need a previous granulepos from an in-sequence page", "// to have a reference point. Thus the !op.e_o_s clause above", "samples", "=", "vd", ".", "synthesis_pcmout", "(", "null", ",", "null", ")", ";", "granulepos", "-=", "samples", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "link", ";", "i", "++", ")", "{", "granulepos", "+=", "pcmlengths", "[", "i", "]", ";", "}", "pcm_offset", "=", "granulepos", ";", "}", "return", "(", "1", ")", ";", "}", "}", "}", "if", "(", "readp", "==", "0", ")", "{", "return", "(", "0", ")", ";", "}", "if", "(", "get_next_page", "(", "og", ",", "-", "1", ")", "<", "0", ")", "{", "return", "(", "0", ")", ";", "// eof. leave unitialized", "}", "// bitrate tracking; add the header's bytes here, the body bytes", "// are done by packet above", "bittrack", "+=", "og", ".", "header_len", "*", "8", ";", "// has our decoding just traversed a bitstream boundary?", "if", "(", "decode_ready", ")", "{", "if", "(", "current_serialno", "!=", "og", ".", "serialno", "(", ")", ")", "{", "decode_clear", "(", ")", ";", "}", "}", "// Do we need to load a new machine before submitting the page?", "// This is different in the seekable and non-seekable cases. ", "// ", "// In the seekable case, we already have all the header", "// information loaded and cached; we just initialize the machine", "// with it and continue on our merry way.", "// ", "// In the non-seekable (streaming) case, we'll only be at a", "// boundary if we just left the previous logical bitstream and", "// we're now nominally at the header of the next bitstream", "if", "(", "!", "decode_ready", ")", "{", "int", "i", ";", "if", "(", "seekable", ")", "{", "current_serialno", "=", "og", ".", "serialno", "(", ")", ";", "// match the serialno to bitstream section. We use this rather than", "// offset positions to avoid problems near logical bitstream", "// boundaries", "for", "(", "i", "=", "0", ";", "i", "<", "links", ";", "i", "++", ")", "{", "if", "(", "serialnos", "[", "i", "]", "==", "current_serialno", ")", "{", "break", ";", "}", "}", "if", "(", "i", "==", "links", ")", "{", "return", "(", "-", "1", ")", ";", "// sign of a bogus stream. error out,", "}", "// leave machine uninitialized", "current_link", "=", "i", ";", "os", ".", "init", "(", "current_serialno", ")", ";", "os", ".", "reset", "(", ")", ";", "}", "else", "{", "// we're streaming", "// fetch the three header packets, build the info struct", "int", "foo", "[", "]", "=", "new", "int", "[", "1", "]", ";", "int", "ret", "=", "fetch_headers", "(", "vi", "[", "0", "]", ",", "vc", "[", "0", "]", ",", "foo", ",", "og", ")", ";", "current_serialno", "=", "foo", "[", "0", "]", ";", "if", "(", "ret", "!=", "0", ")", "{", "return", "ret", ";", "}", "current_link", "++", ";", "i", "=", "0", ";", "}", "make_decode_ready", "(", ")", ";", "}", "os", ".", "pagein", "(", "og", ")", ";", "}", "}" ]
1) got a packet
[ "1", ")", "got", "a", "packet" ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/jcraft/jorbis/VorbisFile.java#L487-L612
11,180
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/vorbis/jcraft/jorbis/VorbisFile.java
VorbisFile.clear
int clear() { vb.clear(); vd.clear(); os.clear(); if (vi != null && links != 0) { for (int i = 0; i < links; i++) { vi[i].clear(); vc[i].clear(); } vi = null; vc = null; } if (dataoffsets != null) { dataoffsets = null; } if (pcmlengths != null) { pcmlengths = null; } if (serialnos != null) { serialnos = null; } if (offsets != null) { offsets = null; } oy.clear(); return (0); }
java
int clear() { vb.clear(); vd.clear(); os.clear(); if (vi != null && links != 0) { for (int i = 0; i < links; i++) { vi[i].clear(); vc[i].clear(); } vi = null; vc = null; } if (dataoffsets != null) { dataoffsets = null; } if (pcmlengths != null) { pcmlengths = null; } if (serialnos != null) { serialnos = null; } if (offsets != null) { offsets = null; } oy.clear(); return (0); }
[ "int", "clear", "(", ")", "{", "vb", ".", "clear", "(", ")", ";", "vd", ".", "clear", "(", ")", ";", "os", ".", "clear", "(", ")", ";", "if", "(", "vi", "!=", "null", "&&", "links", "!=", "0", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "links", ";", "i", "++", ")", "{", "vi", "[", "i", "]", ".", "clear", "(", ")", ";", "vc", "[", "i", "]", ".", "clear", "(", ")", ";", "}", "vi", "=", "null", ";", "vc", "=", "null", ";", "}", "if", "(", "dataoffsets", "!=", "null", ")", "{", "dataoffsets", "=", "null", ";", "}", "if", "(", "pcmlengths", "!=", "null", ")", "{", "pcmlengths", "=", "null", ";", "}", "if", "(", "serialnos", "!=", "null", ")", "{", "serialnos", "=", "null", ";", "}", "if", "(", "offsets", "!=", "null", ")", "{", "offsets", "=", "null", ";", "}", "oy", ".", "clear", "(", ")", ";", "return", "(", "0", ")", ";", "}" ]
clear out the OggVorbis_File struct
[ "clear", "out", "the", "OggVorbis_File", "struct" ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/jcraft/jorbis/VorbisFile.java#L616-L644
11,181
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisFormatConversionProvider.java
VorbisFormatConversionProvider.getAudioInputStream
@Override public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream audioInputStream) { if (isConversionSupported(targetFormat, audioInputStream.getFormat())) { return new DecodedVorbisAudioInputStream(targetFormat, audioInputStream); } else { throw new IllegalArgumentException("conversion not supported"); } }
java
@Override public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream audioInputStream) { if (isConversionSupported(targetFormat, audioInputStream.getFormat())) { return new DecodedVorbisAudioInputStream(targetFormat, audioInputStream); } else { throw new IllegalArgumentException("conversion not supported"); } }
[ "@", "Override", "public", "AudioInputStream", "getAudioInputStream", "(", "AudioFormat", "targetFormat", ",", "AudioInputStream", "audioInputStream", ")", "{", "if", "(", "isConversionSupported", "(", "targetFormat", ",", "audioInputStream", ".", "getFormat", "(", ")", ")", ")", "{", "return", "new", "DecodedVorbisAudioInputStream", "(", "targetFormat", ",", "audioInputStream", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"conversion not supported\"", ")", ";", "}", "}" ]
Returns converted AudioInputStream. @param audioInputStream @return
[ "Returns", "converted", "AudioInputStream", "." ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisFormatConversionProvider.java#L141-L148
11,182
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/sampled/AudioFormats.java
AudioFormats.matches
public static boolean matches(AudioFormat format1, AudioFormat format2) { //$$fb 19 Dec 99: endian must be checked, too. // // we do have a problem with redundant elements: // e.g. // encoding=ALAW || ULAW -> bigEndian and samplesizeinbits don't matter // sample size in bits == 8 -> bigEndian doesn't matter // sample size in bits > 8 -> PCM is always signed. // This is an overall issue in JavaSound, I think. // At present, it is not consistently implemented to support these // redundancies and implicit definitions // // As a workaround of this issue I return in the converters // all combinations, e.g. for ULAW I return bigEndian and !bigEndian formats. /* old version */ // as proposed by florian return format1.getEncoding().equals(format2.getEncoding()) && (format2.getSampleSizeInBits() <= 8 || format1.getSampleSizeInBits() == AudioSystem.NOT_SPECIFIED || format2.getSampleSizeInBits() == AudioSystem.NOT_SPECIFIED || format1.isBigEndian() == format2.isBigEndian()) && doMatch(format1.getChannels(), format2.getChannels()) && doMatch(format1.getSampleSizeInBits(), format2.getSampleSizeInBits()) && doMatch(format1.getFrameSize(), format2.getFrameSize()) && doMatch(format1.getSampleRate(), format2.getSampleRate()) && doMatch(format1.getFrameRate(), format2.getFrameRate()); }
java
public static boolean matches(AudioFormat format1, AudioFormat format2) { //$$fb 19 Dec 99: endian must be checked, too. // // we do have a problem with redundant elements: // e.g. // encoding=ALAW || ULAW -> bigEndian and samplesizeinbits don't matter // sample size in bits == 8 -> bigEndian doesn't matter // sample size in bits > 8 -> PCM is always signed. // This is an overall issue in JavaSound, I think. // At present, it is not consistently implemented to support these // redundancies and implicit definitions // // As a workaround of this issue I return in the converters // all combinations, e.g. for ULAW I return bigEndian and !bigEndian formats. /* old version */ // as proposed by florian return format1.getEncoding().equals(format2.getEncoding()) && (format2.getSampleSizeInBits() <= 8 || format1.getSampleSizeInBits() == AudioSystem.NOT_SPECIFIED || format2.getSampleSizeInBits() == AudioSystem.NOT_SPECIFIED || format1.isBigEndian() == format2.isBigEndian()) && doMatch(format1.getChannels(), format2.getChannels()) && doMatch(format1.getSampleSizeInBits(), format2.getSampleSizeInBits()) && doMatch(format1.getFrameSize(), format2.getFrameSize()) && doMatch(format1.getSampleRate(), format2.getSampleRate()) && doMatch(format1.getFrameRate(), format2.getFrameRate()); }
[ "public", "static", "boolean", "matches", "(", "AudioFormat", "format1", ",", "AudioFormat", "format2", ")", "{", "//$$fb 19 Dec 99: endian must be checked, too.", "//", "// we do have a problem with redundant elements:", "// e.g.", "// encoding=ALAW || ULAW -> bigEndian and samplesizeinbits don't matter", "// sample size in bits == 8 -> bigEndian doesn't matter", "// sample size in bits > 8 -> PCM is always signed.", "// This is an overall issue in JavaSound, I think.", "// At present, it is not consistently implemented to support these", "// redundancies and implicit definitions", "//", "// As a workaround of this issue I return in the converters", "// all combinations, e.g. for ULAW I return bigEndian and !bigEndian formats.", "/* old version\n */", "// as proposed by florian", "return", "format1", ".", "getEncoding", "(", ")", ".", "equals", "(", "format2", ".", "getEncoding", "(", ")", ")", "&&", "(", "format2", ".", "getSampleSizeInBits", "(", ")", "<=", "8", "||", "format1", ".", "getSampleSizeInBits", "(", ")", "==", "AudioSystem", ".", "NOT_SPECIFIED", "||", "format2", ".", "getSampleSizeInBits", "(", ")", "==", "AudioSystem", ".", "NOT_SPECIFIED", "||", "format1", ".", "isBigEndian", "(", ")", "==", "format2", ".", "isBigEndian", "(", ")", ")", "&&", "doMatch", "(", "format1", ".", "getChannels", "(", ")", ",", "format2", ".", "getChannels", "(", ")", ")", "&&", "doMatch", "(", "format1", ".", "getSampleSizeInBits", "(", ")", ",", "format2", ".", "getSampleSizeInBits", "(", ")", ")", "&&", "doMatch", "(", "format1", ".", "getFrameSize", "(", ")", ",", "format2", ".", "getFrameSize", "(", ")", ")", "&&", "doMatch", "(", "format1", ".", "getSampleRate", "(", ")", ",", "format2", ".", "getSampleRate", "(", ")", ")", "&&", "doMatch", "(", "format1", ".", "getFrameRate", "(", ")", ",", "format2", ".", "getFrameRate", "(", ")", ")", ";", "}" ]
and a AudioFormat.Encoding.matches method.
[ "and", "a", "AudioFormat", ".", "Encoding", ".", "matches", "method", "." ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/sampled/AudioFormats.java#L66-L94
11,183
gustavkarlsson/g-wiz
src/main/java/se/gustavkarlsson/gwiz/wizards/JFrameWizard.java
JFrameWizard.setupWizard
private void setupWizard() { setupComponents(); layoutComponents(); setMinimumSize(defaultminimumSize); // Center on screen Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int xPosition = (screenSize.width / 2) - (defaultminimumSize.width / 2); int yPosition = (screenSize.height / 2) - (defaultminimumSize.height / 2); setLocation(xPosition, yPosition); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); }
java
private void setupWizard() { setupComponents(); layoutComponents(); setMinimumSize(defaultminimumSize); // Center on screen Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int xPosition = (screenSize.width / 2) - (defaultminimumSize.width / 2); int yPosition = (screenSize.height / 2) - (defaultminimumSize.height / 2); setLocation(xPosition, yPosition); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); }
[ "private", "void", "setupWizard", "(", ")", "{", "setupComponents", "(", ")", ";", "layoutComponents", "(", ")", ";", "setMinimumSize", "(", "defaultminimumSize", ")", ";", "// Center on screen", "Dimension", "screenSize", "=", "Toolkit", ".", "getDefaultToolkit", "(", ")", ".", "getScreenSize", "(", ")", ";", "int", "xPosition", "=", "(", "screenSize", ".", "width", "/", "2", ")", "-", "(", "defaultminimumSize", ".", "width", "/", "2", ")", ";", "int", "yPosition", "=", "(", "screenSize", ".", "height", "/", "2", ")", "-", "(", "defaultminimumSize", ".", "height", "/", "2", ")", ";", "setLocation", "(", "xPosition", ",", "yPosition", ")", ";", "setDefaultCloseOperation", "(", "JFrame", ".", "DISPOSE_ON_CLOSE", ")", ";", "}" ]
Sets up wizard upon construction.
[ "Sets", "up", "wizard", "upon", "construction", "." ]
cf290272e0626d7a515283b71ad99745f29ab106
https://github.com/gustavkarlsson/g-wiz/blob/cf290272e0626d7a515283b71ad99745f29ab106/src/main/java/se/gustavkarlsson/gwiz/wizards/JFrameWizard.java#L103-L116
11,184
gustavkarlsson/g-wiz
src/main/java/se/gustavkarlsson/gwiz/wizards/JFrameWizard.java
JFrameWizard.setupComponents
private void setupComponents() { cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); finishButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(getContentPane(), "Wizard finished!"); dispose(); } }); cancelButton.setMnemonic(KeyEvent.VK_C); previousButton.setMnemonic(KeyEvent.VK_P); nextButton.setMnemonic(KeyEvent.VK_N); finishButton.setMnemonic(KeyEvent.VK_F); wizardPageContainer.addContainerListener(new MinimumSizeAdjuster()); }
java
private void setupComponents() { cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); finishButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(getContentPane(), "Wizard finished!"); dispose(); } }); cancelButton.setMnemonic(KeyEvent.VK_C); previousButton.setMnemonic(KeyEvent.VK_P); nextButton.setMnemonic(KeyEvent.VK_N); finishButton.setMnemonic(KeyEvent.VK_F); wizardPageContainer.addContainerListener(new MinimumSizeAdjuster()); }
[ "private", "void", "setupComponents", "(", ")", "{", "cancelButton", ".", "addActionListener", "(", "new", "ActionListener", "(", ")", "{", "@", "Override", "public", "void", "actionPerformed", "(", "ActionEvent", "e", ")", "{", "dispose", "(", ")", ";", "}", "}", ")", ";", "finishButton", ".", "addActionListener", "(", "new", "ActionListener", "(", ")", "{", "@", "Override", "public", "void", "actionPerformed", "(", "ActionEvent", "e", ")", "{", "JOptionPane", ".", "showMessageDialog", "(", "getContentPane", "(", ")", ",", "\"Wizard finished!\"", ")", ";", "dispose", "(", ")", ";", "}", "}", ")", ";", "cancelButton", ".", "setMnemonic", "(", "KeyEvent", ".", "VK_C", ")", ";", "previousButton", ".", "setMnemonic", "(", "KeyEvent", ".", "VK_P", ")", ";", "nextButton", ".", "setMnemonic", "(", "KeyEvent", ".", "VK_N", ")", ";", "finishButton", ".", "setMnemonic", "(", "KeyEvent", ".", "VK_F", ")", ";", "wizardPageContainer", ".", "addContainerListener", "(", "new", "MinimumSizeAdjuster", "(", ")", ")", ";", "}" ]
Sets up the components of the wizard with listeners and mnemonics.
[ "Sets", "up", "the", "components", "of", "the", "wizard", "with", "listeners", "and", "mnemonics", "." ]
cf290272e0626d7a515283b71ad99745f29ab106
https://github.com/gustavkarlsson/g-wiz/blob/cf290272e0626d7a515283b71ad99745f29ab106/src/main/java/se/gustavkarlsson/gwiz/wizards/JFrameWizard.java#L121-L143
11,185
gustavkarlsson/g-wiz
src/main/java/se/gustavkarlsson/gwiz/wizards/JFrameWizard.java
JFrameWizard.layoutComponents
private void layoutComponents() { GridBagLayout layout = new GridBagLayout(); layout.rowWeights = new double[]{1.0, 0.0, 0.0}; layout.columnWeights = new double[]{1.0, 0.0, 0.0, 0.0, 0.0}; layout.rowHeights = new int[] {0, 0, 0}; layout.columnWidths = new int[] {0, 0, 0, 0, 0}; getContentPane().setLayout(layout); GridBagConstraints wizardPageContainerConstraint = new GridBagConstraints(); wizardPageContainerConstraint.gridwidth = 5; wizardPageContainerConstraint.fill = GridBagConstraints.BOTH; wizardPageContainerConstraint.gridx = 0; wizardPageContainerConstraint.gridy = 0; wizardPageContainerConstraint.insets = new Insets(5, 5, 5, 5); getContentPane().add(wizardPageContainer, wizardPageContainerConstraint); GridBagConstraints separatorConstraints = new GridBagConstraints(); separatorConstraints.gridwidth = 5; separatorConstraints.fill = GridBagConstraints.HORIZONTAL; separatorConstraints.gridx = 0; separatorConstraints.gridy = 1; separatorConstraints.insets = new Insets(5, 5, 5, 5); getContentPane().add(new JSeparator(), separatorConstraints); GridBagConstraints cancelButtonConstraints = new GridBagConstraints(); cancelButtonConstraints.gridx = 1; cancelButtonConstraints.gridy = 2; cancelButtonConstraints.insets = new Insets(5, 5, 5, 0); getContentPane().add(cancelButton, cancelButtonConstraints); GridBagConstraints previousButtonConstraints = new GridBagConstraints(); previousButtonConstraints.gridx = 2; previousButtonConstraints.gridy = 2; previousButtonConstraints.insets = new Insets(5, 5, 5, 0); getContentPane().add(previousButton, previousButtonConstraints); GridBagConstraints nextButtonConstraints = new GridBagConstraints(); nextButtonConstraints.gridx = 3; nextButtonConstraints.gridy = 2; nextButtonConstraints.insets = new Insets(5, 5, 5, 0); getContentPane().add(nextButton, nextButtonConstraints); GridBagConstraints finishButtonConstraints = new GridBagConstraints(); finishButtonConstraints.gridx = 4; finishButtonConstraints.gridy = 2; finishButtonConstraints.insets = new Insets(5, 5, 5, 5); getContentPane().add(finishButton, finishButtonConstraints); }
java
private void layoutComponents() { GridBagLayout layout = new GridBagLayout(); layout.rowWeights = new double[]{1.0, 0.0, 0.0}; layout.columnWeights = new double[]{1.0, 0.0, 0.0, 0.0, 0.0}; layout.rowHeights = new int[] {0, 0, 0}; layout.columnWidths = new int[] {0, 0, 0, 0, 0}; getContentPane().setLayout(layout); GridBagConstraints wizardPageContainerConstraint = new GridBagConstraints(); wizardPageContainerConstraint.gridwidth = 5; wizardPageContainerConstraint.fill = GridBagConstraints.BOTH; wizardPageContainerConstraint.gridx = 0; wizardPageContainerConstraint.gridy = 0; wizardPageContainerConstraint.insets = new Insets(5, 5, 5, 5); getContentPane().add(wizardPageContainer, wizardPageContainerConstraint); GridBagConstraints separatorConstraints = new GridBagConstraints(); separatorConstraints.gridwidth = 5; separatorConstraints.fill = GridBagConstraints.HORIZONTAL; separatorConstraints.gridx = 0; separatorConstraints.gridy = 1; separatorConstraints.insets = new Insets(5, 5, 5, 5); getContentPane().add(new JSeparator(), separatorConstraints); GridBagConstraints cancelButtonConstraints = new GridBagConstraints(); cancelButtonConstraints.gridx = 1; cancelButtonConstraints.gridy = 2; cancelButtonConstraints.insets = new Insets(5, 5, 5, 0); getContentPane().add(cancelButton, cancelButtonConstraints); GridBagConstraints previousButtonConstraints = new GridBagConstraints(); previousButtonConstraints.gridx = 2; previousButtonConstraints.gridy = 2; previousButtonConstraints.insets = new Insets(5, 5, 5, 0); getContentPane().add(previousButton, previousButtonConstraints); GridBagConstraints nextButtonConstraints = new GridBagConstraints(); nextButtonConstraints.gridx = 3; nextButtonConstraints.gridy = 2; nextButtonConstraints.insets = new Insets(5, 5, 5, 0); getContentPane().add(nextButton, nextButtonConstraints); GridBagConstraints finishButtonConstraints = new GridBagConstraints(); finishButtonConstraints.gridx = 4; finishButtonConstraints.gridy = 2; finishButtonConstraints.insets = new Insets(5, 5, 5, 5); getContentPane().add(finishButton, finishButtonConstraints); }
[ "private", "void", "layoutComponents", "(", ")", "{", "GridBagLayout", "layout", "=", "new", "GridBagLayout", "(", ")", ";", "layout", ".", "rowWeights", "=", "new", "double", "[", "]", "{", "1.0", ",", "0.0", ",", "0.0", "}", ";", "layout", ".", "columnWeights", "=", "new", "double", "[", "]", "{", "1.0", ",", "0.0", ",", "0.0", ",", "0.0", ",", "0.0", "}", ";", "layout", ".", "rowHeights", "=", "new", "int", "[", "]", "{", "0", ",", "0", ",", "0", "}", ";", "layout", ".", "columnWidths", "=", "new", "int", "[", "]", "{", "0", ",", "0", ",", "0", ",", "0", ",", "0", "}", ";", "getContentPane", "(", ")", ".", "setLayout", "(", "layout", ")", ";", "GridBagConstraints", "wizardPageContainerConstraint", "=", "new", "GridBagConstraints", "(", ")", ";", "wizardPageContainerConstraint", ".", "gridwidth", "=", "5", ";", "wizardPageContainerConstraint", ".", "fill", "=", "GridBagConstraints", ".", "BOTH", ";", "wizardPageContainerConstraint", ".", "gridx", "=", "0", ";", "wizardPageContainerConstraint", ".", "gridy", "=", "0", ";", "wizardPageContainerConstraint", ".", "insets", "=", "new", "Insets", "(", "5", ",", "5", ",", "5", ",", "5", ")", ";", "getContentPane", "(", ")", ".", "add", "(", "wizardPageContainer", ",", "wizardPageContainerConstraint", ")", ";", "GridBagConstraints", "separatorConstraints", "=", "new", "GridBagConstraints", "(", ")", ";", "separatorConstraints", ".", "gridwidth", "=", "5", ";", "separatorConstraints", ".", "fill", "=", "GridBagConstraints", ".", "HORIZONTAL", ";", "separatorConstraints", ".", "gridx", "=", "0", ";", "separatorConstraints", ".", "gridy", "=", "1", ";", "separatorConstraints", ".", "insets", "=", "new", "Insets", "(", "5", ",", "5", ",", "5", ",", "5", ")", ";", "getContentPane", "(", ")", ".", "add", "(", "new", "JSeparator", "(", ")", ",", "separatorConstraints", ")", ";", "GridBagConstraints", "cancelButtonConstraints", "=", "new", "GridBagConstraints", "(", ")", ";", "cancelButtonConstraints", ".", "gridx", "=", "1", ";", "cancelButtonConstraints", ".", "gridy", "=", "2", ";", "cancelButtonConstraints", ".", "insets", "=", "new", "Insets", "(", "5", ",", "5", ",", "5", ",", "0", ")", ";", "getContentPane", "(", ")", ".", "add", "(", "cancelButton", ",", "cancelButtonConstraints", ")", ";", "GridBagConstraints", "previousButtonConstraints", "=", "new", "GridBagConstraints", "(", ")", ";", "previousButtonConstraints", ".", "gridx", "=", "2", ";", "previousButtonConstraints", ".", "gridy", "=", "2", ";", "previousButtonConstraints", ".", "insets", "=", "new", "Insets", "(", "5", ",", "5", ",", "5", ",", "0", ")", ";", "getContentPane", "(", ")", ".", "add", "(", "previousButton", ",", "previousButtonConstraints", ")", ";", "GridBagConstraints", "nextButtonConstraints", "=", "new", "GridBagConstraints", "(", ")", ";", "nextButtonConstraints", ".", "gridx", "=", "3", ";", "nextButtonConstraints", ".", "gridy", "=", "2", ";", "nextButtonConstraints", ".", "insets", "=", "new", "Insets", "(", "5", ",", "5", ",", "5", ",", "0", ")", ";", "getContentPane", "(", ")", ".", "add", "(", "nextButton", ",", "nextButtonConstraints", ")", ";", "GridBagConstraints", "finishButtonConstraints", "=", "new", "GridBagConstraints", "(", ")", ";", "finishButtonConstraints", ".", "gridx", "=", "4", ";", "finishButtonConstraints", ".", "gridy", "=", "2", ";", "finishButtonConstraints", ".", "insets", "=", "new", "Insets", "(", "5", ",", "5", ",", "5", ",", "5", ")", ";", "getContentPane", "(", ")", ".", "add", "(", "finishButton", ",", "finishButtonConstraints", ")", ";", "}" ]
Lays out the components in the wizards content pane.
[ "Lays", "out", "the", "components", "in", "the", "wizards", "content", "pane", "." ]
cf290272e0626d7a515283b71ad99745f29ab106
https://github.com/gustavkarlsson/g-wiz/blob/cf290272e0626d7a515283b71ad99745f29ab106/src/main/java/se/gustavkarlsson/gwiz/wizards/JFrameWizard.java#L148-L195
11,186
EXIficient/exificient-grammars
src/main/java/com/siemens/ct/exi/grammars/GrammarFactory.java
GrammarFactory.createXSDTypesOnlyGrammars
public Grammars createXSDTypesOnlyGrammars() throws EXIException { grammarBuilder.loadXSDTypesOnlyGrammars(); SchemaInformedGrammars g = grammarBuilder.toGrammars(); g.setBuiltInXMLSchemaTypesOnly(true); // builtInXMLSchemaTypesOnly return g; }
java
public Grammars createXSDTypesOnlyGrammars() throws EXIException { grammarBuilder.loadXSDTypesOnlyGrammars(); SchemaInformedGrammars g = grammarBuilder.toGrammars(); g.setBuiltInXMLSchemaTypesOnly(true); // builtInXMLSchemaTypesOnly return g; }
[ "public", "Grammars", "createXSDTypesOnlyGrammars", "(", ")", "throws", "EXIException", "{", "grammarBuilder", ".", "loadXSDTypesOnlyGrammars", "(", ")", ";", "SchemaInformedGrammars", "g", "=", "grammarBuilder", ".", "toGrammars", "(", ")", ";", "g", ".", "setBuiltInXMLSchemaTypesOnly", "(", "true", ")", ";", "// builtInXMLSchemaTypesOnly", "return", "g", ";", "}" ]
No user defined schema information is generated for processing the EXI body; however, the built-in XML schema types are available for use in the EXI body. @return built-in XSD EXI grammars @throws EXIException EXI exception
[ "No", "user", "defined", "schema", "information", "is", "generated", "for", "processing", "the", "EXI", "body", ";", "however", "the", "built", "-", "in", "XML", "schema", "types", "are", "available", "for", "use", "in", "the", "EXI", "body", "." ]
d96477062ebdd4245920e44cc1995259699fc7fb
https://github.com/EXIficient/exificient-grammars/blob/d96477062ebdd4245920e44cc1995259699fc7fb/src/main/java/com/siemens/ct/exi/grammars/GrammarFactory.java#L138-L143
11,187
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/sampled/spi/SimpleFormatConversionProvider.java
SimpleFormatConversionProvider.getTargetEncodings
@Override public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat) { if (isAllowedSourceFormat(sourceFormat)) { return getTargetEncodings(); } else { return EMPTY_ENCODING_ARRAY; } }
java
@Override public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat) { if (isAllowedSourceFormat(sourceFormat)) { return getTargetEncodings(); } else { return EMPTY_ENCODING_ARRAY; } }
[ "@", "Override", "public", "AudioFormat", ".", "Encoding", "[", "]", "getTargetEncodings", "(", "AudioFormat", "sourceFormat", ")", "{", "if", "(", "isAllowedSourceFormat", "(", "sourceFormat", ")", ")", "{", "return", "getTargetEncodings", "(", ")", ";", "}", "else", "{", "return", "EMPTY_ENCODING_ARRAY", ";", "}", "}" ]
This implementation assumes that the converter can convert from each of its source encodings to each of its target encodings. If this is not the case, the converter has to override this method. @param sourceFormat @return
[ "This", "implementation", "assumes", "that", "the", "converter", "can", "convert", "from", "each", "of", "its", "source", "encodings", "to", "each", "of", "its", "target", "encodings", ".", "If", "this", "is", "not", "the", "case", "the", "converter", "has", "to", "override", "this", "method", "." ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/sampled/spi/SimpleFormatConversionProvider.java#L111-L118
11,188
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/sampled/spi/SimpleFormatConversionProvider.java
SimpleFormatConversionProvider.getTargetFormats
@Override public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat) { if (isConversionSupported(targetEncoding, sourceFormat)) { return m_targetFormats.toArray(EMPTY_FORMAT_ARRAY); } else { return EMPTY_FORMAT_ARRAY; } }
java
@Override public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat) { if (isConversionSupported(targetEncoding, sourceFormat)) { return m_targetFormats.toArray(EMPTY_FORMAT_ARRAY); } else { return EMPTY_FORMAT_ARRAY; } }
[ "@", "Override", "public", "AudioFormat", "[", "]", "getTargetFormats", "(", "AudioFormat", ".", "Encoding", "targetEncoding", ",", "AudioFormat", "sourceFormat", ")", "{", "if", "(", "isConversionSupported", "(", "targetEncoding", ",", "sourceFormat", ")", ")", "{", "return", "m_targetFormats", ".", "toArray", "(", "EMPTY_FORMAT_ARRAY", ")", ";", "}", "else", "{", "return", "EMPTY_FORMAT_ARRAY", ";", "}", "}" ]
This implementation assumes that the converter can convert from each of its source formats to each of its target formats. If this is not the case, the converter has to override this method. @param targetEncoding @param sourceFormat @return
[ "This", "implementation", "assumes", "that", "the", "converter", "can", "convert", "from", "each", "of", "its", "source", "formats", "to", "each", "of", "its", "target", "formats", ".", "If", "this", "is", "not", "the", "case", "the", "converter", "has", "to", "override", "this", "method", "." ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/sampled/spi/SimpleFormatConversionProvider.java#L129-L136
11,189
EXIficient/exificient-grammars
src/main/java/com/siemens/ct/exi/grammars/regex/Token.java
Token.getMinLength
final int getMinLength() { switch (this.type) { case CONCAT: int sum = 0; for (int i = 0; i < this.size(); i++) sum += this.getChild(i).getMinLength(); return sum; case CONDITION: case UNION: if (this.size() == 0) return 0; int ret = this.getChild(0).getMinLength(); for (int i = 1; i < this.size(); i++) { int min = this.getChild(i).getMinLength(); if (min < ret) ret = min; } return ret; case CLOSURE: case NONGREEDYCLOSURE: if (this.getMin() >= 0) return this.getMin() * this.getChild(0).getMinLength(); return 0; case EMPTY: case ANCHOR: return 0; case DOT: case CHAR: case RANGE: case NRANGE: return 1; case INDEPENDENT: case PAREN: case MODIFIERGROUP: return this.getChild(0).getMinLength(); case BACKREFERENCE: return 0; // ******* case STRING: return this.getString().length(); case LOOKAHEAD: case NEGATIVELOOKAHEAD: case LOOKBEHIND: case NEGATIVELOOKBEHIND: return 0; // ***** Really? default: throw new RuntimeException("Token#getMinLength(): Invalid Type: " + this.type); } }
java
final int getMinLength() { switch (this.type) { case CONCAT: int sum = 0; for (int i = 0; i < this.size(); i++) sum += this.getChild(i).getMinLength(); return sum; case CONDITION: case UNION: if (this.size() == 0) return 0; int ret = this.getChild(0).getMinLength(); for (int i = 1; i < this.size(); i++) { int min = this.getChild(i).getMinLength(); if (min < ret) ret = min; } return ret; case CLOSURE: case NONGREEDYCLOSURE: if (this.getMin() >= 0) return this.getMin() * this.getChild(0).getMinLength(); return 0; case EMPTY: case ANCHOR: return 0; case DOT: case CHAR: case RANGE: case NRANGE: return 1; case INDEPENDENT: case PAREN: case MODIFIERGROUP: return this.getChild(0).getMinLength(); case BACKREFERENCE: return 0; // ******* case STRING: return this.getString().length(); case LOOKAHEAD: case NEGATIVELOOKAHEAD: case LOOKBEHIND: case NEGATIVELOOKBEHIND: return 0; // ***** Really? default: throw new RuntimeException("Token#getMinLength(): Invalid Type: " + this.type); } }
[ "final", "int", "getMinLength", "(", ")", "{", "switch", "(", "this", ".", "type", ")", "{", "case", "CONCAT", ":", "int", "sum", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "size", "(", ")", ";", "i", "++", ")", "sum", "+=", "this", ".", "getChild", "(", "i", ")", ".", "getMinLength", "(", ")", ";", "return", "sum", ";", "case", "CONDITION", ":", "case", "UNION", ":", "if", "(", "this", ".", "size", "(", ")", "==", "0", ")", "return", "0", ";", "int", "ret", "=", "this", ".", "getChild", "(", "0", ")", ".", "getMinLength", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "this", ".", "size", "(", ")", ";", "i", "++", ")", "{", "int", "min", "=", "this", ".", "getChild", "(", "i", ")", ".", "getMinLength", "(", ")", ";", "if", "(", "min", "<", "ret", ")", "ret", "=", "min", ";", "}", "return", "ret", ";", "case", "CLOSURE", ":", "case", "NONGREEDYCLOSURE", ":", "if", "(", "this", ".", "getMin", "(", ")", ">=", "0", ")", "return", "this", ".", "getMin", "(", ")", "*", "this", ".", "getChild", "(", "0", ")", ".", "getMinLength", "(", ")", ";", "return", "0", ";", "case", "EMPTY", ":", "case", "ANCHOR", ":", "return", "0", ";", "case", "DOT", ":", "case", "CHAR", ":", "case", "RANGE", ":", "case", "NRANGE", ":", "return", "1", ";", "case", "INDEPENDENT", ":", "case", "PAREN", ":", "case", "MODIFIERGROUP", ":", "return", "this", ".", "getChild", "(", "0", ")", ".", "getMinLength", "(", ")", ";", "case", "BACKREFERENCE", ":", "return", "0", ";", "// *******\r", "case", "STRING", ":", "return", "this", ".", "getString", "(", ")", ".", "length", "(", ")", ";", "case", "LOOKAHEAD", ":", "case", "NEGATIVELOOKAHEAD", ":", "case", "LOOKBEHIND", ":", "case", "NEGATIVELOOKBEHIND", ":", "return", "0", ";", "// ***** Really?\r", "default", ":", "throw", "new", "RuntimeException", "(", "\"Token#getMinLength(): Invalid Type: \"", "+", "this", ".", "type", ")", ";", "}", "}" ]
How many characters are needed?
[ "How", "many", "characters", "are", "needed?" ]
d96477062ebdd4245920e44cc1995259699fc7fb
https://github.com/EXIficient/exificient-grammars/blob/d96477062ebdd4245920e44cc1995259699fc7fb/src/main/java/com/siemens/ct/exi/grammars/regex/Token.java#L303-L360
11,190
gustavkarlsson/g-wiz
src/main/java/se/gustavkarlsson/gwiz/WizardController.java
WizardController.showNextPage
public boolean showNextPage(AbstractWizardPage nextPage) { if (nextPage == null) { // Next page is null. Updating buttons and ignoring request. updateButtons(); return false; } if (currentPage != null) { pageHistory.push(currentPage); } setPage(nextPage); return true; }
java
public boolean showNextPage(AbstractWizardPage nextPage) { if (nextPage == null) { // Next page is null. Updating buttons and ignoring request. updateButtons(); return false; } if (currentPage != null) { pageHistory.push(currentPage); } setPage(nextPage); return true; }
[ "public", "boolean", "showNextPage", "(", "AbstractWizardPage", "nextPage", ")", "{", "if", "(", "nextPage", "==", "null", ")", "{", "// Next page is null. Updating buttons and ignoring request.", "updateButtons", "(", ")", ";", "return", "false", ";", "}", "if", "(", "currentPage", "!=", "null", ")", "{", "pageHistory", ".", "push", "(", "currentPage", ")", ";", "}", "setPage", "(", "nextPage", ")", ";", "return", "true", ";", "}" ]
Sets the current page of this wizard to the specified page and adds the previous "current page" to the history. @param nextPage the page to set as the current page @return <code>true</code> if the current page was changed, otherwise <code>false</code>
[ "Sets", "the", "current", "page", "of", "this", "wizard", "to", "the", "specified", "page", "and", "adds", "the", "previous", "current", "page", "to", "the", "history", "." ]
cf290272e0626d7a515283b71ad99745f29ab106
https://github.com/gustavkarlsson/g-wiz/blob/cf290272e0626d7a515283b71ad99745f29ab106/src/main/java/se/gustavkarlsson/gwiz/WizardController.java#L61-L72
11,191
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/vorbis/jcraft/jorbis/CodeBook.java
CodeBook.encode
int encode(int a, Buffer b) { b.write(codelist[a], c.lengthlist[a]); return (c.lengthlist[a]); }
java
int encode(int a, Buffer b) { b.write(codelist[a], c.lengthlist[a]); return (c.lengthlist[a]); }
[ "int", "encode", "(", "int", "a", ",", "Buffer", "b", ")", "{", "b", ".", "write", "(", "codelist", "[", "a", "]", ",", "c", ".", "lengthlist", "[", "a", "]", ")", ";", "return", "(", "c", ".", "lengthlist", "[", "a", "]", ")", ";", "}" ]
returns the number of bits
[ "returns", "the", "number", "of", "bits" ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/jcraft/jorbis/CodeBook.java#L37-L40
11,192
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/vorbis/jcraft/jorbis/CodeBook.java
CodeBook.decodevs_add
synchronized int decodevs_add(float[] a, int offset, Buffer b, int n) { int step = n / dim; int entry; int i, j, o; if (t.length < step) { t = new int[step]; } for (i = 0; i < step; i++) { entry = decode(b); if (entry == -1) { return (-1); } t[i] = entry * dim; } for (i = 0, o = 0; i < dim; i++, o += step) { for (j = 0; j < step; j++) { a[offset + o + j] += valuelist[t[j] + i]; } } return (0); }
java
synchronized int decodevs_add(float[] a, int offset, Buffer b, int n) { int step = n / dim; int entry; int i, j, o; if (t.length < step) { t = new int[step]; } for (i = 0; i < step; i++) { entry = decode(b); if (entry == -1) { return (-1); } t[i] = entry * dim; } for (i = 0, o = 0; i < dim; i++, o += step) { for (j = 0; j < step; j++) { a[offset + o + j] += valuelist[t[j] + i]; } } return (0); }
[ "synchronized", "int", "decodevs_add", "(", "float", "[", "]", "a", ",", "int", "offset", ",", "Buffer", "b", ",", "int", "n", ")", "{", "int", "step", "=", "n", "/", "dim", ";", "int", "entry", ";", "int", "i", ",", "j", ",", "o", ";", "if", "(", "t", ".", "length", "<", "step", ")", "{", "t", "=", "new", "int", "[", "step", "]", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "step", ";", "i", "++", ")", "{", "entry", "=", "decode", "(", "b", ")", ";", "if", "(", "entry", "==", "-", "1", ")", "{", "return", "(", "-", "1", ")", ";", "}", "t", "[", "i", "]", "=", "entry", "*", "dim", ";", "}", "for", "(", "i", "=", "0", ",", "o", "=", "0", ";", "i", "<", "dim", ";", "i", "++", ",", "o", "+=", "step", ")", "{", "for", "(", "j", "=", "0", ";", "j", "<", "step", ";", "j", "++", ")", "{", "a", "[", "offset", "+", "o", "+", "j", "]", "+=", "valuelist", "[", "t", "[", "j", "]", "+", "i", "]", ";", "}", "}", "return", "(", "0", ")", ";", "}" ]
decodevs_add is synchronized for re-using t.
[ "decodevs_add", "is", "synchronized", "for", "re", "-", "using", "t", "." ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/jcraft/jorbis/CodeBook.java#L81-L104
11,193
Trilarion/java-vorbis-support
src/main/java/com/github/trilarion/sound/vorbis/jcraft/jorbis/StaticCodeBook.java
StaticCodeBook.maptype1_quantvals
private int maptype1_quantvals() { int vals = (int) (Math.floor(Math.pow(entries, 1. / dim))); // the above *should* be reliable, but we'll not assume that FP is // ever reliable when bitstream sync is at stake; verify via integer // means that vals really is the greatest value of dim for which // vals^b->bim <= b->entries // treat the above as an initial guess while (true) { int acc = 1; int acc1 = 1; for (int i = 0; i < dim; i++) { acc *= vals; acc1 *= vals + 1; } if (acc <= entries && acc1 > entries) { return (vals); } else { if (acc > entries) { vals--; } else { vals++; } } } }
java
private int maptype1_quantvals() { int vals = (int) (Math.floor(Math.pow(entries, 1. / dim))); // the above *should* be reliable, but we'll not assume that FP is // ever reliable when bitstream sync is at stake; verify via integer // means that vals really is the greatest value of dim for which // vals^b->bim <= b->entries // treat the above as an initial guess while (true) { int acc = 1; int acc1 = 1; for (int i = 0; i < dim; i++) { acc *= vals; acc1 *= vals + 1; } if (acc <= entries && acc1 > entries) { return (vals); } else { if (acc > entries) { vals--; } else { vals++; } } } }
[ "private", "int", "maptype1_quantvals", "(", ")", "{", "int", "vals", "=", "(", "int", ")", "(", "Math", ".", "floor", "(", "Math", ".", "pow", "(", "entries", ",", "1.", "/", "dim", ")", ")", ")", ";", "// the above *should* be reliable, but we'll not assume that FP is", "// ever reliable when bitstream sync is at stake; verify via integer", "// means that vals really is the greatest value of dim for which", "// vals^b->bim <= b->entries", "// treat the above as an initial guess", "while", "(", "true", ")", "{", "int", "acc", "=", "1", ";", "int", "acc1", "=", "1", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dim", ";", "i", "++", ")", "{", "acc", "*=", "vals", ";", "acc1", "*=", "vals", "+", "1", ";", "}", "if", "(", "acc", "<=", "entries", "&&", "acc1", ">", "entries", ")", "{", "return", "(", "vals", ")", ";", "}", "else", "{", "if", "(", "acc", ">", "entries", ")", "{", "vals", "--", ";", "}", "else", "{", "vals", "++", ";", "}", "}", "}", "}" ]
thought of it. Therefore, we opt on the side of caution
[ "thought", "of", "it", ".", "Therefore", "we", "opt", "on", "the", "side", "of", "caution" ]
f72aba7d97167fe0ff20b1b719fdb5bb662ff736
https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/jcraft/jorbis/StaticCodeBook.java#L313-L338
11,194
j-a-w-r/jawr
jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/ResourceBundleDefinition.java
ResourceBundleDefinition.setBundleId
public void setBundleId(String bundleId) { if (JawrRequestHandler.CLIENTSIDE_HANDLER_REQ_PATH.equals(bundleId)) throw new IllegalArgumentException("The provided id [" + JawrRequestHandler.CLIENTSIDE_HANDLER_REQ_PATH + "] can't be used since it's the same as the clientside handler path. Please change this id (or the name of the script)"); this.bundleId = bundleId; }
java
public void setBundleId(String bundleId) { if (JawrRequestHandler.CLIENTSIDE_HANDLER_REQ_PATH.equals(bundleId)) throw new IllegalArgumentException("The provided id [" + JawrRequestHandler.CLIENTSIDE_HANDLER_REQ_PATH + "] can't be used since it's the same as the clientside handler path. Please change this id (or the name of the script)"); this.bundleId = bundleId; }
[ "public", "void", "setBundleId", "(", "String", "bundleId", ")", "{", "if", "(", "JawrRequestHandler", ".", "CLIENTSIDE_HANDLER_REQ_PATH", ".", "equals", "(", "bundleId", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"The provided id [\"", "+", "JawrRequestHandler", ".", "CLIENTSIDE_HANDLER_REQ_PATH", "+", "\"] can't be used since it's the same as the clientside handler path. Please change this id (or the name of the script)\"", ")", ";", "this", ".", "bundleId", "=", "bundleId", ";", "}" ]
Sets the bundle ID @param bundleId the bundle ID to set
[ "Sets", "the", "bundle", "ID" ]
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/ResourceBundleDefinition.java#L144-L149
11,195
j-a-w-r/jawr
jawr-core/src/main/java/net/jawr/web/servlet/util/ClientAbortExceptionResolver.java
ClientAbortExceptionResolver.isClientAbortException
public static boolean isClientAbortException(IOException e) { String exceptionClassName = e.getClass().getName(); return exceptionClassName.endsWith(".EofException") || exceptionClassName.endsWith(".ClientAbortException"); }
java
public static boolean isClientAbortException(IOException e) { String exceptionClassName = e.getClass().getName(); return exceptionClassName.endsWith(".EofException") || exceptionClassName.endsWith(".ClientAbortException"); }
[ "public", "static", "boolean", "isClientAbortException", "(", "IOException", "e", ")", "{", "String", "exceptionClassName", "=", "e", ".", "getClass", "(", ")", ".", "getName", "(", ")", ";", "return", "exceptionClassName", ".", "endsWith", "(", "\".EofException\"", ")", "||", "exceptionClassName", ".", "endsWith", "(", "\".ClientAbortException\"", ")", ";", "}" ]
Checks if the exception is a client abort exception @param e @return true if the exception is a client abort exception
[ "Checks", "if", "the", "exception", "is", "a", "client", "abort", "exception" ]
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/servlet/util/ClientAbortExceptionResolver.java#L32-L37
11,196
d-michail/jheaps
src/main/java/org/jheaps/tree/ReflectedHeap.java
ReflectedHeap.insertPair
@SuppressWarnings("unchecked") private void insertPair(ReflectedHandle<K, V> handle1, ReflectedHandle<K, V> handle2) { int c; if (comparator == null) { c = ((Comparable<? super K>) handle1.key).compareTo(handle2.key); } else { c = comparator.compare(handle1.key, handle2.key); } AddressableHeap.Handle<K, HandleMap<K, V>> innerHandle1; AddressableHeap.Handle<K, HandleMap<K, V>> innerHandle2; if (c <= 0) { innerHandle1 = minHeap.insert(handle1.key); handle1.minNotMax = true; innerHandle2 = maxHeap.insert(handle2.key); handle2.minNotMax = false; } else { innerHandle1 = maxHeap.insert(handle1.key); handle1.minNotMax = false; innerHandle2 = minHeap.insert(handle2.key); handle2.minNotMax = true; } handle1.inner = innerHandle1; handle2.inner = innerHandle2; innerHandle1.setValue(new HandleMap<K, V>(handle1, innerHandle2)); innerHandle2.setValue(new HandleMap<K, V>(handle2, innerHandle1)); }
java
@SuppressWarnings("unchecked") private void insertPair(ReflectedHandle<K, V> handle1, ReflectedHandle<K, V> handle2) { int c; if (comparator == null) { c = ((Comparable<? super K>) handle1.key).compareTo(handle2.key); } else { c = comparator.compare(handle1.key, handle2.key); } AddressableHeap.Handle<K, HandleMap<K, V>> innerHandle1; AddressableHeap.Handle<K, HandleMap<K, V>> innerHandle2; if (c <= 0) { innerHandle1 = minHeap.insert(handle1.key); handle1.minNotMax = true; innerHandle2 = maxHeap.insert(handle2.key); handle2.minNotMax = false; } else { innerHandle1 = maxHeap.insert(handle1.key); handle1.minNotMax = false; innerHandle2 = minHeap.insert(handle2.key); handle2.minNotMax = true; } handle1.inner = innerHandle1; handle2.inner = innerHandle2; innerHandle1.setValue(new HandleMap<K, V>(handle1, innerHandle2)); innerHandle2.setValue(new HandleMap<K, V>(handle2, innerHandle1)); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "insertPair", "(", "ReflectedHandle", "<", "K", ",", "V", ">", "handle1", ",", "ReflectedHandle", "<", "K", ",", "V", ">", "handle2", ")", "{", "int", "c", ";", "if", "(", "comparator", "==", "null", ")", "{", "c", "=", "(", "(", "Comparable", "<", "?", "super", "K", ">", ")", "handle1", ".", "key", ")", ".", "compareTo", "(", "handle2", ".", "key", ")", ";", "}", "else", "{", "c", "=", "comparator", ".", "compare", "(", "handle1", ".", "key", ",", "handle2", ".", "key", ")", ";", "}", "AddressableHeap", ".", "Handle", "<", "K", ",", "HandleMap", "<", "K", ",", "V", ">", ">", "innerHandle1", ";", "AddressableHeap", ".", "Handle", "<", "K", ",", "HandleMap", "<", "K", ",", "V", ">", ">", "innerHandle2", ";", "if", "(", "c", "<=", "0", ")", "{", "innerHandle1", "=", "minHeap", ".", "insert", "(", "handle1", ".", "key", ")", ";", "handle1", ".", "minNotMax", "=", "true", ";", "innerHandle2", "=", "maxHeap", ".", "insert", "(", "handle2", ".", "key", ")", ";", "handle2", ".", "minNotMax", "=", "false", ";", "}", "else", "{", "innerHandle1", "=", "maxHeap", ".", "insert", "(", "handle1", ".", "key", ")", ";", "handle1", ".", "minNotMax", "=", "false", ";", "innerHandle2", "=", "minHeap", ".", "insert", "(", "handle2", ".", "key", ")", ";", "handle2", ".", "minNotMax", "=", "true", ";", "}", "handle1", ".", "inner", "=", "innerHandle1", ";", "handle2", ".", "inner", "=", "innerHandle2", ";", "innerHandle1", ".", "setValue", "(", "new", "HandleMap", "<", "K", ",", "V", ">", "(", "handle1", ",", "innerHandle2", ")", ")", ";", "innerHandle2", ".", "setValue", "(", "new", "HandleMap", "<", "K", ",", "V", ">", "(", "handle2", ",", "innerHandle1", ")", ")", ";", "}" ]
Insert a pair of elements, one in the min heap and one in the max heap. @param handle1 a handle to the first element @param handle2 a handle to the second element
[ "Insert", "a", "pair", "of", "elements", "one", "in", "the", "min", "heap", "and", "one", "in", "the", "max", "heap", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/ReflectedHeap.java#L510-L538
11,197
d-michail/jheaps
src/main/java/org/jheaps/tree/ReflectedHeap.java
ReflectedHeap.delete
private void delete(ReflectedHandle<K, V> n) { if (n.inner == null && free != n) { throw new IllegalArgumentException("Invalid handle!"); } if (free == n) { free = null; } else { // delete from inner queue AddressableHeap.Handle<K, HandleMap<K, V>> nInner = n.inner; ReflectedHandle<K, V> nOuter = nInner.getValue().outer; nInner.delete(); nOuter.inner = null; nOuter.minNotMax = false; // delete pair from inner queue AddressableHeap.Handle<K, HandleMap<K, V>> otherInner = nInner.getValue().otherInner; ReflectedHandle<K, V> otherOuter = otherInner.getValue().outer; otherInner.delete(); otherOuter.inner = null; otherOuter.minNotMax = false; // reinsert either as free or as pair with free if (free == null) { free = otherOuter; } else { insertPair(otherOuter, free); free = null; } } size--; }
java
private void delete(ReflectedHandle<K, V> n) { if (n.inner == null && free != n) { throw new IllegalArgumentException("Invalid handle!"); } if (free == n) { free = null; } else { // delete from inner queue AddressableHeap.Handle<K, HandleMap<K, V>> nInner = n.inner; ReflectedHandle<K, V> nOuter = nInner.getValue().outer; nInner.delete(); nOuter.inner = null; nOuter.minNotMax = false; // delete pair from inner queue AddressableHeap.Handle<K, HandleMap<K, V>> otherInner = nInner.getValue().otherInner; ReflectedHandle<K, V> otherOuter = otherInner.getValue().outer; otherInner.delete(); otherOuter.inner = null; otherOuter.minNotMax = false; // reinsert either as free or as pair with free if (free == null) { free = otherOuter; } else { insertPair(otherOuter, free); free = null; } } size--; }
[ "private", "void", "delete", "(", "ReflectedHandle", "<", "K", ",", "V", ">", "n", ")", "{", "if", "(", "n", ".", "inner", "==", "null", "&&", "free", "!=", "n", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid handle!\"", ")", ";", "}", "if", "(", "free", "==", "n", ")", "{", "free", "=", "null", ";", "}", "else", "{", "// delete from inner queue", "AddressableHeap", ".", "Handle", "<", "K", ",", "HandleMap", "<", "K", ",", "V", ">", ">", "nInner", "=", "n", ".", "inner", ";", "ReflectedHandle", "<", "K", ",", "V", ">", "nOuter", "=", "nInner", ".", "getValue", "(", ")", ".", "outer", ";", "nInner", ".", "delete", "(", ")", ";", "nOuter", ".", "inner", "=", "null", ";", "nOuter", ".", "minNotMax", "=", "false", ";", "// delete pair from inner queue", "AddressableHeap", ".", "Handle", "<", "K", ",", "HandleMap", "<", "K", ",", "V", ">", ">", "otherInner", "=", "nInner", ".", "getValue", "(", ")", ".", "otherInner", ";", "ReflectedHandle", "<", "K", ",", "V", ">", "otherOuter", "=", "otherInner", ".", "getValue", "(", ")", ".", "outer", ";", "otherInner", ".", "delete", "(", ")", ";", "otherOuter", ".", "inner", "=", "null", ";", "otherOuter", ".", "minNotMax", "=", "false", ";", "// reinsert either as free or as pair with free", "if", "(", "free", "==", "null", ")", "{", "free", "=", "otherOuter", ";", "}", "else", "{", "insertPair", "(", "otherOuter", ",", "free", ")", ";", "free", "=", "null", ";", "}", "}", "size", "--", ";", "}" ]
Delete an element @param n a handle to the element
[ "Delete", "an", "element" ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/ReflectedHeap.java#L546-L577
11,198
d-michail/jheaps
src/main/java/org/jheaps/tree/ReflectedHeap.java
ReflectedHeap.decreaseKey
@SuppressWarnings("unchecked") private void decreaseKey(ReflectedHandle<K, V> n, K newKey) { if (n.inner == null && free != n) { throw new IllegalArgumentException("Invalid handle!"); } int c; if (comparator == null) { c = ((Comparable<? super K>) newKey).compareTo(n.key); } else { c = comparator.compare(newKey, n.key); } if (c > 0) { throw new IllegalArgumentException("Keys can only be decreased!"); } n.key = newKey; if (c == 0 || free == n) { return; } // actual decrease AddressableHeap.Handle<K, HandleMap<K, V>> nInner = n.inner; if (n.minNotMax) { // we are in the min heap, easy case n.inner.decreaseKey(newKey); } else { // we are in the max heap, remove nInner.delete(); ReflectedHandle<K, V> nOuter = nInner.getValue().outer; nOuter.inner = null; nOuter.minNotMax = false; // remove min AddressableHeap.Handle<K, HandleMap<K, V>> minInner = nInner.getValue().otherInner; ReflectedHandle<K, V> minOuter = minInner.getValue().outer; minInner.delete(); minOuter.inner = null; minOuter.minNotMax = false; // update key nOuter.key = newKey; // reinsert both insertPair(nOuter, minOuter); } }
java
@SuppressWarnings("unchecked") private void decreaseKey(ReflectedHandle<K, V> n, K newKey) { if (n.inner == null && free != n) { throw new IllegalArgumentException("Invalid handle!"); } int c; if (comparator == null) { c = ((Comparable<? super K>) newKey).compareTo(n.key); } else { c = comparator.compare(newKey, n.key); } if (c > 0) { throw new IllegalArgumentException("Keys can only be decreased!"); } n.key = newKey; if (c == 0 || free == n) { return; } // actual decrease AddressableHeap.Handle<K, HandleMap<K, V>> nInner = n.inner; if (n.minNotMax) { // we are in the min heap, easy case n.inner.decreaseKey(newKey); } else { // we are in the max heap, remove nInner.delete(); ReflectedHandle<K, V> nOuter = nInner.getValue().outer; nOuter.inner = null; nOuter.minNotMax = false; // remove min AddressableHeap.Handle<K, HandleMap<K, V>> minInner = nInner.getValue().otherInner; ReflectedHandle<K, V> minOuter = minInner.getValue().outer; minInner.delete(); minOuter.inner = null; minOuter.minNotMax = false; // update key nOuter.key = newKey; // reinsert both insertPair(nOuter, minOuter); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "decreaseKey", "(", "ReflectedHandle", "<", "K", ",", "V", ">", "n", ",", "K", "newKey", ")", "{", "if", "(", "n", ".", "inner", "==", "null", "&&", "free", "!=", "n", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid handle!\"", ")", ";", "}", "int", "c", ";", "if", "(", "comparator", "==", "null", ")", "{", "c", "=", "(", "(", "Comparable", "<", "?", "super", "K", ">", ")", "newKey", ")", ".", "compareTo", "(", "n", ".", "key", ")", ";", "}", "else", "{", "c", "=", "comparator", ".", "compare", "(", "newKey", ",", "n", ".", "key", ")", ";", "}", "if", "(", "c", ">", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Keys can only be decreased!\"", ")", ";", "}", "n", ".", "key", "=", "newKey", ";", "if", "(", "c", "==", "0", "||", "free", "==", "n", ")", "{", "return", ";", "}", "// actual decrease", "AddressableHeap", ".", "Handle", "<", "K", ",", "HandleMap", "<", "K", ",", "V", ">", ">", "nInner", "=", "n", ".", "inner", ";", "if", "(", "n", ".", "minNotMax", ")", "{", "// we are in the min heap, easy case", "n", ".", "inner", ".", "decreaseKey", "(", "newKey", ")", ";", "}", "else", "{", "// we are in the max heap, remove", "nInner", ".", "delete", "(", ")", ";", "ReflectedHandle", "<", "K", ",", "V", ">", "nOuter", "=", "nInner", ".", "getValue", "(", ")", ".", "outer", ";", "nOuter", ".", "inner", "=", "null", ";", "nOuter", ".", "minNotMax", "=", "false", ";", "// remove min", "AddressableHeap", ".", "Handle", "<", "K", ",", "HandleMap", "<", "K", ",", "V", ">", ">", "minInner", "=", "nInner", ".", "getValue", "(", ")", ".", "otherInner", ";", "ReflectedHandle", "<", "K", ",", "V", ">", "minOuter", "=", "minInner", ".", "getValue", "(", ")", ".", "outer", ";", "minInner", ".", "delete", "(", ")", ";", "minOuter", ".", "inner", "=", "null", ";", "minOuter", ".", "minNotMax", "=", "false", ";", "// update key", "nOuter", ".", "key", "=", "newKey", ";", "// reinsert both", "insertPair", "(", "nOuter", ",", "minOuter", ")", ";", "}", "}" ]
Decrease the key of an element. @param n the element @param newKey the new key
[ "Decrease", "the", "key", "of", "an", "element", "." ]
7146451dd6591c2a8559dc564c9c40428c4a2c10
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/ReflectedHeap.java#L587-L632
11,199
ibm-bluemix-mobile-services/bms-clientsdk-android-core
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/api/Request.java
Request.send
public void send(Context context, byte[] data, ResponseListener listener) { setContext(context); super.send(data, listener); }
java
public void send(Context context, byte[] data, ResponseListener listener) { setContext(context); super.send(data, listener); }
[ "public", "void", "send", "(", "Context", "context", ",", "byte", "[", "]", "data", ",", "ResponseListener", "listener", ")", "{", "setContext", "(", "context", ")", ";", "super", ".", "send", "(", "data", ",", "listener", ")", ";", "}" ]
Send this resource request asynchronously, with the given byte array as the request body. This method does not set any Content-Type header; if such a header is required, it must be set before calling this method. @param context The context that will be passed to authentication listener. @param data The byte array to put in the request body @param listener The listener whose onSuccess or onFailure methods will be called when this request finishes
[ "Send", "this", "resource", "request", "asynchronously", "with", "the", "given", "byte", "array", "as", "the", "request", "body", ".", "This", "method", "does", "not", "set", "any", "Content", "-", "Type", "header", ";", "if", "such", "a", "header", "is", "required", "it", "must", "be", "set", "before", "calling", "this", "method", "." ]
8db4f00d0d564792397bfc0e5bd57d52a238b858
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/api/Request.java#L205-L208