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
partition
stringclasses
1 value
beders/Resty
src/main/java/us/monoid/util/EncoderUtil.java
EncoderUtil.encodeQ
public static String encodeQ(byte[] bytes, Usage usage) { BitSet qChars = usage == Usage.TEXT_TOKEN ? Q_REGULAR_CHARS : Q_RESTRICTED_CHARS; StringBuilder sb = new StringBuilder(); final int end = bytes.length; for (int idx = 0; idx < end; idx++) { int v = bytes[idx] & 0xff; if (v == 32) { sb.append(...
java
public static String encodeQ(byte[] bytes, Usage usage) { BitSet qChars = usage == Usage.TEXT_TOKEN ? Q_REGULAR_CHARS : Q_RESTRICTED_CHARS; StringBuilder sb = new StringBuilder(); final int end = bytes.length; for (int idx = 0; idx < end; idx++) { int v = bytes[idx] & 0xff; if (v == 32) { sb.append(...
[ "public", "static", "String", "encodeQ", "(", "byte", "[", "]", "bytes", ",", "Usage", "usage", ")", "{", "BitSet", "qChars", "=", "usage", "==", "Usage", ".", "TEXT_TOKEN", "?", "Q_REGULAR_CHARS", ":", "Q_RESTRICTED_CHARS", ";", "StringBuilder", "sb", "=", ...
Encodes the specified byte array using the Q encoding defined in RFC 2047. @param bytes byte array to encode. @param usage whether the encoded-word is to be used to replace a text token or a word entity (see RFC 822). @return encoded string.
[ "Encodes", "the", "specified", "byte", "array", "using", "the", "Q", "encoding", "defined", "in", "RFC", "2047", "." ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/util/EncoderUtil.java#L395-L415
train
beders/Resty
src/main/java/us/monoid/util/EncoderUtil.java
EncoderUtil.isToken
public static boolean isToken(String str) { // token := 1*<any (US-ASCII) CHAR except SPACE, CTLs, or tspecials> // tspecials := "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" / // <"> / "/" / "[" / "]" / "?" / "=" // CTL := 0.- 31., 127. final int length = str.length(); if (length == 0) return fal...
java
public static boolean isToken(String str) { // token := 1*<any (US-ASCII) CHAR except SPACE, CTLs, or tspecials> // tspecials := "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" / // <"> / "/" / "[" / "]" / "?" / "=" // CTL := 0.- 31., 127. final int length = str.length(); if (length == 0) return fal...
[ "public", "static", "boolean", "isToken", "(", "String", "str", ")", "{", "// token := 1*<any (US-ASCII) CHAR except SPACE, CTLs, or tspecials>", "// tspecials := \"(\" / \")\" / \"<\" / \">\" / \"@\" / \",\" / \";\" / \":\" / \"\\\" /", "// <\"> / \"/\" / \"[\" / \"]\" / \"?\" / \"=\"", "//...
Tests whether the specified string is a token as defined in RFC 2045 section 5.1. @param str string to test. @return <code>true</code> if the specified string is a RFC 2045 token, <code>false</code> otherwise.
[ "Tests", "whether", "the", "specified", "string", "is", "a", "token", "as", "defined", "in", "RFC", "2045", "section", "5", ".", "1", "." ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/util/EncoderUtil.java#L426-L443
train
beders/Resty
src/main/java/us/monoid/util/EncoderUtil.java
EncoderUtil.isDotAtomText
private static boolean isDotAtomText(String str) { // dot-atom-text = 1*atext *("." 1*atext) // atext = ALPHA / DIGIT / "!" / "#" / "$" / "%" / "&" / "'" / "*" / // "+" / "-" / "/" / "=" / "?" / "^" / "_" / "`" / "{" / "|" / "}" / "~" char prev = '.'; final int length = str.length(); if (length == 0) r...
java
private static boolean isDotAtomText(String str) { // dot-atom-text = 1*atext *("." 1*atext) // atext = ALPHA / DIGIT / "!" / "#" / "$" / "%" / "&" / "'" / "*" / // "+" / "-" / "/" / "=" / "?" / "^" / "_" / "`" / "{" / "|" / "}" / "~" char prev = '.'; final int length = str.length(); if (length == 0) r...
[ "private", "static", "boolean", "isDotAtomText", "(", "String", "str", ")", "{", "// dot-atom-text = 1*atext *(\".\" 1*atext)", "// atext = ALPHA / DIGIT / \"!\" / \"#\" / \"$\" / \"%\" / \"&\" / \"'\" / \"*\" /", "// \"+\" / \"-\" / \"/\" / \"=\" / \"?\" / \"^\" / \"_\" / \"`\" / \"{\" / \"|\...
RFC 5322 section 3.2.3
[ "RFC", "5322", "section", "3", ".", "2", ".", "3" ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/util/EncoderUtil.java#L464-L490
train
beders/Resty
src/main/java/us/monoid/web/Resty.java
Resty.setOptions
public Resty setOptions(Option... someOptions) { options = (someOptions == null) ? new Option[0] : someOptions; for (Option o : options) { o.init(this); } return this; }
java
public Resty setOptions(Option... someOptions) { options = (someOptions == null) ? new Option[0] : someOptions; for (Option o : options) { o.init(this); } return this; }
[ "public", "Resty", "setOptions", "(", "Option", "...", "someOptions", ")", "{", "options", "=", "(", "someOptions", "==", "null", ")", "?", "new", "Option", "[", "0", "]", ":", "someOptions", ";", "for", "(", "Option", "o", ":", "options", ")", "{", ...
Set options if you missed your opportunity in the c'tor or if you want to change the options. @param someOptions new set of options @return
[ "Set", "options", "if", "you", "missed", "your", "opportunity", "in", "the", "c", "tor", "or", "if", "you", "want", "to", "change", "the", "options", "." ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/Resty.java#L116-L122
train
beders/Resty
src/main/java/us/monoid/web/Resty.java
Resty.authenticate
public void authenticate(URI aSite, String aLogin, char[] aPwd) { rath.addSite(aSite, aLogin, aPwd); }
java
public void authenticate(URI aSite, String aLogin, char[] aPwd) { rath.addSite(aSite, aLogin, aPwd); }
[ "public", "void", "authenticate", "(", "URI", "aSite", ",", "String", "aLogin", ",", "char", "[", "]", "aPwd", ")", "{", "rath", ".", "addSite", "(", "aSite", ",", "aLogin", ",", "aPwd", ")", ";", "}" ]
Register this root URI for authentication. Whenever a URL is requested that starts with this root, the credentials given are used for HTTP AUTH. Note that currently authentication information is shared across all Resty instances. This is due to the shortcomings of the java.net authentication mechanism. This might chang...
[ "Register", "this", "root", "URI", "for", "authentication", ".", "Whenever", "a", "URL", "is", "requested", "that", "starts", "with", "this", "root", "the", "credentials", "given", "are", "used", "for", "HTTP", "AUTH", ".", "Note", "that", "currently", "auth...
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/Resty.java#L136-L138
train
beders/Resty
src/main/java/us/monoid/web/Resty.java
Resty.authenticateForRealm
public void authenticateForRealm(String realm, String aLogin, char[] charArray) { rath.addRealm(realm, aLogin, charArray); }
java
public void authenticateForRealm(String realm, String aLogin, char[] charArray) { rath.addRealm(realm, aLogin, charArray); }
[ "public", "void", "authenticateForRealm", "(", "String", "realm", ",", "String", "aLogin", ",", "char", "[", "]", "charArray", ")", "{", "rath", ".", "addRealm", "(", "realm", ",", "aLogin", ",", "charArray", ")", ";", "}" ]
Register a login password for the realm returned by the authorization challenge. Use this method instead of authenticate in case the URL is not made available to the java.net.Authenticator class @param realm the realm (see rfc2617, section 1.2) @param aLogin @param charArray
[ "Register", "a", "login", "password", "for", "the", "realm", "returned", "by", "the", "authorization", "challenge", ".", "Use", "this", "method", "instead", "of", "authenticate", "in", "case", "the", "URL", "is", "not", "made", "available", "to", "the", "jav...
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/Resty.java#L160-L162
train
beders/Resty
src/main/java/us/monoid/web/Resty.java
Resty.json
public JSONResource json(URI anUri, AbstractContent requestContent) throws IOException { return doPOSTOrPUT(anUri, requestContent, createJSONResource()); }
java
public JSONResource json(URI anUri, AbstractContent requestContent) throws IOException { return doPOSTOrPUT(anUri, requestContent, createJSONResource()); }
[ "public", "JSONResource", "json", "(", "URI", "anUri", ",", "AbstractContent", "requestContent", ")", "throws", "IOException", "{", "return", "doPOSTOrPUT", "(", "anUri", ",", "requestContent", ",", "createJSONResource", "(", ")", ")", ";", "}" ]
POST to a URI and parse the result as JSON @param anUri the URI to visit @param requestContent the content to POST to the URI @return @throws IOException if uri is wrong or no connection could be made or for 10 zillion other reasons
[ "POST", "to", "a", "URI", "and", "parse", "the", "result", "as", "JSON" ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/Resty.java#L219-L221
train
beders/Resty
src/main/java/us/monoid/web/Resty.java
Resty.xml
public XMLResource xml(URI anUri, AbstractContent requestContent) throws IOException { return doPOSTOrPUT(anUri, requestContent, createXMLResource()); }
java
public XMLResource xml(URI anUri, AbstractContent requestContent) throws IOException { return doPOSTOrPUT(anUri, requestContent, createXMLResource()); }
[ "public", "XMLResource", "xml", "(", "URI", "anUri", ",", "AbstractContent", "requestContent", ")", "throws", "IOException", "{", "return", "doPOSTOrPUT", "(", "anUri", ",", "requestContent", ",", "createXMLResource", "(", ")", ")", ";", "}" ]
POST to a URI and parse the result as XML @param anUri the URI to visit @param requestContent the content to POST to the URI @return @throws IOException if uri is wrong or no connection could be made or for 10 zillion other reasons
[ "POST", "to", "a", "URI", "and", "parse", "the", "result", "as", "XML" ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/Resty.java#L322-L324
train
beders/Resty
src/main/java/us/monoid/web/Resty.java
Resty.addAdditionalHeaders
protected void addAdditionalHeaders(URLConnection con) { for (Map.Entry<String, String> header : getAdditionalHeaders().entrySet()) { con.addRequestProperty(header.getKey(), header.getValue()); } }
java
protected void addAdditionalHeaders(URLConnection con) { for (Map.Entry<String, String> header : getAdditionalHeaders().entrySet()) { con.addRequestProperty(header.getKey(), header.getValue()); } }
[ "protected", "void", "addAdditionalHeaders", "(", "URLConnection", "con", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "header", ":", "getAdditionalHeaders", "(", ")", ".", "entrySet", "(", ")", ")", "{", "con", ".", "add...
Add all headers that have been set with the alwaysSend call.
[ "Add", "all", "headers", "that", "have", "been", "set", "with", "the", "alwaysSend", "call", "." ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/Resty.java#L405-L409
train
beders/Resty
src/main/java/us/monoid/web/Resty.java
Resty.fillResourceFromURL
protected <T extends AbstractResource> T fillResourceFromURL(URLConnection con, T resource) throws IOException { resource.fill(con); resource.getAdditionalHeaders().putAll(getAdditionalHeaders()); // carry over additional headers TODO don't do it if there are no additional headers return resource; }
java
protected <T extends AbstractResource> T fillResourceFromURL(URLConnection con, T resource) throws IOException { resource.fill(con); resource.getAdditionalHeaders().putAll(getAdditionalHeaders()); // carry over additional headers TODO don't do it if there are no additional headers return resource; }
[ "protected", "<", "T", "extends", "AbstractResource", ">", "T", "fillResourceFromURL", "(", "URLConnection", "con", ",", "T", "resource", ")", "throws", "IOException", "{", "resource", ".", "fill", "(", "con", ")", ";", "resource", ".", "getAdditionalHeaders", ...
Get the content from the URLConnection, create a Resource representing the content and carry over some metadata like HTTP Result and location header. @param <T extends AbstractResource> the resource that will be created and filled @param con the URLConnection used to get the data @param resourceClass the resource clas...
[ "Get", "the", "content", "from", "the", "URLConnection", "create", "a", "Resource", "representing", "the", "content", "and", "carry", "over", "some", "metadata", "like", "HTTP", "Result", "and", "location", "header", "." ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/Resty.java#L428-L432
train
beders/Resty
src/main/java/us/monoid/web/Resty.java
Resty.content
public static Content content(JSONObject someJson) { Content c = null; try { c = new Content("application/json; charset=UTF-8", someJson.toString().getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { /* UTF-8 is never unsupported */ } return c; }
java
public static Content content(JSONObject someJson) { Content c = null; try { c = new Content("application/json; charset=UTF-8", someJson.toString().getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { /* UTF-8 is never unsupported */ } return c; }
[ "public", "static", "Content", "content", "(", "JSONObject", "someJson", ")", "{", "Content", "c", "=", "null", ";", "try", "{", "c", "=", "new", "Content", "(", "\"application/json; charset=UTF-8\"", ",", "someJson", ".", "toString", "(", ")", ".", "getByte...
Create a content object from a JSON object. Use this to POST the content to a URL. @param someJson the JSON object to use @return the content to send
[ "Create", "a", "content", "object", "from", "a", "JSON", "object", ".", "Use", "this", "to", "POST", "the", "content", "to", "a", "URL", "." ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/Resty.java#L469-L476
train
beders/Resty
src/main/java/us/monoid/web/Resty.java
Resty.content
public static Content content(String somePlainText) { Content c = null; try { c = new Content("text/plain; charset=UTF-8", somePlainText.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { /* UTF-8 is never unsupported */ } return c; }
java
public static Content content(String somePlainText) { Content c = null; try { c = new Content("text/plain; charset=UTF-8", somePlainText.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { /* UTF-8 is never unsupported */ } return c; }
[ "public", "static", "Content", "content", "(", "String", "somePlainText", ")", "{", "Content", "c", "=", "null", ";", "try", "{", "c", "=", "new", "Content", "(", "\"text/plain; charset=UTF-8\"", ",", "somePlainText", ".", "getBytes", "(", "\"UTF-8\"", ")", ...
Create a content object from plain text. Use this to POST the content to a URL. @param somePlainText the plain text to send @return the content to send
[ "Create", "a", "content", "object", "from", "plain", "text", ".", "Use", "this", "to", "POST", "the", "content", "to", "a", "URL", "." ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/Resty.java#L501-L508
train
beders/Resty
src/main/java/us/monoid/web/Resty.java
Resty.enc
public static String enc(String unencodedString) { try { return URLEncoder.encode(unencodedString, "UTF-8"); } catch (UnsupportedEncodingException e) { } // UTF-8 is never unsupported return null; }
java
public static String enc(String unencodedString) { try { return URLEncoder.encode(unencodedString, "UTF-8"); } catch (UnsupportedEncodingException e) { } // UTF-8 is never unsupported return null; }
[ "public", "static", "String", "enc", "(", "String", "unencodedString", ")", "{", "try", "{", "return", "URLEncoder", ".", "encode", "(", "unencodedString", ",", "\"UTF-8\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "}", "//...
Shortcut to URLEncoder.encode with UTF-8. @param unencodedString the string to encode @return the URL encoded string, safe to be used in URLs
[ "Shortcut", "to", "URLEncoder", ".", "encode", "with", "UTF", "-", "8", "." ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/Resty.java#L589-L595
train
beders/Resty
src/main/java/us/monoid/web/XMLResource.java
XMLResource.doc
public Document doc() throws IOException { // if the stream has already been read, use the text format InputSource is; if (document == null) { if (text == null) { is = new InputSource(inputStream); is.setEncoding(getCharSet().name()); } else { is = new InputSource(new StringReader(text)); } ...
java
public Document doc() throws IOException { // if the stream has already been read, use the text format InputSource is; if (document == null) { if (text == null) { is = new InputSource(inputStream); is.setEncoding(getCharSet().name()); } else { is = new InputSource(new StringReader(text)); } ...
[ "public", "Document", "doc", "(", ")", "throws", "IOException", "{", "// if the stream has already been read, use the text format", "InputSource", "is", ";", "if", "(", "document", "==", "null", ")", "{", "if", "(", "text", "==", "null", ")", "{", "is", "=", "...
Return the DOM of the XML resource. @return @throws IOException
[ "Return", "the", "DOM", "of", "the", "XML", "resource", "." ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/XMLResource.java#L39-L59
train
beders/Resty
src/main/java/us/monoid/web/XMLResource.java
XMLResource.json
public JSONResource json(XPathQuery path) throws Exception { String uri = path.eval(this, String.class); return json(uri); }
java
public JSONResource json(XPathQuery path) throws Exception { String uri = path.eval(this, String.class); return json(uri); }
[ "public", "JSONResource", "json", "(", "XPathQuery", "path", ")", "throws", "Exception", "{", "String", "uri", "=", "path", ".", "eval", "(", "this", ",", "String", ".", "class", ")", ";", "return", "json", "(", "uri", ")", ";", "}" ]
Execute the given path query on the XML, GET the returned URI expecting JSON as content @param path path to the URI to follow, must be a String QName result @return a new resource, as a result of getting it from the server in JSON format @throws Exception @throws JSONException
[ "Execute", "the", "given", "path", "query", "on", "the", "XML", "GET", "the", "returned", "URI", "expecting", "JSON", "as", "content" ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/XMLResource.java#L68-L71
train
beders/Resty
src/main/java/us/monoid/web/XMLResource.java
XMLResource.xml
public XMLResource xml(XPathQuery path, Content aContent) throws Exception { String uri = path.eval(this, String.class); return xml(uri, aContent); }
java
public XMLResource xml(XPathQuery path, Content aContent) throws Exception { String uri = path.eval(this, String.class); return xml(uri, aContent); }
[ "public", "XMLResource", "xml", "(", "XPathQuery", "path", ",", "Content", "aContent", ")", "throws", "Exception", "{", "String", "uri", "=", "path", ".", "eval", "(", "this", ",", "String", ".", "class", ")", ";", "return", "xml", "(", "uri", ",", "aC...
Execute the given path query on the XML, POST the returned URI expecting XML @param path path to the URI to follow, must be a String QName result @param aContent the content to POST @return a new resource, as a result of getting it from the server in text format @throws Exception
[ "Execute", "the", "given", "path", "query", "on", "the", "XML", "POST", "the", "returned", "URI", "expecting", "XML" ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/XMLResource.java#L127-L130
train
beders/Resty
src/main/java/us/monoid/web/XMLResource.java
XMLResource.get
public NodeList get(String xPath) throws Exception { XPathQuery xp = new XPathQuery(xPath); return xp.eval(this); }
java
public NodeList get(String xPath) throws Exception { XPathQuery xp = new XPathQuery(xPath); return xp.eval(this); }
[ "public", "NodeList", "get", "(", "String", "xPath", ")", "throws", "Exception", "{", "XPathQuery", "xp", "=", "new", "XPathQuery", "(", "xPath", ")", ";", "return", "xp", ".", "eval", "(", "this", ")", ";", "}" ]
Access the XML evaluating an XPath on it, returning the resulting NodeList. @throws Exception
[ "Access", "the", "XML", "evaluating", "an", "XPath", "on", "it", "returning", "the", "resulting", "NodeList", "." ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/XMLResource.java#L135-L138
train
beders/Resty
src/main/java/us/monoid/web/XMLResource.java
XMLResource.get
public <T> T get(String xPath, Class<T> returnType) throws Exception { XPathQuery xp = new XPathQuery(xPath); return xp.eval(this, returnType); }
java
public <T> T get(String xPath, Class<T> returnType) throws Exception { XPathQuery xp = new XPathQuery(xPath); return xp.eval(this, returnType); }
[ "public", "<", "T", ">", "T", "get", "(", "String", "xPath", ",", "Class", "<", "T", ">", "returnType", ")", "throws", "Exception", "{", "XPathQuery", "xp", "=", "new", "XPathQuery", "(", "xPath", ")", ";", "return", "xp", ".", "eval", "(", "this", ...
Access the XML evaluating an XPath on it, returning the resulting Object of the desired type Supported types are NodeList, String, Boolean, Double, Node. @throws Exception
[ "Access", "the", "XML", "evaluating", "an", "XPath", "on", "it", "returning", "the", "resulting", "Object", "of", "the", "desired", "type", "Supported", "types", "are", "NodeList", "String", "Boolean", "Double", "Node", "." ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/XMLResource.java#L143-L146
train
beders/Resty
src/main/java/us/monoid/web/auth/RestyAuthenticator.java
RestyAuthenticator.addSite
public void addSite(URI aRootUrl, String login, char[] pwd) { String rootUri = aRootUrl.normalize().toString(); boolean replaced = false; // check if we already have a login/password for the root uri for (Site site : sites) { if (site.root.equals(rootUri)) { // TODO synchronisation site.login = login; ...
java
public void addSite(URI aRootUrl, String login, char[] pwd) { String rootUri = aRootUrl.normalize().toString(); boolean replaced = false; // check if we already have a login/password for the root uri for (Site site : sites) { if (site.root.equals(rootUri)) { // TODO synchronisation site.login = login; ...
[ "public", "void", "addSite", "(", "URI", "aRootUrl", ",", "String", "login", ",", "char", "[", "]", "pwd", ")", "{", "String", "rootUri", "=", "aRootUrl", ".", "normalize", "(", ")", ".", "toString", "(", ")", ";", "boolean", "replaced", "=", "false", ...
Add or replace an authentication for a root URL aka site. @param aRootUrl @param login @param pwd
[ "Add", "or", "replace", "an", "authentication", "for", "a", "root", "URL", "aka", "site", "." ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/auth/RestyAuthenticator.java#L60-L79
train
beders/Resty
src/main/java/us/monoid/web/AbstractResource.java
AbstractResource.status
public boolean status(int responseCode) { if (urlConnection instanceof HttpURLConnection) { HttpURLConnection http = (HttpURLConnection) urlConnection; try { return http.getResponseCode() == responseCode; } catch (IOException e) { e.printStackTrace(); return false; } } else return false; ...
java
public boolean status(int responseCode) { if (urlConnection instanceof HttpURLConnection) { HttpURLConnection http = (HttpURLConnection) urlConnection; try { return http.getResponseCode() == responseCode; } catch (IOException e) { e.printStackTrace(); return false; } } else return false; ...
[ "public", "boolean", "status", "(", "int", "responseCode", ")", "{", "if", "(", "urlConnection", "instanceof", "HttpURLConnection", ")", "{", "HttpURLConnection", "http", "=", "(", "HttpURLConnection", ")", "urlConnection", ";", "try", "{", "return", "http", "."...
Check if the URLConnection has returned the specified responseCode @param responseCode @return
[ "Check", "if", "the", "URLConnection", "has", "returned", "the", "specified", "responseCode" ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/AbstractResource.java#L97-L108
train
beders/Resty
src/main/java/us/monoid/web/AbstractResource.java
AbstractResource.location
public URI location() { String loc = http().getHeaderField("Location"); if (loc != null) { return URI.create(loc); } return null; }
java
public URI location() { String loc = http().getHeaderField("Location"); if (loc != null) { return URI.create(loc); } return null; }
[ "public", "URI", "location", "(", ")", "{", "String", "loc", "=", "http", "(", ")", ".", "getHeaderField", "(", "\"Location\"", ")", ";", "if", "(", "loc", "!=", "null", ")", "{", "return", "URI", ".", "create", "(", "loc", ")", ";", "}", "return",...
Get the location header as URI. Returns null if there is no location header.
[ "Get", "the", "location", "header", "as", "URI", ".", "Returns", "null", "if", "there", "is", "no", "location", "header", "." ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/AbstractResource.java#L114-L120
train
beders/Resty
src/main/java/us/monoid/web/AbstractResource.java
AbstractResource.printResponseHeaders
public String printResponseHeaders() { StringBuilder sb = new StringBuilder(); HttpURLConnection http = http(); if (http != null) { Map<String, List<String>> header = http.getHeaderFields(); for (String key : header.keySet()) { for (String val : header.get(key)) { sb.append(key).append(": ").append...
java
public String printResponseHeaders() { StringBuilder sb = new StringBuilder(); HttpURLConnection http = http(); if (http != null) { Map<String, List<String>> header = http.getHeaderFields(); for (String key : header.keySet()) { for (String val : header.get(key)) { sb.append(key).append(": ").append...
[ "public", "String", "printResponseHeaders", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "HttpURLConnection", "http", "=", "http", "(", ")", ";", "if", "(", "http", "!=", "null", ")", "{", "Map", "<", "String", ",", ...
Print out the response headers for this resource. @return
[ "Print", "out", "the", "response", "headers", "for", "this", "resource", "." ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/AbstractResource.java#L126-L138
train
beders/Resty
src/main/java/us/monoid/web/BinaryResource.java
BinaryResource.save
public File save(File aFileName) throws IOException { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(aFileName), 1024); byte[] buffer = new byte[1024]; int len = -1; while ((len = inputStream.read(buffer)) != -1) { bos.write(buffer, 0, len); } bos.close(); inputStream.close();...
java
public File save(File aFileName) throws IOException { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(aFileName), 1024); byte[] buffer = new byte[1024]; int len = -1; while ((len = inputStream.read(buffer)) != -1) { bos.write(buffer, 0, len); } bos.close(); inputStream.close();...
[ "public", "File", "save", "(", "File", "aFileName", ")", "throws", "IOException", "{", "BufferedOutputStream", "bos", "=", "new", "BufferedOutputStream", "(", "new", "FileOutputStream", "(", "aFileName", ")", ",", "1024", ")", ";", "byte", "[", "]", "buffer", ...
Save the contents of the resource to a file. This reads the data from the stream and stores it into the given file. Depending on the resource the data might or might not be available afterwards. @param aFileName file to save the data in @return the file the content was stored at @throws IOException
[ "Save", "the", "contents", "of", "the", "resource", "to", "a", "file", ".", "This", "reads", "the", "data", "from", "the", "stream", "and", "stores", "it", "into", "the", "given", "file", ".", "Depending", "on", "the", "resource", "the", "data", "might",...
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/BinaryResource.java#L39-L49
train
beders/Resty
src/main/java/us/monoid/web/TextResource.java
TextResource.getCharSet
protected Charset getCharSet() { String contentType = urlConnection.getContentType(); Charset charset = Charset.forName("iso-8859-1"); // default charset if (contentType != null) { // find out about the charset from the URLConnection Matcher m = charsetPattern.matcher(contentType); if (m.find()) { St...
java
protected Charset getCharSet() { String contentType = urlConnection.getContentType(); Charset charset = Charset.forName("iso-8859-1"); // default charset if (contentType != null) { // find out about the charset from the URLConnection Matcher m = charsetPattern.matcher(contentType); if (m.find()) { St...
[ "protected", "Charset", "getCharSet", "(", ")", "{", "String", "contentType", "=", "urlConnection", ".", "getContentType", "(", ")", ";", "Charset", "charset", "=", "Charset", ".", "forName", "(", "\"iso-8859-1\"", ")", ";", "// default charset", "if", "(", "c...
Get charset for this content type. Parses charset= attribute of content type or falls back to a default @return the charset to use when parsing this content
[ "Get", "charset", "for", "this", "content", "type", ".", "Parses", "charset", "=", "attribute", "of", "content", "type", "or", "falls", "back", "to", "a", "default" ]
4493603e9689c942cc3e53b9c5018010e414a364
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/web/TextResource.java#L70-L88
train
Bernardo-MG/dice-notation-java
src/main/java/com/bernardomg/tabletop/dice/visitor/DiceRollAccumulator.java
DiceRollAccumulator.getOperationText
private final String getOperationText(final BinaryOperation exp) { final String text; if (exp instanceof AdditionOperation) { text = " + "; } else if (exp instanceof SubtractionOperation) { text = " - "; } else if (exp instanceof MultiplicationOperation) { ...
java
private final String getOperationText(final BinaryOperation exp) { final String text; if (exp instanceof AdditionOperation) { text = " + "; } else if (exp instanceof SubtractionOperation) { text = " - "; } else if (exp instanceof MultiplicationOperation) { ...
[ "private", "final", "String", "getOperationText", "(", "final", "BinaryOperation", "exp", ")", "{", "final", "String", "text", ";", "if", "(", "exp", "instanceof", "AdditionOperation", ")", "{", "text", "=", "\" + \"", ";", "}", "else", "if", "(", "exp", "...
Returns the text value of the received operation. @param exp expression containing the operation @return text value of the operation
[ "Returns", "the", "text", "value", "of", "the", "received", "operation", "." ]
fdba6a6eb7ff35740399f2694a58514a383dad88
https://github.com/Bernardo-MG/dice-notation-java/blob/fdba6a6eb7ff35740399f2694a58514a383dad88/src/main/java/com/bernardomg/tabletop/dice/visitor/DiceRollAccumulator.java#L220-L237
train
Bernardo-MG/dice-notation-java
src/main/java/com/bernardomg/tabletop/dice/interpreter/ConfigurableInterpreter.java
ConfigurableInterpreter.process
private final V process(final Iterable<DiceNotationExpression> nodes) { accumulator.reset(); for (final DiceNotationExpression current : nodes) { if (current instanceof BinaryOperation) { accumulator.binaryOperation((BinaryOperation) current); } else if (current...
java
private final V process(final Iterable<DiceNotationExpression> nodes) { accumulator.reset(); for (final DiceNotationExpression current : nodes) { if (current instanceof BinaryOperation) { accumulator.binaryOperation((BinaryOperation) current); } else if (current...
[ "private", "final", "V", "process", "(", "final", "Iterable", "<", "DiceNotationExpression", ">", "nodes", ")", "{", "accumulator", ".", "reset", "(", ")", ";", "for", "(", "final", "DiceNotationExpression", "current", ":", "nodes", ")", "{", "if", "(", "c...
Returns the result from applying the accumulator in all the nodes. @param nodes flattened tree @return the result from applying the accumulator
[ "Returns", "the", "result", "from", "applying", "the", "accumulator", "in", "all", "the", "nodes", "." ]
fdba6a6eb7ff35740399f2694a58514a383dad88
https://github.com/Bernardo-MG/dice-notation-java/blob/fdba6a6eb7ff35740399f2694a58514a383dad88/src/main/java/com/bernardomg/tabletop/dice/interpreter/ConfigurableInterpreter.java#L101-L119
train
Bernardo-MG/dice-notation-java
src/main/java/com/bernardomg/tabletop/dice/parser/listener/DefaultDiceExpressionBuilder.java
DefaultDiceExpressionBuilder.getIntegerOperand
private final IntegerOperand getIntegerOperand(final String expression) { final Integer value; // Parses the value value = Integer.parseInt(expression); return new IntegerOperand(value); }
java
private final IntegerOperand getIntegerOperand(final String expression) { final Integer value; // Parses the value value = Integer.parseInt(expression); return new IntegerOperand(value); }
[ "private", "final", "IntegerOperand", "getIntegerOperand", "(", "final", "String", "expression", ")", "{", "final", "Integer", "value", ";", "// Parses the value", "value", "=", "Integer", ".", "parseInt", "(", "expression", ")", ";", "return", "new", "IntegerOper...
Creates an integer operand from the parsed expression. @param expression parsed expression @return an integer operand
[ "Creates", "an", "integer", "operand", "from", "the", "parsed", "expression", "." ]
fdba6a6eb7ff35740399f2694a58514a383dad88
https://github.com/Bernardo-MG/dice-notation-java/blob/fdba6a6eb7ff35740399f2694a58514a383dad88/src/main/java/com/bernardomg/tabletop/dice/parser/listener/DefaultDiceExpressionBuilder.java#L280-L287
train
Bernardo-MG/dice-notation-java
src/main/java/com/bernardomg/tabletop/dice/interpreter/PostorderTraverser.java
PostorderTraverser.unwrap
private final DiceNotationExpression unwrap(final DiceNotationExpression expression) { final DiceNotationExpression result; if (expression instanceof ExpressionWrapper) { result = ((ExpressionWrapper) expression).getWrappedExpression(); } else { result = expr...
java
private final DiceNotationExpression unwrap(final DiceNotationExpression expression) { final DiceNotationExpression result; if (expression instanceof ExpressionWrapper) { result = ((ExpressionWrapper) expression).getWrappedExpression(); } else { result = expr...
[ "private", "final", "DiceNotationExpression", "unwrap", "(", "final", "DiceNotationExpression", "expression", ")", "{", "final", "DiceNotationExpression", "result", ";", "if", "(", "expression", "instanceof", "ExpressionWrapper", ")", "{", "result", "=", "(", "(", "...
Removes the expression wrappers used to temporally prune the nodes. @param expression node to unwrap @return unwrapped node
[ "Removes", "the", "expression", "wrappers", "used", "to", "temporally", "prune", "the", "nodes", "." ]
fdba6a6eb7ff35740399f2694a58514a383dad88
https://github.com/Bernardo-MG/dice-notation-java/blob/fdba6a6eb7ff35740399f2694a58514a383dad88/src/main/java/com/bernardomg/tabletop/dice/interpreter/PostorderTraverser.java#L96-L107
train
samuelcampos/usbdrivedetector
src/main/java/net/samuelcampos/usbdrivedetector/USBDeviceDetectorManager.java
USBDeviceDetectorManager.setPollingInterval
public synchronized void setPollingInterval(final long pollingInterval) { if (pollingInterval <= 0) { throw new IllegalArgumentException("'pollingInterval' must be greater than 0"); } currentPollingInterval = pollingInterval; if (listeners.size() > 0) { stop(); ...
java
public synchronized void setPollingInterval(final long pollingInterval) { if (pollingInterval <= 0) { throw new IllegalArgumentException("'pollingInterval' must be greater than 0"); } currentPollingInterval = pollingInterval; if (listeners.size() > 0) { stop(); ...
[ "public", "synchronized", "void", "setPollingInterval", "(", "final", "long", "pollingInterval", ")", "{", "if", "(", "pollingInterval", "<=", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"'pollingInterval' must be greater than 0\"", ")", ";", "}"...
Sets the polling interval @param pollingInterval the interval in milliseconds to poll for the USB storage devices on the system.
[ "Sets", "the", "polling", "interval" ]
2f45c2a189b0ea5ba29cd4d408032f48a6b5a3bc
https://github.com/samuelcampos/usbdrivedetector/blob/2f45c2a189b0ea5ba29cd4d408032f48a6b5a3bc/src/main/java/net/samuelcampos/usbdrivedetector/USBDeviceDetectorManager.java#L82-L93
train
samuelcampos/usbdrivedetector
src/main/java/net/samuelcampos/usbdrivedetector/USBDeviceDetectorManager.java
USBDeviceDetectorManager.updateConnectedDevices
private void updateConnectedDevices(final List<USBStorageDevice> currentConnectedDevices) { final List<USBStorageDevice> removedDevices = new ArrayList<>(); synchronized (this) { final Iterator<USBStorageDevice> itConnectedDevices = connectedDevices.iterator(); while (itConnect...
java
private void updateConnectedDevices(final List<USBStorageDevice> currentConnectedDevices) { final List<USBStorageDevice> removedDevices = new ArrayList<>(); synchronized (this) { final Iterator<USBStorageDevice> itConnectedDevices = connectedDevices.iterator(); while (itConnect...
[ "private", "void", "updateConnectedDevices", "(", "final", "List", "<", "USBStorageDevice", ">", "currentConnectedDevices", ")", "{", "final", "List", "<", "USBStorageDevice", ">", "removedDevices", "=", "new", "ArrayList", "<>", "(", ")", ";", "synchronized", "("...
Updates the internal state of this manager and sends @param currentConnectedDevices a list with the currently connected USB storage devices
[ "Updates", "the", "internal", "state", "of", "this", "manager", "and", "sends" ]
2f45c2a189b0ea5ba29cd4d408032f48a6b5a3bc
https://github.com/samuelcampos/usbdrivedetector/blob/2f45c2a189b0ea5ba29cd4d408032f48a6b5a3bc/src/main/java/net/samuelcampos/usbdrivedetector/USBDeviceDetectorManager.java#L177-L203
train
morfologik/morfologik-stemming
morfologik-speller/src/main/java/morfologik/speller/Speller.java
Speller.isMisspelled
public boolean isMisspelled(final String word) { // dictionaries usually do not contain punctuation String wordToCheck = word; if (!dictionaryMetadata.getInputConversionPairs().isEmpty()) { wordToCheck = DictionaryLookup.applyReplacements(word, dictionaryMetadata.getInputConversionPairs()); }...
java
public boolean isMisspelled(final String word) { // dictionaries usually do not contain punctuation String wordToCheck = word; if (!dictionaryMetadata.getInputConversionPairs().isEmpty()) { wordToCheck = DictionaryLookup.applyReplacements(word, dictionaryMetadata.getInputConversionPairs()); }...
[ "public", "boolean", "isMisspelled", "(", "final", "String", "word", ")", "{", "// dictionaries usually do not contain punctuation\r", "String", "wordToCheck", "=", "word", ";", "if", "(", "!", "dictionaryMetadata", ".", "getInputConversionPairs", "(", ")", ".", "isEm...
Checks whether the word is misspelled, by performing a series of checks according to properties of the dictionary. If the flag <code>fsa.dict.speller.ignore-punctuation</code> is set, then all non-alphabetic characters are considered to be correctly spelled. If the flag <code>fsa.dict.speller.ignore-numbers</code> is...
[ "Checks", "whether", "the", "word", "is", "misspelled", "by", "performing", "a", "series", "of", "checks", "according", "to", "properties", "of", "the", "dictionary", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-speller/src/main/java/morfologik/speller/Speller.java#L221-L238
train
morfologik/morfologik-stemming
morfologik-speller/src/main/java/morfologik/speller/Speller.java
Speller.isInDictionary
public boolean isInDictionary(final CharSequence word) { try { byteBuffer = charSequenceToBytes(word); } catch (UnmappableInputException e) { return false; } // Try to find a partial match in the dictionary. final MatchResult match = matcher.match(matchResult, byteBuffer.array()...
java
public boolean isInDictionary(final CharSequence word) { try { byteBuffer = charSequenceToBytes(word); } catch (UnmappableInputException e) { return false; } // Try to find a partial match in the dictionary. final MatchResult match = matcher.match(matchResult, byteBuffer.array()...
[ "public", "boolean", "isInDictionary", "(", "final", "CharSequence", "word", ")", "{", "try", "{", "byteBuffer", "=", "charSequenceToBytes", "(", "word", ")", ";", "}", "catch", "(", "UnmappableInputException", "e", ")", "{", "return", "false", ";", "}", "//...
Test whether the word is found in the dictionary. @param word the word to be tested @return True if it is found.
[ "Test", "whether", "the", "word", "is", "found", "in", "the", "dictionary", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-speller/src/main/java/morfologik/speller/Speller.java#L251-L278
train
morfologik/morfologik-stemming
morfologik-speller/src/main/java/morfologik/speller/Speller.java
Speller.getFrequency
public int getFrequency(final CharSequence word) { if (!dictionaryMetadata.isFrequencyIncluded()) { return 0; } final byte separator = dictionaryMetadata.getSeparator(); try { byteBuffer = charSequenceToBytes(word); } catch (UnmappableInputException e) { return 0; } ...
java
public int getFrequency(final CharSequence word) { if (!dictionaryMetadata.isFrequencyIncluded()) { return 0; } final byte separator = dictionaryMetadata.getSeparator(); try { byteBuffer = charSequenceToBytes(word); } catch (UnmappableInputException e) { return 0; } ...
[ "public", "int", "getFrequency", "(", "final", "CharSequence", "word", ")", "{", "if", "(", "!", "dictionaryMetadata", ".", "isFrequencyIncluded", "(", ")", ")", "{", "return", "0", ";", "}", "final", "byte", "separator", "=", "dictionaryMetadata", ".", "get...
Get the frequency value for a word form. It is taken from the first entry with this word form. @param word the word to be tested @return frequency value in range: 0..FREQ_RANGE-1 (0: less frequent).
[ "Get", "the", "frequency", "value", "for", "a", "word", "form", ".", "It", "is", "taken", "from", "the", "first", "entry", "with", "this", "word", "form", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-speller/src/main/java/morfologik/speller/Speller.java#L289-L316
train
morfologik/morfologik-stemming
morfologik-speller/src/main/java/morfologik/speller/Speller.java
Speller.replaceRunOnWords
public List<String> replaceRunOnWords(final String original) { final List<String> candidates = new ArrayList<String>(); String wordToCheck = original; if (!dictionaryMetadata.getInputConversionPairs().isEmpty()) { wordToCheck = DictionaryLookup.applyReplacements(original, dictionaryMetadata.getInp...
java
public List<String> replaceRunOnWords(final String original) { final List<String> candidates = new ArrayList<String>(); String wordToCheck = original; if (!dictionaryMetadata.getInputConversionPairs().isEmpty()) { wordToCheck = DictionaryLookup.applyReplacements(original, dictionaryMetadata.getInp...
[ "public", "List", "<", "String", ">", "replaceRunOnWords", "(", "final", "String", "original", ")", "{", "final", "List", "<", "String", ">", "candidates", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "String", "wordToCheck", "=", "original"...
Propose suggestions for misspelled run-on words. This algorithm is inspired by spell.cc in s_fsa package by Jan Daciuk. @param original The original misspelled word. @return The list of suggested pairs, as space-concatenated strings.
[ "Propose", "suggestions", "for", "misspelled", "run", "-", "on", "words", ".", "This", "algorithm", "is", "inspired", "by", "spell", ".", "cc", "in", "s_fsa", "package", "by", "Jan", "Daciuk", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-speller/src/main/java/morfologik/speller/Speller.java#L326-L347
train
morfologik/morfologik-stemming
morfologik-speller/src/main/java/morfologik/speller/Speller.java
Speller.findReplacements
public ArrayList<String> findReplacements(String word) { final List<CandidateData> result = findReplacementCandidates(word); final ArrayList<String> resultSuggestions = new ArrayList<String>(result.size()); for (CandidateData cd : result) { resultSuggestions.add(cd.getWord()); } return...
java
public ArrayList<String> findReplacements(String word) { final List<CandidateData> result = findReplacementCandidates(word); final ArrayList<String> resultSuggestions = new ArrayList<String>(result.size()); for (CandidateData cd : result) { resultSuggestions.add(cd.getWord()); } return...
[ "public", "ArrayList", "<", "String", ">", "findReplacements", "(", "String", "word", ")", "{", "final", "List", "<", "CandidateData", ">", "result", "=", "findReplacementCandidates", "(", "word", ")", ";", "final", "ArrayList", "<", "String", ">", "resultSugg...
Find suggestions by using K. Oflazer's algorithm. See Jan Daciuk's s_fsa package, spell.cc for further explanation. @param word The original misspelled word. @return A list of suggested replacements.
[ "Find", "suggestions", "by", "using", "K", ".", "Oflazer", "s", "algorithm", ".", "See", "Jan", "Daciuk", "s", "s_fsa", "package", "spell", ".", "cc", "for", "further", "explanation", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-speller/src/main/java/morfologik/speller/Speller.java#L356-L364
train
morfologik/morfologik-stemming
morfologik-speller/src/main/java/morfologik/speller/Speller.java
Speller.ed
public int ed(final int i, final int j, final int wordIndex, final int candIndex) { int result; int a, b, c; if (areEqual(wordProcessed[wordIndex], candidate[candIndex])) { // last characters are the same result = hMatrix.get(i, j); } else if (wordIndex > 0 && candIndex > 0 && wordPr...
java
public int ed(final int i, final int j, final int wordIndex, final int candIndex) { int result; int a, b, c; if (areEqual(wordProcessed[wordIndex], candidate[candIndex])) { // last characters are the same result = hMatrix.get(i, j); } else if (wordIndex > 0 && candIndex > 0 && wordPr...
[ "public", "int", "ed", "(", "final", "int", "i", ",", "final", "int", "j", ",", "final", "int", "wordIndex", ",", "final", "int", "candIndex", ")", "{", "int", "result", ";", "int", "a", ",", "b", ",", "c", ";", "if", "(", "areEqual", "(", "wordP...
Calculates edit distance. @param i length of first word (here: misspelled) - 1; @param j length of second word (here: candidate) - 1. @param wordIndex (TODO: javadoc?) @param candIndex (TODO: javadoc?) @return Edit distance between the two words. Remarks: See Oflazer.
[ "Calculates", "edit", "distance", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-speller/src/main/java/morfologik/speller/Speller.java#L558-L582
train
morfologik/morfologik-stemming
morfologik-speller/src/main/java/morfologik/speller/Speller.java
Speller.areEqual
private boolean areEqual(final char x, final char y) { if (x == y) { return true; } if (dictionaryMetadata.getEquivalentChars() != null) { List<Character> chars = dictionaryMetadata.getEquivalentChars().get(x); if (chars != null && chars.contains(y)) { return true; } ...
java
private boolean areEqual(final char x, final char y) { if (x == y) { return true; } if (dictionaryMetadata.getEquivalentChars() != null) { List<Character> chars = dictionaryMetadata.getEquivalentChars().get(x); if (chars != null && chars.contains(y)) { return true; } ...
[ "private", "boolean", "areEqual", "(", "final", "char", "x", ",", "final", "char", "y", ")", "{", "if", "(", "x", "==", "y", ")", "{", "return", "true", ";", "}", "if", "(", "dictionaryMetadata", ".", "getEquivalentChars", "(", ")", "!=", "null", ")"...
by Jaume Ortola
[ "by", "Jaume", "Ortola" ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-speller/src/main/java/morfologik/speller/Speller.java#L585-L615
train
morfologik/morfologik-stemming
morfologik-speller/src/main/java/morfologik/speller/Speller.java
Speller.cuted
public int cuted(final int depth, final int wordIndex, final int candIndex) { final int l = Math.max(0, depth - effectEditDistance); // min chars from word to consider - 1 final int u = Math.min(wordLen - 1 - (wordIndex - depth), depth + effectEditDistance); // max chars from word to // consider - 1 ...
java
public int cuted(final int depth, final int wordIndex, final int candIndex) { final int l = Math.max(0, depth - effectEditDistance); // min chars from word to consider - 1 final int u = Math.min(wordLen - 1 - (wordIndex - depth), depth + effectEditDistance); // max chars from word to // consider - 1 ...
[ "public", "int", "cuted", "(", "final", "int", "depth", ",", "final", "int", "wordIndex", ",", "final", "int", "candIndex", ")", "{", "final", "int", "l", "=", "Math", ".", "max", "(", "0", ",", "depth", "-", "effectEditDistance", ")", ";", "// min cha...
Calculates cut-off edit distance. @param depth current length of candidates. @param wordIndex (TODO: javadoc?) @param candIndex (TODO: javadoc?) @return Cut-off edit distance. Remarks: See Oflazer.
[ "Calculates", "cut", "-", "off", "edit", "distance", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-speller/src/main/java/morfologik/speller/Speller.java#L626-L640
train
morfologik/morfologik-stemming
morfologik-speller/src/main/java/morfologik/speller/Speller.java
Speller.matchAnyToOne
private int matchAnyToOne(final int wordIndex, final int candIndex) { if (replacementsAnyToOne.containsKey(candidate[candIndex])) { for (final char[] rep : replacementsAnyToOne.get(candidate[candIndex])) { int i = 0; while (i < rep.length && (wordIndex + i) < wordLen && rep[i] == wordProce...
java
private int matchAnyToOne(final int wordIndex, final int candIndex) { if (replacementsAnyToOne.containsKey(candidate[candIndex])) { for (final char[] rep : replacementsAnyToOne.get(candidate[candIndex])) { int i = 0; while (i < rep.length && (wordIndex + i) < wordLen && rep[i] == wordProce...
[ "private", "int", "matchAnyToOne", "(", "final", "int", "wordIndex", ",", "final", "int", "candIndex", ")", "{", "if", "(", "replacementsAnyToOne", ".", "containsKey", "(", "candidate", "[", "candIndex", "]", ")", ")", "{", "for", "(", "final", "char", "["...
Match the last letter of the candidate against two or more letters of the word.
[ "Match", "the", "last", "letter", "of", "the", "candidate", "against", "two", "or", "more", "letters", "of", "the", "word", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-speller/src/main/java/morfologik/speller/Speller.java#L643-L656
train
morfologik/morfologik-stemming
morfologik-speller/src/main/java/morfologik/speller/Speller.java
Speller.containsNoDigit
static boolean containsNoDigit(final String s) { for (int k = 0; k < s.length(); k++) { if (Character.isDigit(s.charAt(k))) { return false; } } return true; }
java
static boolean containsNoDigit(final String s) { for (int k = 0; k < s.length(); k++) { if (Character.isDigit(s.charAt(k))) { return false; } } return true; }
[ "static", "boolean", "containsNoDigit", "(", "final", "String", "s", ")", "{", "for", "(", "int", "k", "=", "0", ";", "k", "<", "s", ".", "length", "(", ")", ";", "k", "++", ")", "{", "if", "(", "Character", ".", "isDigit", "(", "s", ".", "char...
Checks whether a string contains a digit. Used for ignoring words with numbers @param s Word to be checked. @return True if there is a digit inside the word.
[ "Checks", "whether", "a", "string", "contains", "a", "digit", ".", "Used", "for", "ignoring", "words", "with", "numbers" ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-speller/src/main/java/morfologik/speller/Speller.java#L706-L713
train
morfologik/morfologik-stemming
morfologik-speller/src/main/java/morfologik/speller/Speller.java
Speller.setWordAndCandidate
void setWordAndCandidate(final String word, final String candidate) { wordProcessed = word.toCharArray(); wordLen = wordProcessed.length; this.candidate = candidate.toCharArray(); candLen = this.candidate.length; effectEditDistance = wordLen <= editDistance ? wordLen - 1 : editDistance; }
java
void setWordAndCandidate(final String word, final String candidate) { wordProcessed = word.toCharArray(); wordLen = wordProcessed.length; this.candidate = candidate.toCharArray(); candLen = this.candidate.length; effectEditDistance = wordLen <= editDistance ? wordLen - 1 : editDistance; }
[ "void", "setWordAndCandidate", "(", "final", "String", "word", ",", "final", "String", "candidate", ")", "{", "wordProcessed", "=", "word", ".", "toCharArray", "(", ")", ";", "wordLen", "=", "wordProcessed", ".", "length", ";", "this", ".", "candidate", "=",...
Sets up the word and candidate. Used only to test the edit distance in JUnit tests. @param word the first word @param candidate the second word used for edit distance calculation
[ "Sets", "up", "the", "word", "and", "candidate", ".", "Used", "only", "to", "test", "the", "edit", "distance", "in", "JUnit", "tests", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-speller/src/main/java/morfologik/speller/Speller.java#L871-L877
train
morfologik/morfologik-stemming
morfologik-stemming/src/main/java/morfologik/stemming/BufferUtils.java
BufferUtils.sharedPrefixLength
static int sharedPrefixLength(ByteBuffer a, int aStart, ByteBuffer b, int bStart) { int i = 0; final int max = Math.min(a.remaining() - aStart, b.remaining() - bStart); aStart += a.position(); bStart += b.position(); while (i < max && a.get(aStart++) == b.get(bStart++)) { i++; } ...
java
static int sharedPrefixLength(ByteBuffer a, int aStart, ByteBuffer b, int bStart) { int i = 0; final int max = Math.min(a.remaining() - aStart, b.remaining() - bStart); aStart += a.position(); bStart += b.position(); while (i < max && a.get(aStart++) == b.get(bStart++)) { i++; } ...
[ "static", "int", "sharedPrefixLength", "(", "ByteBuffer", "a", ",", "int", "aStart", ",", "ByteBuffer", "b", ",", "int", "bStart", ")", "{", "int", "i", "=", "0", ";", "final", "int", "max", "=", "Math", ".", "min", "(", "a", ".", "remaining", "(", ...
Compute the length of the shared prefix between two byte sequences.
[ "Compute", "the", "length", "of", "the", "shared", "prefix", "between", "two", "byte", "sequences", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-stemming/src/main/java/morfologik/stemming/BufferUtils.java#L99-L108
train
morfologik/morfologik-stemming
morfologik-stemming/src/main/java/morfologik/stemming/BufferUtils.java
BufferUtils.charsToBytes
public static ByteBuffer charsToBytes(CharsetEncoder encoder, CharBuffer chars, ByteBuffer bytes) throws UnmappableInputException { assert encoder.malformedInputAction() == CodingErrorAction.REPORT; bytes = clearAndEnsureCapacity(bytes, (int) (chars.remaining() * encoder.maxBytesPerChar())); ...
java
public static ByteBuffer charsToBytes(CharsetEncoder encoder, CharBuffer chars, ByteBuffer bytes) throws UnmappableInputException { assert encoder.malformedInputAction() == CodingErrorAction.REPORT; bytes = clearAndEnsureCapacity(bytes, (int) (chars.remaining() * encoder.maxBytesPerChar())); ...
[ "public", "static", "ByteBuffer", "charsToBytes", "(", "CharsetEncoder", "encoder", ",", "CharBuffer", "chars", ",", "ByteBuffer", "bytes", ")", "throws", "UnmappableInputException", "{", "assert", "encoder", ".", "malformedInputAction", "(", ")", "==", "CodingErrorAc...
Convert chars into bytes.
[ "Convert", "chars", "into", "bytes", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-stemming/src/main/java/morfologik/stemming/BufferUtils.java#L152-L180
train
morfologik/morfologik-stemming
morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/FSABuilder.java
FSABuilder.add
public void add(byte[] sequence, int start, int len) { assert serialized != null : "Automaton already built."; assert previous == null || len == 0 || compare(previous, 0, previousLength, sequence, start, len) <= 0 : "Input must be sorted: " + Arrays.toString(Arrays.copyOf(previous, previousLength)) ...
java
public void add(byte[] sequence, int start, int len) { assert serialized != null : "Automaton already built."; assert previous == null || len == 0 || compare(previous, 0, previousLength, sequence, start, len) <= 0 : "Input must be sorted: " + Arrays.toString(Arrays.copyOf(previous, previousLength)) ...
[ "public", "void", "add", "(", "byte", "[", "]", "sequence", ",", "int", "start", ",", "int", "len", ")", "{", "assert", "serialized", "!=", "null", ":", "\"Automaton already built.\"", ";", "assert", "previous", "==", "null", "||", "len", "==", "0", "||"...
Add a single sequence of bytes to the FSA. The input must be lexicographically greater than any previously added sequence. @param sequence The array holding input sequence of bytes. @param start Starting offset (inclusive) @param len Length of the input sequence (at least 1 byte).
[ "Add", "a", "single", "sequence", "of", "bytes", "to", "the", "FSA", ".", "The", "input", "must", "be", "lexicographically", "greater", "than", "any", "previously", "added", "sequence", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/FSABuilder.java#L166-L200
train
morfologik/morfologik-stemming
morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/FSABuilder.java
FSABuilder.build
public static FSA build(byte[][] input) { final FSABuilder builder = new FSABuilder(); for (byte[] chs : input) { builder.add(chs, 0, chs.length); } return builder.complete(); }
java
public static FSA build(byte[][] input) { final FSABuilder builder = new FSABuilder(); for (byte[] chs : input) { builder.add(chs, 0, chs.length); } return builder.complete(); }
[ "public", "static", "FSA", "build", "(", "byte", "[", "]", "[", "]", "input", ")", "{", "final", "FSABuilder", "builder", "=", "new", "FSABuilder", "(", ")", ";", "for", "(", "byte", "[", "]", "chs", ":", "input", ")", "{", "builder", ".", "add", ...
Build a minimal, deterministic automaton from a sorted list of byte sequences. @param input Input sequences to build automaton from. @return Returns the automaton encoding all input sequences.
[ "Build", "a", "minimal", "deterministic", "automaton", "from", "a", "sorted", "list", "of", "byte", "sequences", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/FSABuilder.java#L243-L251
train
morfologik/morfologik-stemming
morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/FSABuilder.java
FSABuilder.getArcTarget
private int getArcTarget(int arc) { arc += ADDRESS_OFFSET; return (serialized[arc] ) << 24 | (serialized[arc + 1] & 0xff) << 16 | (serialized[arc + 2] & 0xff) << 8 | (serialized[arc + 3] & 0xff); }
java
private int getArcTarget(int arc) { arc += ADDRESS_OFFSET; return (serialized[arc] ) << 24 | (serialized[arc + 1] & 0xff) << 16 | (serialized[arc + 2] & 0xff) << 8 | (serialized[arc + 3] & 0xff); }
[ "private", "int", "getArcTarget", "(", "int", "arc", ")", "{", "arc", "+=", "ADDRESS_OFFSET", ";", "return", "(", "serialized", "[", "arc", "]", ")", "<<", "24", "|", "(", "serialized", "[", "arc", "+", "1", "]", "&", "0xff", ")", "<<", "16", "|", ...
Returns the address of an arc.
[ "Returns", "the", "address", "of", "an", "arc", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/FSABuilder.java#L307-L313
train
morfologik/morfologik-stemming
morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/FSABuilder.java
FSABuilder.expandAndRehash
private void expandAndRehash() { final int[] newHashSet = new int[hashSet.length * 2]; final int bucketMask = (newHashSet.length - 1); for (int j = 0; j < hashSet.length; j++) { final int state = hashSet[j]; if (state > 0) { int slot = hash(state, stateLength(state)) & bucketMask; ...
java
private void expandAndRehash() { final int[] newHashSet = new int[hashSet.length * 2]; final int bucketMask = (newHashSet.length - 1); for (int j = 0; j < hashSet.length; j++) { final int state = hashSet[j]; if (state > 0) { int slot = hash(state, stateLength(state)) & bucketMask; ...
[ "private", "void", "expandAndRehash", "(", ")", "{", "final", "int", "[", "]", "newHashSet", "=", "new", "int", "[", "hashSet", ".", "length", "*", "2", "]", ";", "final", "int", "bucketMask", "=", "(", "newHashSet", ".", "length", "-", "1", ")", ";"...
Reallocate and rehash the hash set.
[ "Reallocate", "and", "rehash", "the", "hash", "set", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/FSABuilder.java#L366-L381
train
morfologik/morfologik-stemming
morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/FSABuilder.java
FSABuilder.serialize
private int serialize(final int activePathIndex) { expandBuffers(); final int newState = size; final int start = activePath[activePathIndex]; final int len = nextArcOffset[activePathIndex] - start; System.arraycopy(serialized, start, serialized, newState, len); size += len; return newState...
java
private int serialize(final int activePathIndex) { expandBuffers(); final int newState = size; final int start = activePath[activePathIndex]; final int len = nextArcOffset[activePathIndex] - start; System.arraycopy(serialized, start, serialized, newState, len); size += len; return newState...
[ "private", "int", "serialize", "(", "final", "int", "activePathIndex", ")", "{", "expandBuffers", "(", ")", ";", "final", "int", "newState", "=", "size", ";", "final", "int", "start", "=", "activePath", "[", "activePathIndex", "]", ";", "final", "int", "le...
Serialize a given state on the active path.
[ "Serialize", "a", "given", "state", "on", "the", "active", "path", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/FSABuilder.java#L412-L422
train
morfologik/morfologik-stemming
morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/FSABuilder.java
FSABuilder.expandActivePath
private void expandActivePath(int size) { if (activePath.length < size) { final int p = activePath.length; activePath = java.util.Arrays.copyOf(activePath, size); nextArcOffset = java.util.Arrays.copyOf(nextArcOffset, size); for (int i = p; i < size; i++) { nextArcOffset[i] = active...
java
private void expandActivePath(int size) { if (activePath.length < size) { final int p = activePath.length; activePath = java.util.Arrays.copyOf(activePath, size); nextArcOffset = java.util.Arrays.copyOf(nextArcOffset, size); for (int i = p; i < size; i++) { nextArcOffset[i] = active...
[ "private", "void", "expandActivePath", "(", "int", "size", ")", "{", "if", "(", "activePath", ".", "length", "<", "size", ")", "{", "final", "int", "p", "=", "activePath", ".", "length", ";", "activePath", "=", "java", ".", "util", ".", "Arrays", ".", ...
Append a new mutable state to the active path.
[ "Append", "a", "new", "mutable", "state", "to", "the", "active", "path", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/FSABuilder.java#L444-L454
train
morfologik/morfologik-stemming
morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/FSABuilder.java
FSABuilder.expandBuffers
private void expandBuffers() { if (this.serialized.length < size + ARC_SIZE * MAX_LABELS) { serialized = java.util.Arrays.copyOf(serialized, serialized.length + bufferGrowthSize); serializationBufferReallocations++; } }
java
private void expandBuffers() { if (this.serialized.length < size + ARC_SIZE * MAX_LABELS) { serialized = java.util.Arrays.copyOf(serialized, serialized.length + bufferGrowthSize); serializationBufferReallocations++; } }
[ "private", "void", "expandBuffers", "(", ")", "{", "if", "(", "this", ".", "serialized", ".", "length", "<", "size", "+", "ARC_SIZE", "*", "MAX_LABELS", ")", "{", "serialized", "=", "java", ".", "util", ".", "Arrays", ".", "copyOf", "(", "serialized", ...
Expand internal buffers for the next state.
[ "Expand", "internal", "buffers", "for", "the", "next", "state", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/FSABuilder.java#L459-L464
train
morfologik/morfologik-stemming
morfologik-stemming/src/main/java/morfologik/stemming/DictionaryLookup.java
DictionaryLookup.applyReplacements
public static String applyReplacements(CharSequence word, LinkedHashMap<String, String> replacements) { // quite horrible from performance point of view; this should really be a transducer. StringBuilder sb = new StringBuilder(word); for (final Map.Entry<String, String> e : replacements.entrySet()) { ...
java
public static String applyReplacements(CharSequence word, LinkedHashMap<String, String> replacements) { // quite horrible from performance point of view; this should really be a transducer. StringBuilder sb = new StringBuilder(word); for (final Map.Entry<String, String> e : replacements.entrySet()) { ...
[ "public", "static", "String", "applyReplacements", "(", "CharSequence", "word", ",", "LinkedHashMap", "<", "String", ",", "String", ">", "replacements", ")", "{", "// quite horrible from performance point of view; this should really be a transducer.\r", "StringBuilder", "sb", ...
Apply partial string replacements from a given map. Useful if the word needs to be normalized somehow (i.e., ligatures, apostrophes and such). @param word The word to apply replacements to. @param replacements A map of replacements (from-&gt;to). @return new string with all replacements applied.
[ "Apply", "partial", "string", "replacements", "from", "a", "given", "map", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-stemming/src/main/java/morfologik/stemming/DictionaryLookup.java#L259-L271
train
morfologik/morfologik-stemming
morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/CFSA2Serializer.java
CFSA2Serializer.computeLabelsIndex
private void computeLabelsIndex(final FSA fsa) { // Compute labels count. final int[] countByValue = new int[256]; fsa.visitAllStates(new StateVisitor() { public boolean accept(int state) { for (int arc = fsa.getFirstArc(state); arc != 0; arc = fsa.getNextArc(arc)) countByVal...
java
private void computeLabelsIndex(final FSA fsa) { // Compute labels count. final int[] countByValue = new int[256]; fsa.visitAllStates(new StateVisitor() { public boolean accept(int state) { for (int arc = fsa.getFirstArc(state); arc != 0; arc = fsa.getNextArc(arc)) countByVal...
[ "private", "void", "computeLabelsIndex", "(", "final", "FSA", "fsa", ")", "{", "// Compute labels count.\r", "final", "int", "[", "]", "countByValue", "=", "new", "int", "[", "256", "]", ";", "fsa", ".", "visitAllStates", "(", "new", "StateVisitor", "(", ")"...
Compute a set of labels to be integrated with the flags field.
[ "Compute", "a", "set", "of", "labels", "to", "be", "integrated", "with", "the", "flags", "field", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/CFSA2Serializer.java#L158-L196
train
morfologik/morfologik-stemming
morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/CFSA2Serializer.java
CFSA2Serializer.linearizeState
private void linearizeState(final FSA fsa, IntStack nodes, IntArrayList linearized, BitSet visited, int node) { linearized.add(node); visited.set(node); for (int arc = fsa.getFirstArc(node); arc != 0; arc = fsa.getNextArc(arc)) { if (!fsa.isArcTerminal(arc)) { final int target = fsa.getEn...
java
private void linearizeState(final FSA fsa, IntStack nodes, IntArrayList linearized, BitSet visited, int node) { linearized.add(node); visited.set(node); for (int arc = fsa.getFirstArc(node); arc != 0; arc = fsa.getNextArc(arc)) { if (!fsa.isArcTerminal(arc)) { final int target = fsa.getEn...
[ "private", "void", "linearizeState", "(", "final", "FSA", "fsa", ",", "IntStack", "nodes", ",", "IntArrayList", "linearized", ",", "BitSet", "visited", ",", "int", "node", ")", "{", "linearized", ".", "add", "(", "node", ")", ";", "visited", ".", "set", ...
Add a state to linearized list.
[ "Add", "a", "state", "to", "linearized", "list", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/CFSA2Serializer.java#L319-L329
train
morfologik/morfologik-stemming
morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/CFSA2Serializer.java
CFSA2Serializer.computeFirstStates
private int[] computeFirstStates(IntIntHashMap inlinkCount, int maxStates, int minInlinkCount) { Comparator<IntIntHolder> comparator = new Comparator<FSAUtils.IntIntHolder>() { public int compare(IntIntHolder o1, IntIntHolder o2) { int v = o1.a - o2.a; return v == 0 ? (o1.b - o2.b) : v; ...
java
private int[] computeFirstStates(IntIntHashMap inlinkCount, int maxStates, int minInlinkCount) { Comparator<IntIntHolder> comparator = new Comparator<FSAUtils.IntIntHolder>() { public int compare(IntIntHolder o1, IntIntHolder o2) { int v = o1.a - o2.a; return v == 0 ? (o1.b - o2.b) : v; ...
[ "private", "int", "[", "]", "computeFirstStates", "(", "IntIntHashMap", "inlinkCount", ",", "int", "maxStates", ",", "int", "minInlinkCount", ")", "{", "Comparator", "<", "IntIntHolder", ">", "comparator", "=", "new", "Comparator", "<", "FSAUtils", ".", "IntIntH...
Compute the set of states that should be linearized first to minimize other states goto length.
[ "Compute", "the", "set", "of", "states", "that", "should", "be", "linearized", "first", "to", "minimize", "other", "states", "goto", "length", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/CFSA2Serializer.java#L335-L366
train
morfologik/morfologik-stemming
morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/CFSA2Serializer.java
CFSA2Serializer.computeInlinkCount
private IntIntHashMap computeInlinkCount(final FSA fsa) { IntIntHashMap inlinkCount = new IntIntHashMap(); BitSet visited = new BitSet(); IntStack nodes = new IntStack(); nodes.push(fsa.getRootNode()); while (!nodes.isEmpty()) { final int node = nodes.pop(); if (visited.get(node...
java
private IntIntHashMap computeInlinkCount(final FSA fsa) { IntIntHashMap inlinkCount = new IntIntHashMap(); BitSet visited = new BitSet(); IntStack nodes = new IntStack(); nodes.push(fsa.getRootNode()); while (!nodes.isEmpty()) { final int node = nodes.pop(); if (visited.get(node...
[ "private", "IntIntHashMap", "computeInlinkCount", "(", "final", "FSA", "fsa", ")", "{", "IntIntHashMap", "inlinkCount", "=", "new", "IntIntHashMap", "(", ")", ";", "BitSet", "visited", "=", "new", "BitSet", "(", ")", ";", "IntStack", "nodes", "=", "new", "In...
Compute in-link count for each state.
[ "Compute", "in", "-", "link", "count", "for", "each", "state", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/CFSA2Serializer.java#L371-L395
train
morfologik/morfologik-stemming
morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/CFSA2Serializer.java
CFSA2Serializer.emitNodeArcs
private int emitNodeArcs(FSA fsa, OutputStream os, final int state, final int nextState) throws IOException { int offset = 0; for (int arc = fsa.getFirstArc(state); arc != 0; arc = fsa.getNextArc(arc)) { int targetOffset; final int target; if (fsa.isArcTerminal(arc)) { target =...
java
private int emitNodeArcs(FSA fsa, OutputStream os, final int state, final int nextState) throws IOException { int offset = 0; for (int arc = fsa.getFirstArc(state); arc != 0; arc = fsa.getNextArc(arc)) { int targetOffset; final int target; if (fsa.isArcTerminal(arc)) { target =...
[ "private", "int", "emitNodeArcs", "(", "FSA", "fsa", ",", "OutputStream", "os", ",", "final", "int", "state", ",", "final", "int", "nextState", ")", "throws", "IOException", "{", "int", "offset", "=", "0", ";", "for", "(", "int", "arc", "=", "fsa", "."...
Emit all arcs of a single node.
[ "Emit", "all", "arcs", "of", "a", "single", "node", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/CFSA2Serializer.java#L433-L466
train
morfologik/morfologik-stemming
morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/CFSA2Serializer.java
CFSA2Serializer.writeVInt
static int writeVInt(byte[] array, int offset, int value) { assert value >= 0 : "Can't v-code negative ints."; while (value > 0x7F) { array[offset++] = (byte) (0x80 | (value & 0x7F)); value >>= 7; } array[offset++] = (byte) value; return offset; }
java
static int writeVInt(byte[] array, int offset, int value) { assert value >= 0 : "Can't v-code negative ints."; while (value > 0x7F) { array[offset++] = (byte) (0x80 | (value & 0x7F)); value >>= 7; } array[offset++] = (byte) value; return offset; }
[ "static", "int", "writeVInt", "(", "byte", "[", "]", "array", ",", "int", "offset", ",", "int", "value", ")", "{", "assert", "value", ">=", "0", ":", "\"Can't v-code negative ints.\"", ";", "while", "(", "value", ">", "0x7F", ")", "{", "array", "[", "o...
Write a v-int to a byte array.
[ "Write", "a", "v", "-", "int", "to", "a", "byte", "array", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/CFSA2Serializer.java#L525-L535
train
morfologik/morfologik-stemming
morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/FSAUtils.java
FSAUtils.rightLanguageForAllStates
public static IntIntHashMap rightLanguageForAllStates(final FSA fsa) { final IntIntHashMap numbers = new IntIntHashMap(); fsa.visitInPostOrder(new StateVisitor() { public boolean accept(int state) { int thisNodeNumber = 0; for (int arc = fsa.getFirstArc(state); arc != 0; arc = fsa.g...
java
public static IntIntHashMap rightLanguageForAllStates(final FSA fsa) { final IntIntHashMap numbers = new IntIntHashMap(); fsa.visitInPostOrder(new StateVisitor() { public boolean accept(int state) { int thisNodeNumber = 0; for (int arc = fsa.getFirstArc(state); arc != 0; arc = fsa.g...
[ "public", "static", "IntIntHashMap", "rightLanguageForAllStates", "(", "final", "FSA", "fsa", ")", "{", "final", "IntIntHashMap", "numbers", "=", "new", "IntIntHashMap", "(", ")", ";", "fsa", ".", "visitInPostOrder", "(", "new", "StateVisitor", "(", ")", "{", ...
Calculate the size of "right language" for each state in an FSA. The right language is the number of sequences encoded from a given node in the automaton. @param fsa The automaton to calculate right language for. @return Returns a map with node identifiers as keys and their right language counts as associated values.
[ "Calculate", "the", "size", "of", "right", "language", "for", "each", "state", "in", "an", "FSA", ".", "The", "right", "language", "is", "the", "number", "of", "sequences", "encoded", "from", "a", "given", "node", "in", "the", "automaton", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa-builders/src/main/java/morfologik/fsa/builders/FSAUtils.java#L177-L194
train
morfologik/morfologik-stemming
morfologik-fsa/src/main/java/morfologik/fsa/CFSA2.java
CFSA2.readVInt
static int readVInt(byte[] array, int offset) { byte b = array[offset]; int value = b & 0x7F; for (int shift = 7; b < 0; shift += 7) { b = array[++offset]; value |= (b & 0x7F) << shift; } return value; }
java
static int readVInt(byte[] array, int offset) { byte b = array[offset]; int value = b & 0x7F; for (int shift = 7; b < 0; shift += 7) { b = array[++offset]; value |= (b & 0x7F) << shift; } return value; }
[ "static", "int", "readVInt", "(", "byte", "[", "]", "array", ",", "int", "offset", ")", "{", "byte", "b", "=", "array", "[", "offset", "]", ";", "int", "value", "=", "b", "&", "0x7F", ";", "for", "(", "int", "shift", "=", "7", ";", "b", "<", ...
Read a v-int.
[ "Read", "a", "v", "-", "int", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa/src/main/java/morfologik/fsa/CFSA2.java#L353-L363
train
morfologik/morfologik-stemming
morfologik-stemming/src/main/java/morfologik/stemming/Dictionary.java
Dictionary.read
public static Dictionary read(Path location) throws IOException { final Path metadata = DictionaryMetadata.getExpectedMetadataLocation(location); try (InputStream fsaStream = Files.newInputStream(location); InputStream metadataStream = Files.newInputStream(metadata)) { return read(fsaStream...
java
public static Dictionary read(Path location) throws IOException { final Path metadata = DictionaryMetadata.getExpectedMetadataLocation(location); try (InputStream fsaStream = Files.newInputStream(location); InputStream metadataStream = Files.newInputStream(metadata)) { return read(fsaStream...
[ "public", "static", "Dictionary", "read", "(", "Path", "location", ")", "throws", "IOException", "{", "final", "Path", "metadata", "=", "DictionaryMetadata", ".", "getExpectedMetadataLocation", "(", "location", ")", ";", "try", "(", "InputStream", "fsaStream", "="...
Attempts to load a dictionary using the path to the FSA file and the expected metadata extension. @param location The location of the dictionary file (<code>*.dict</code>). @return An instantiated dictionary. @throws IOException if an I/O error occurs.
[ "Attempts", "to", "load", "a", "dictionary", "using", "the", "path", "to", "the", "FSA", "file", "and", "the", "expected", "metadata", "extension", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-stemming/src/main/java/morfologik/stemming/Dictionary.java#L60-L67
train
morfologik/morfologik-stemming
morfologik-stemming/src/main/java/morfologik/stemming/Dictionary.java
Dictionary.read
public static Dictionary read(URL dictURL) throws IOException { final URL expectedMetadataURL; try { String external = dictURL.toExternalForm(); expectedMetadataURL = new URL(DictionaryMetadata.getExpectedMetadataFileName(external)); } catch (MalformedURLException e) { throw new IOEx...
java
public static Dictionary read(URL dictURL) throws IOException { final URL expectedMetadataURL; try { String external = dictURL.toExternalForm(); expectedMetadataURL = new URL(DictionaryMetadata.getExpectedMetadataFileName(external)); } catch (MalformedURLException e) { throw new IOEx...
[ "public", "static", "Dictionary", "read", "(", "URL", "dictURL", ")", "throws", "IOException", "{", "final", "URL", "expectedMetadataURL", ";", "try", "{", "String", "external", "=", "dictURL", ".", "toExternalForm", "(", ")", ";", "expectedMetadataURL", "=", ...
Attempts to load a dictionary using the URL to the FSA file and the expected metadata extension. @param dictURL The URL pointing to the dictionary file (<code>*.dict</code>). @return An instantiated dictionary. @throws IOException if an I/O error occurs.
[ "Attempts", "to", "load", "a", "dictionary", "using", "the", "URL", "to", "the", "FSA", "file", "and", "the", "expected", "metadata", "extension", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-stemming/src/main/java/morfologik/stemming/Dictionary.java#L77-L90
train
morfologik/morfologik-stemming
morfologik-stemming/src/main/java/morfologik/stemming/Dictionary.java
Dictionary.read
public static Dictionary read(InputStream fsaStream, InputStream metadataStream) throws IOException { return new Dictionary(FSA.read(fsaStream), DictionaryMetadata.read(metadataStream)); }
java
public static Dictionary read(InputStream fsaStream, InputStream metadataStream) throws IOException { return new Dictionary(FSA.read(fsaStream), DictionaryMetadata.read(metadataStream)); }
[ "public", "static", "Dictionary", "read", "(", "InputStream", "fsaStream", ",", "InputStream", "metadataStream", ")", "throws", "IOException", "{", "return", "new", "Dictionary", "(", "FSA", ".", "read", "(", "fsaStream", ")", ",", "DictionaryMetadata", ".", "re...
Attempts to load a dictionary from opened streams of FSA dictionary data and associated metadata. Input streams are not closed automatically. @param fsaStream The stream with FSA data @param metadataStream The stream with metadata @return Returns an instantiated {@link Dictionary}. @throws IOException if an I/O error ...
[ "Attempts", "to", "load", "a", "dictionary", "from", "opened", "streams", "of", "FSA", "dictionary", "data", "and", "associated", "metadata", ".", "Input", "streams", "are", "not", "closed", "automatically", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-stemming/src/main/java/morfologik/stemming/Dictionary.java#L101-L103
train
morfologik/morfologik-stemming
morfologik-speller/src/main/java/morfologik/speller/HMatrix.java
HMatrix.set
public void set(final int i, final int j, final int val) { p[(j - i + editDistance + 1) * rowLength + j] = val; }
java
public void set(final int i, final int j, final int val) { p[(j - i + editDistance + 1) * rowLength + j] = val; }
[ "public", "void", "set", "(", "final", "int", "i", ",", "final", "int", "j", ",", "final", "int", "val", ")", "{", "p", "[", "(", "j", "-", "i", "+", "editDistance", "+", "1", ")", "*", "rowLength", "+", "j", "]", "=", "val", ";", "}" ]
Set an item in hMatrix. No checking for i &amp; j is done. They must be correct. @param i - (int) row number; @param j - (int) column number; @param val - (int) value to put there.
[ "Set", "an", "item", "in", "hMatrix", ".", "No", "checking", "for", "i", "&amp", ";", "j", "is", "done", ".", "They", "must", "be", "correct", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-speller/src/main/java/morfologik/speller/HMatrix.java#L94-L96
train
morfologik/morfologik-stemming
morfologik-fsa/src/main/java/morfologik/fsa/ByteSequenceIterator.java
ByteSequenceIterator.advance
private final ByteBuffer advance() { if (position == 0) { return null; } while (position > 0) { final int lastIndex = position - 1; final int arc = arcs[lastIndex]; if (arc == 0) { // Remove the current node from the queue. position--; continue; ...
java
private final ByteBuffer advance() { if (position == 0) { return null; } while (position > 0) { final int lastIndex = position - 1; final int arc = arcs[lastIndex]; if (arc == 0) { // Remove the current node from the queue. position--; continue; ...
[ "private", "final", "ByteBuffer", "advance", "(", ")", "{", "if", "(", "position", "==", "0", ")", "{", "return", "null", ";", "}", "while", "(", "position", ">", "0", ")", "{", "final", "int", "lastIndex", "=", "position", "-", "1", ";", "final", ...
Advances to the next available final state.
[ "Advances", "to", "the", "next", "available", "final", "state", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa/src/main/java/morfologik/fsa/ByteSequenceIterator.java#L107-L147
train
morfologik/morfologik-stemming
morfologik-fsa/src/main/java/morfologik/fsa/ByteSequenceIterator.java
ByteSequenceIterator.pushNode
private void pushNode(int node) { // Expand buffers if needed. if (position == arcs.length) { arcs = Arrays.copyOf(arcs, arcs.length + EXPECTED_MAX_STATES); } arcs[position++] = fsa.getFirstArc(node); }
java
private void pushNode(int node) { // Expand buffers if needed. if (position == arcs.length) { arcs = Arrays.copyOf(arcs, arcs.length + EXPECTED_MAX_STATES); } arcs[position++] = fsa.getFirstArc(node); }
[ "private", "void", "pushNode", "(", "int", "node", ")", "{", "// Expand buffers if needed.\r", "if", "(", "position", "==", "arcs", ".", "length", ")", "{", "arcs", "=", "Arrays", ".", "copyOf", "(", "arcs", ",", "arcs", ".", "length", "+", "EXPECTED_MAX_S...
Descends to a given node, adds its arcs to the stack to be traversed.
[ "Descends", "to", "a", "given", "node", "adds", "its", "arcs", "to", "the", "stack", "to", "be", "traversed", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa/src/main/java/morfologik/fsa/ByteSequenceIterator.java#L160-L167
train
morfologik/morfologik-stemming
morfologik-fsa/src/main/java/morfologik/fsa/FSAHeader.java
FSAHeader.read
public static FSAHeader read(InputStream in) throws IOException { if (in.read() != ((FSA_MAGIC >>> 24) ) || in.read() != ((FSA_MAGIC >>> 16) & 0xff) || in.read() != ((FSA_MAGIC >>> 8) & 0xff) || in.read() != ((FSA_MAGIC ) & 0xff)) { throw new IOException("Invalid file head...
java
public static FSAHeader read(InputStream in) throws IOException { if (in.read() != ((FSA_MAGIC >>> 24) ) || in.read() != ((FSA_MAGIC >>> 16) & 0xff) || in.read() != ((FSA_MAGIC >>> 8) & 0xff) || in.read() != ((FSA_MAGIC ) & 0xff)) { throw new IOException("Invalid file head...
[ "public", "static", "FSAHeader", "read", "(", "InputStream", "in", ")", "throws", "IOException", "{", "if", "(", "in", ".", "read", "(", ")", "!=", "(", "(", "FSA_MAGIC", ">>>", "24", ")", ")", "||", "in", ".", "read", "(", ")", "!=", "(", "(", "...
Read FSA header and version from a stream, consuming read bytes. @param in The input stream to read data from. @return Returns a valid {@link FSAHeader} with version information. @throws IOException If the stream ends prematurely or if it contains invalid data.
[ "Read", "FSA", "header", "and", "version", "from", "a", "stream", "consuming", "read", "bytes", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa/src/main/java/morfologik/fsa/FSAHeader.java#L40-L54
train
morfologik/morfologik-stemming
morfologik-fsa/src/main/java/morfologik/fsa/FSAHeader.java
FSAHeader.write
public static void write(OutputStream os, byte version) throws IOException { os.write(FSA_MAGIC >> 24); os.write(FSA_MAGIC >> 16); os.write(FSA_MAGIC >> 8); os.write(FSA_MAGIC); os.write(version); }
java
public static void write(OutputStream os, byte version) throws IOException { os.write(FSA_MAGIC >> 24); os.write(FSA_MAGIC >> 16); os.write(FSA_MAGIC >> 8); os.write(FSA_MAGIC); os.write(version); }
[ "public", "static", "void", "write", "(", "OutputStream", "os", ",", "byte", "version", ")", "throws", "IOException", "{", "os", ".", "write", "(", "FSA_MAGIC", ">>", "24", ")", ";", "os", ".", "write", "(", "FSA_MAGIC", ">>", "16", ")", ";", "os", "...
Writes FSA magic bytes and version information. @param os The stream to write to. @param version Automaton version. @throws IOException Rethrown if writing fails.
[ "Writes", "FSA", "magic", "bytes", "and", "version", "information", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa/src/main/java/morfologik/fsa/FSAHeader.java#L63-L69
train
morfologik/morfologik-stemming
morfologik-fsa/src/main/java/morfologik/fsa/FSA5.java
FSA5.decodeFromBytes
static final int decodeFromBytes(final byte[] arcs, final int start, final int n) { int r = 0; for (int i = n; --i >= 0;) { r = r << 8 | (arcs[start + i] & 0xff); } return r; }
java
static final int decodeFromBytes(final byte[] arcs, final int start, final int n) { int r = 0; for (int i = n; --i >= 0;) { r = r << 8 | (arcs[start + i] & 0xff); } return r; }
[ "static", "final", "int", "decodeFromBytes", "(", "final", "byte", "[", "]", "arcs", ",", "final", "int", "start", ",", "final", "int", "n", ")", "{", "int", "r", "=", "0", ";", "for", "(", "int", "i", "=", "n", ";", "--", "i", ">=", "0", ";", ...
Returns an n-byte integer encoded in byte-packed representation.
[ "Returns", "an", "n", "-", "byte", "integer", "encoded", "in", "byte", "-", "packed", "representation", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa/src/main/java/morfologik/fsa/FSA5.java#L289-L295
train
morfologik/morfologik-stemming
morfologik-tools/src/main/java/morfologik/tools/CliTool.java
CliTool.main
protected static void main(String[] args, CliTool... commands) { if (commands.length == 1) { main(args, commands[0]); } else { JCommander jc = new JCommander(); for (CliTool command : commands) { jc.addCommand(command); } jc.addConverterFactory(new CustomParameterCo...
java
protected static void main(String[] args, CliTool... commands) { if (commands.length == 1) { main(args, commands[0]); } else { JCommander jc = new JCommander(); for (CliTool command : commands) { jc.addCommand(command); } jc.addConverterFactory(new CustomParameterCo...
[ "protected", "static", "void", "main", "(", "String", "[", "]", "args", ",", "CliTool", "...", "commands", ")", "{", "if", "(", "commands", ".", "length", "==", "1", ")", "{", "main", "(", "args", ",", "commands", "[", "0", "]", ")", ";", "}", "e...
Parse and execute one of the commands. @param args Command line arguments (command and options). @param commands A list of commands.
[ "Parse", "and", "execute", "one", "of", "the", "commands", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-tools/src/main/java/morfologik/tools/CliTool.java#L57-L114
train
morfologik/morfologik-stemming
morfologik-tools/src/main/java/morfologik/tools/CliTool.java
CliTool.main
protected static void main(String[] args, CliTool command) { JCommander jc = new JCommander(command); jc.addConverterFactory(new CustomParameterConverters()); jc.setProgramName(command.getClass().getAnnotation(Parameters.class).commandNames()[0]); ExitStatus exitStatus = ExitStatus.SUCCESS; t...
java
protected static void main(String[] args, CliTool command) { JCommander jc = new JCommander(command); jc.addConverterFactory(new CustomParameterConverters()); jc.setProgramName(command.getClass().getAnnotation(Parameters.class).commandNames()[0]); ExitStatus exitStatus = ExitStatus.SUCCESS; t...
[ "protected", "static", "void", "main", "(", "String", "[", "]", "args", ",", "CliTool", "command", ")", "{", "JCommander", "jc", "=", "new", "JCommander", "(", "command", ")", ";", "jc", ".", "addConverterFactory", "(", "new", "CustomParameterConverters", "(...
Parse and execute a single command. @param args Command line arguments (command and options). @param command The command to execute.
[ "Parse", "and", "execute", "a", "single", "command", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-tools/src/main/java/morfologik/tools/CliTool.java#L122-L165
train
morfologik/morfologik-stemming
morfologik-tools/src/main/java/morfologik/tools/FSAInfo.java
FSAInfo.byteAsChar
static String byteAsChar(byte v) { int chr = v & 0xff; return String.format(Locale.ROOT, "%s (0x%02x)", (Character.isWhitespace(chr) || chr > 127) ? "[non-printable]" : Character.toString((char) chr), v & 0xFF); }
java
static String byteAsChar(byte v) { int chr = v & 0xff; return String.format(Locale.ROOT, "%s (0x%02x)", (Character.isWhitespace(chr) || chr > 127) ? "[non-printable]" : Character.toString((char) chr), v & 0xFF); }
[ "static", "String", "byteAsChar", "(", "byte", "v", ")", "{", "int", "chr", "=", "v", "&", "0xff", ";", "return", "String", ".", "format", "(", "Locale", ".", "ROOT", ",", "\"%s (0x%02x)\"", ",", "(", "Character", ".", "isWhitespace", "(", "chr", ")", ...
Convert a byte to an informative string.
[ "Convert", "a", "byte", "to", "an", "informative", "string", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-tools/src/main/java/morfologik/tools/FSAInfo.java#L87-L93
train
morfologik/morfologik-stemming
morfologik-fsa/src/main/java/morfologik/fsa/FSA.java
FSA.read
public static FSA read(InputStream stream) throws IOException { final FSAHeader header = FSAHeader.read(stream); switch (header.version) { case FSA5.VERSION: return new FSA5(stream); case CFSA.VERSION: return new CFSA(stream); case CFSA2.VERSION: return new CF...
java
public static FSA read(InputStream stream) throws IOException { final FSAHeader header = FSAHeader.read(stream); switch (header.version) { case FSA5.VERSION: return new FSA5(stream); case CFSA.VERSION: return new CFSA(stream); case CFSA2.VERSION: return new CF...
[ "public", "static", "FSA", "read", "(", "InputStream", "stream", ")", "throws", "IOException", "{", "final", "FSAHeader", "header", "=", "FSAHeader", ".", "read", "(", "stream", ")", ";", "switch", "(", "header", ".", "version", ")", "{", "case", "FSA5", ...
A factory for reading automata in any of the supported versions. @param stream The input stream to read automaton data from. The stream is not closed. @return Returns an instantiated automaton. Never null. @throws IOException If the input stream does not represent an automaton or is otherwise invalid.
[ "A", "factory", "for", "reading", "automata", "in", "any", "of", "the", "supported", "versions", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa/src/main/java/morfologik/fsa/FSA.java#L311-L325
train
morfologik/morfologik-stemming
morfologik-fsa/src/main/java/morfologik/fsa/FSA.java
FSA.read
public static <T extends FSA> T read(InputStream stream, Class<? extends T> clazz) throws IOException { FSA fsa = read(stream); if (!clazz.isInstance(fsa)) { throw new IOException(String.format(Locale.ROOT, "Expected FSA type %s, but read an incompatible type %s.", clazz.getName(), fsa.getCl...
java
public static <T extends FSA> T read(InputStream stream, Class<? extends T> clazz) throws IOException { FSA fsa = read(stream); if (!clazz.isInstance(fsa)) { throw new IOException(String.format(Locale.ROOT, "Expected FSA type %s, but read an incompatible type %s.", clazz.getName(), fsa.getCl...
[ "public", "static", "<", "T", "extends", "FSA", ">", "T", "read", "(", "InputStream", "stream", ",", "Class", "<", "?", "extends", "T", ">", "clazz", ")", "throws", "IOException", "{", "FSA", "fsa", "=", "read", "(", "stream", ")", ";", "if", "(", ...
A factory for reading a specific FSA subclass, including proper casting. @param stream The input stream to read automaton data from. The stream is not closed. @param clazz A subclass of {@link FSA} to cast the read automaton to. @param <T> A subclass of {@link FSA} to cast the read automaton to. @return Returns an ins...
[ "A", "factory", "for", "reading", "a", "specific", "FSA", "subclass", "including", "proper", "casting", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa/src/main/java/morfologik/fsa/FSA.java#L341-L348
train
morfologik/morfologik-stemming
morfologik-tools/src/main/java/morfologik/tools/BinaryInput.java
BinaryInput.forAllLines
private static int forAllLines(InputStream is, byte separator, LineConsumer lineConsumer) throws IOException { int lines = 0; byte[] buffer = new byte[0]; int b, pos = 0; while ((b = is.read()) != -1) { if (b == separator) { buffer = lineConsumer.process(buffer, pos); pos = ...
java
private static int forAllLines(InputStream is, byte separator, LineConsumer lineConsumer) throws IOException { int lines = 0; byte[] buffer = new byte[0]; int b, pos = 0; while ((b = is.read()) != -1) { if (b == separator) { buffer = lineConsumer.process(buffer, pos); pos = ...
[ "private", "static", "int", "forAllLines", "(", "InputStream", "is", ",", "byte", "separator", ",", "LineConsumer", "lineConsumer", ")", "throws", "IOException", "{", "int", "lines", "=", "0", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "0", ...
Read all byte-separated sequences.
[ "Read", "all", "byte", "-", "separated", "sequences", "." ]
9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e
https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-tools/src/main/java/morfologik/tools/BinaryInput.java#L105-L127
train
kohsuke/jcifs
src/jcifs/http/NtlmSsp.java
NtlmSsp.authenticate
public static NtlmPasswordAuthentication authenticate( HttpServletRequest req, HttpServletResponse resp, byte[] challenge) throws IOException, ServletException { String msg = req.getHeader("Authorization"); if (msg != null && msg.startsWith("NTLM ")) { by...
java
public static NtlmPasswordAuthentication authenticate( HttpServletRequest req, HttpServletResponse resp, byte[] challenge) throws IOException, ServletException { String msg = req.getHeader("Authorization"); if (msg != null && msg.startsWith("NTLM ")) { by...
[ "public", "static", "NtlmPasswordAuthentication", "authenticate", "(", "HttpServletRequest", "req", ",", "HttpServletResponse", "resp", ",", "byte", "[", "]", "challenge", ")", "throws", "IOException", ",", "ServletException", "{", "String", "msg", "=", "req", ".", ...
Performs NTLM authentication for the servlet request. @param req The request being serviced. @param resp The response. @param challenge The domain controller challenge. @throws IOException If an IO error occurs. @throws ServletException If an error occurs.
[ "Performs", "NTLM", "authentication", "for", "the", "servlet", "request", "." ]
7751f4e4826c35614d237a70c2582553f95b58de
https://github.com/kohsuke/jcifs/blob/7751f4e4826c35614d237a70c2582553f95b58de/src/jcifs/http/NtlmSsp.java#L81-L108
train
kohsuke/jcifs
src/jcifs/smb/SigningDigest.java
SigningDigest.verify
boolean verify(byte[] data, int offset, ServerMessageBlock response) { update(macSigningKey, 0, macSigningKey.length); int index = offset; update(data, index, ServerMessageBlock.SIGNATURE_OFFSET); index += ServerMessageBlock.SIGNATURE_OFFSET; byte[] sequence = new byte[8]; ...
java
boolean verify(byte[] data, int offset, ServerMessageBlock response) { update(macSigningKey, 0, macSigningKey.length); int index = offset; update(data, index, ServerMessageBlock.SIGNATURE_OFFSET); index += ServerMessageBlock.SIGNATURE_OFFSET; byte[] sequence = new byte[8]; ...
[ "boolean", "verify", "(", "byte", "[", "]", "data", ",", "int", "offset", ",", "ServerMessageBlock", "response", ")", "{", "update", "(", "macSigningKey", ",", "0", ",", "macSigningKey", ".", "length", ")", ";", "int", "index", "=", "offset", ";", "updat...
Performs MAC signature verification. This calculates the signature of the SMB and compares it to the signature field on the SMB itself. @param data The data. @param offset The starting offset at which the SMB header begins. @param length The length of the SMB data starting at offset.
[ "Performs", "MAC", "signature", "verification", ".", "This", "calculates", "the", "signature", "of", "the", "SMB", "and", "compares", "it", "to", "the", "signature", "field", "on", "the", "SMB", "itself", "." ]
7751f4e4826c35614d237a70c2582553f95b58de
https://github.com/kohsuke/jcifs/blob/7751f4e4826c35614d237a70c2582553f95b58de/src/jcifs/smb/SigningDigest.java#L158-L191
train
kohsuke/jcifs
src/jcifs/util/Base64.java
Base64.encode
public static String encode(byte[] bytes) { int length = bytes.length; if (length == 0) return ""; StringBuffer buffer = new StringBuffer((int) Math.ceil((double) length / 3d) * 4); int remainder = length % 3; length -= remainder; int block; ...
java
public static String encode(byte[] bytes) { int length = bytes.length; if (length == 0) return ""; StringBuffer buffer = new StringBuffer((int) Math.ceil((double) length / 3d) * 4); int remainder = length % 3; length -= remainder; int block; ...
[ "public", "static", "String", "encode", "(", "byte", "[", "]", "bytes", ")", "{", "int", "length", "=", "bytes", ".", "length", ";", "if", "(", "length", "==", "0", ")", "return", "\"\"", ";", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ...
Base-64 encodes the supplied block of data. Line wrapping is not applied on output. @param bytes The block of data that is to be Base-64 encoded. @return A <code>String</code> containing the encoded data.
[ "Base", "-", "64", "encodes", "the", "supplied", "block", "of", "data", ".", "Line", "wrapping", "is", "not", "applied", "on", "output", "." ]
7751f4e4826c35614d237a70c2582553f95b58de
https://github.com/kohsuke/jcifs/blob/7751f4e4826c35614d237a70c2582553f95b58de/src/jcifs/util/Base64.java#L33-L64
train
kohsuke/jcifs
src/jcifs/util/Base64.java
Base64.decode
public static byte[] decode(String string) { int length = string.length(); if (length == 0) return new byte[0]; int pad = (string.charAt(length - 2) == '=') ? 2 : (string.charAt(length - 1) == '=') ? 1 : 0; int size = length * 3 / 4 - pad; byte[] buffer = ne...
java
public static byte[] decode(String string) { int length = string.length(); if (length == 0) return new byte[0]; int pad = (string.charAt(length - 2) == '=') ? 2 : (string.charAt(length - 1) == '=') ? 1 : 0; int size = length * 3 / 4 - pad; byte[] buffer = ne...
[ "public", "static", "byte", "[", "]", "decode", "(", "String", "string", ")", "{", "int", "length", "=", "string", ".", "length", "(", ")", ";", "if", "(", "length", "==", "0", ")", "return", "new", "byte", "[", "0", "]", ";", "int", "pad", "=", ...
Decodes the supplied Base-64 encoded string. @param string The Base-64 encoded string that is to be decoded. @return A <code>byte[]</code> containing the decoded data block.
[ "Decodes", "the", "supplied", "Base", "-", "64", "encoded", "string", "." ]
7751f4e4826c35614d237a70c2582553f95b58de
https://github.com/kohsuke/jcifs/blob/7751f4e4826c35614d237a70c2582553f95b58de/src/jcifs/util/Base64.java#L72-L92
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/types/Post.java
Post.reblog
public Post reblog(String blogName, Map<String, ?> options) { return client.postReblog(blogName, id, reblog_key, options); }
java
public Post reblog(String blogName, Map<String, ?> options) { return client.postReblog(blogName, id, reblog_key, options); }
[ "public", "Post", "reblog", "(", "String", "blogName", ",", "Map", "<", "String", ",", "?", ">", "options", ")", "{", "return", "client", ".", "postReblog", "(", "blogName", ",", "id", ",", "reblog_key", ",", "options", ")", ";", "}" ]
Reblog this post @param blogName the blog name to reblog onto @param options options to reblog with (or null) @return reblogged post
[ "Reblog", "this", "post" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/types/Post.java#L307-L309
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/types/Post.java
Post.setDate
public void setDate(Date date) { DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); df.setTimeZone(TimeZone.getTimeZone("GMT")); setDate(df.format(date)); }
java
public void setDate(Date date) { DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); df.setTimeZone(TimeZone.getTimeZone("GMT")); setDate(df.format(date)); }
[ "public", "void", "setDate", "(", "Date", "date", ")", "{", "DateFormat", "df", "=", "new", "SimpleDateFormat", "(", "\"yyyy/MM/dd HH:mm:ss\"", ")", ";", "df", ".", "setTimeZone", "(", "TimeZone", ".", "getTimeZone", "(", "\"GMT\"", ")", ")", ";", "setDate",...
Set the date as a date @param date the date to set
[ "Set", "the", "date", "as", "a", "date" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/types/Post.java#L373-L377
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/types/Post.java
Post.addTag
public void addTag(String tag) { if (this.tags == null) { tags = new ArrayList<String>(); } this.tags.add(tag); }
java
public void addTag(String tag) { if (this.tags == null) { tags = new ArrayList<String>(); } this.tags.add(tag); }
[ "public", "void", "addTag", "(", "String", "tag", ")", "{", "if", "(", "this", ".", "tags", "==", "null", ")", "{", "tags", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "}", "this", ".", "tags", ".", "add", "(", "tag", ")", ";", ...
Add a tag @param tag the tag
[ "Add", "a", "tag" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/types/Post.java#L400-L405
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/types/Post.java
Post.save
public void save() throws IOException { if (id == null) { this.id = client.postCreate(blog_name, detail()); } else { client.postEdit(blog_name, id, detail()); } }
java
public void save() throws IOException { if (id == null) { this.id = client.postCreate(blog_name, detail()); } else { client.postEdit(blog_name, id, detail()); } }
[ "public", "void", "save", "(", ")", "throws", "IOException", "{", "if", "(", "id", "==", "null", ")", "{", "this", ".", "id", "=", "client", ".", "postCreate", "(", "blog_name", ",", "detail", "(", ")", ")", ";", "}", "else", "{", "client", ".", ...
Save this post @throws IOException if a file in detail cannot be read
[ "Save", "this", "post" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/types/Post.java#L419-L425
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/types/Post.java
Post.detail
protected Map<String, Object> detail() { final Map<String, Object> map = new HashMap<String, Object>(); map.put("state", state); map.put("tags", getTagString()); map.put("format", format); map.put("slug", slug); map.put("date", date); map.put("type", getType().get...
java
protected Map<String, Object> detail() { final Map<String, Object> map = new HashMap<String, Object>(); map.put("state", state); map.put("tags", getTagString()); map.put("format", format); map.put("slug", slug); map.put("date", date); map.put("type", getType().get...
[ "protected", "Map", "<", "String", ",", "Object", ">", "detail", "(", ")", "{", "final", "Map", "<", "String", ",", "Object", ">", "map", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "map", ".", "put", "(", "\"state\"", ...
Detail for this post @return the detail
[ "Detail", "for", "this", "post" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/types/Post.java#L431-L440
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/types/PhotoPost.java
PhotoPost.setPhoto
public void setPhoto(Photo photo) { PhotoType type = photo.getType(); if (postType != null && !postType.equals(type)) { throw new IllegalArgumentException("Photos must all be the same type (source or data)"); } else if (postType == PhotoType.SOURCE && pendingPhotos.size() > 0) { ...
java
public void setPhoto(Photo photo) { PhotoType type = photo.getType(); if (postType != null && !postType.equals(type)) { throw new IllegalArgumentException("Photos must all be the same type (source or data)"); } else if (postType == PhotoType.SOURCE && pendingPhotos.size() > 0) { ...
[ "public", "void", "setPhoto", "(", "Photo", "photo", ")", "{", "PhotoType", "type", "=", "photo", ".", "getType", "(", ")", ";", "if", "(", "postType", "!=", "null", "&&", "!", "postType", ".", "equals", "(", "type", ")", ")", "{", "throw", "new", ...
Set the photo for this post @param photo the photo to add
[ "Set", "the", "photo", "for", "this", "post" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/types/PhotoPost.java#L77-L87
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/types/User.java
User.getBlogs
public List<Blog> getBlogs() { if (blogs != null) { for (Blog blog : blogs) { blog.setClient(client); } } return this.blogs; }
java
public List<Blog> getBlogs() { if (blogs != null) { for (Blog blog : blogs) { blog.setClient(client); } } return this.blogs; }
[ "public", "List", "<", "Blog", ">", "getBlogs", "(", ")", "{", "if", "(", "blogs", "!=", "null", ")", "{", "for", "(", "Blog", "blog", ":", "blogs", ")", "{", "blog", ".", "setClient", "(", "client", ")", ";", "}", "}", "return", "this", ".", "...
Get the blog List for this user @return The blog List for this user
[ "Get", "the", "blog", "List", "for", "this", "user" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/types/User.java#L61-L68
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/exceptions/JumblrException.java
JumblrException.extractErrors
private void extractErrors(JsonObject object) { JsonObject response; try { response = object.getAsJsonObject("response"); } catch (ClassCastException ex) { return; // response is non-object } if (response == null) { return; } JsonArray e = respons...
java
private void extractErrors(JsonObject object) { JsonObject response; try { response = object.getAsJsonObject("response"); } catch (ClassCastException ex) { return; // response is non-object } if (response == null) { return; } JsonArray e = respons...
[ "private", "void", "extractErrors", "(", "JsonObject", "object", ")", "{", "JsonObject", "response", ";", "try", "{", "response", "=", "object", ".", "getAsJsonObject", "(", "\"response\"", ")", ";", "}", "catch", "(", "ClassCastException", "ex", ")", "{", "...
Pull the errors out of the response if present @param object the parsed response object
[ "Pull", "the", "errors", "out", "of", "the", "response", "if", "present" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/exceptions/JumblrException.java#L74-L91
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/exceptions/JumblrException.java
JumblrException.extractMessage
private void extractMessage(JsonObject object) { // Prefer to pull the message out of meta JsonObject meta = object.getAsJsonObject("meta"); if (meta != null) { JsonPrimitive msg = meta.getAsJsonPrimitive("msg"); if (msg != null) { this.message = msg.getAs...
java
private void extractMessage(JsonObject object) { // Prefer to pull the message out of meta JsonObject meta = object.getAsJsonObject("meta"); if (meta != null) { JsonPrimitive msg = meta.getAsJsonPrimitive("msg"); if (msg != null) { this.message = msg.getAs...
[ "private", "void", "extractMessage", "(", "JsonObject", "object", ")", "{", "// Prefer to pull the message out of meta", "JsonObject", "meta", "=", "object", ".", "getAsJsonObject", "(", "\"meta\"", ")", ";", "if", "(", "meta", "!=", "null", ")", "{", "JsonPrimiti...
Pull the message out of the response @param object the parsed response object
[ "Pull", "the", "message", "out", "of", "the", "response" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/exceptions/JumblrException.java#L97-L117
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/JumblrClient.java
JumblrClient.xauth
public void xauth(final String email, final String password) { setToken(this.requestBuilder.postXAuth(email, password)); }
java
public void xauth(final String email, final String password) { setToken(this.requestBuilder.postXAuth(email, password)); }
[ "public", "void", "xauth", "(", "final", "String", "email", ",", "final", "String", "password", ")", "{", "setToken", "(", "this", ".", "requestBuilder", ".", "postXAuth", "(", "email", ",", "password", ")", ")", ";", "}" ]
Performs an XAuth authentication. @param email the user's login email. @param password the user's login password.
[ "Performs", "an", "XAuth", "authentication", "." ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/JumblrClient.java#L75-L77
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/JumblrClient.java
JumblrClient.userDashboard
public List<Post> userDashboard(Map<String, ?> options) { return requestBuilder.get("/user/dashboard", options).getPosts(); }
java
public List<Post> userDashboard(Map<String, ?> options) { return requestBuilder.get("/user/dashboard", options).getPosts(); }
[ "public", "List", "<", "Post", ">", "userDashboard", "(", "Map", "<", "String", ",", "?", ">", "options", ")", "{", "return", "requestBuilder", ".", "get", "(", "\"/user/dashboard\"", ",", "options", ")", ".", "getPosts", "(", ")", ";", "}" ]
Get the user dashboard for the authenticated User @param options the options for the call (or null) @return A List of posts
[ "Get", "the", "user", "dashboard", "for", "the", "authenticated", "User" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/JumblrClient.java#L92-L94
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/JumblrClient.java
JumblrClient.userFollowing
public List<Blog> userFollowing(Map<String, ?> options) { return requestBuilder.get("/user/following", options).getBlogs(); }
java
public List<Blog> userFollowing(Map<String, ?> options) { return requestBuilder.get("/user/following", options).getBlogs(); }
[ "public", "List", "<", "Blog", ">", "userFollowing", "(", "Map", "<", "String", ",", "?", ">", "options", ")", "{", "return", "requestBuilder", ".", "get", "(", "\"/user/following\"", ",", "options", ")", ".", "getBlogs", "(", ")", ";", "}" ]
Get the blogs the given user is following @param options the options @return a List of blogs
[ "Get", "the", "blogs", "the", "given", "user", "is", "following" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/JumblrClient.java#L105-L107
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/JumblrClient.java
JumblrClient.blogInfo
public Blog blogInfo(String blogName) { Map<String, String> map = new HashMap<String, String>(); map.put("api_key", this.apiKey); return requestBuilder.get(JumblrClient.blogPath(blogName, "/info"), map).getBlog(); }
java
public Blog blogInfo(String blogName) { Map<String, String> map = new HashMap<String, String>(); map.put("api_key", this.apiKey); return requestBuilder.get(JumblrClient.blogPath(blogName, "/info"), map).getBlog(); }
[ "public", "Blog", "blogInfo", "(", "String", "blogName", ")", "{", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "map", ".", "put", "(", "\"api_key\"", ",", "this", ".", "a...
Get the blog info for a given blog @param blogName the Name of the blog @return The Blog object for this blog
[ "Get", "the", "blog", "info", "for", "a", "given", "blog" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/JumblrClient.java#L136-L140
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/JumblrClient.java
JumblrClient.blogFollowers
public List<User> blogFollowers(String blogName, Map<String, ?> options) { return requestBuilder.get(JumblrClient.blogPath(blogName, "/followers"), options).getUsers(); }
java
public List<User> blogFollowers(String blogName, Map<String, ?> options) { return requestBuilder.get(JumblrClient.blogPath(blogName, "/followers"), options).getUsers(); }
[ "public", "List", "<", "User", ">", "blogFollowers", "(", "String", "blogName", ",", "Map", "<", "String", ",", "?", ">", "options", ")", "{", "return", "requestBuilder", ".", "get", "(", "JumblrClient", ".", "blogPath", "(", "blogName", ",", "\"/followers...
Get the followers for a given blog @param blogName the name of the blog @param options the options for this call (or null) @return the blog object for this blog
[ "Get", "the", "followers", "for", "a", "given", "blog" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/JumblrClient.java#L148-L150
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/JumblrClient.java
JumblrClient.blogLikes
public List<Post> blogLikes(String blogName, Map<String, ?> options) { if (options == null) { options = Collections.emptyMap(); } Map<String, Object> soptions = JumblrClient.safeOptionMap(options); soptions.put("api_key", this.apiKey); return requestBuilder.get(Jumblr...
java
public List<Post> blogLikes(String blogName, Map<String, ?> options) { if (options == null) { options = Collections.emptyMap(); } Map<String, Object> soptions = JumblrClient.safeOptionMap(options); soptions.put("api_key", this.apiKey); return requestBuilder.get(Jumblr...
[ "public", "List", "<", "Post", ">", "blogLikes", "(", "String", "blogName", ",", "Map", "<", "String", ",", "?", ">", "options", ")", "{", "if", "(", "options", "==", "null", ")", "{", "options", "=", "Collections", ".", "emptyMap", "(", ")", ";", ...
Get the public likes for a given blog @param blogName the name of the blog @param options the options for this call (or null) @return a List of posts
[ "Get", "the", "public", "likes", "for", "a", "given", "blog" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/JumblrClient.java#L160-L167
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/JumblrClient.java
JumblrClient.blogPosts
public List<Post> blogPosts(String blogName, Map<String, ?> options) { if (options == null) { options = Collections.emptyMap(); } Map<String, Object> soptions = JumblrClient.safeOptionMap(options); soptions.put("api_key", apiKey); String path = "/posts"; if (...
java
public List<Post> blogPosts(String blogName, Map<String, ?> options) { if (options == null) { options = Collections.emptyMap(); } Map<String, Object> soptions = JumblrClient.safeOptionMap(options); soptions.put("api_key", apiKey); String path = "/posts"; if (...
[ "public", "List", "<", "Post", ">", "blogPosts", "(", "String", "blogName", ",", "Map", "<", "String", ",", "?", ">", "options", ")", "{", "if", "(", "options", "==", "null", ")", "{", "options", "=", "Collections", ".", "emptyMap", "(", ")", ";", ...
Get the posts for a given blog @param blogName the name of the blog @param options the options for this call (or null) @return a List of posts
[ "Get", "the", "posts", "for", "a", "given", "blog" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/JumblrClient.java#L179-L192
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/JumblrClient.java
JumblrClient.blogPost
public Post blogPost(String blogName, Long postId) { HashMap<String, String> options = new HashMap<String, String>(); options.put("id", postId.toString()); List<Post> posts = this.blogPosts(blogName, options); return posts.size() > 0 ? posts.get(0) : null; }
java
public Post blogPost(String blogName, Long postId) { HashMap<String, String> options = new HashMap<String, String>(); options.put("id", postId.toString()); List<Post> posts = this.blogPosts(blogName, options); return posts.size() > 0 ? posts.get(0) : null; }
[ "public", "Post", "blogPost", "(", "String", "blogName", ",", "Long", "postId", ")", "{", "HashMap", "<", "String", ",", "String", ">", "options", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "options", ".", "put", "(", "\...
Get an individual post by id @param blogName the name of the blog @param postId the id of the post to get @return the Post or null
[ "Get", "an", "individual", "post", "by", "id" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/JumblrClient.java#L204-L209
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/JumblrClient.java
JumblrClient.blogQueuedPosts
public List<Post> blogQueuedPosts(String blogName, Map<String, ?> options) { return requestBuilder.get(JumblrClient.blogPath(blogName, "/posts/queue"), options).getPosts(); }
java
public List<Post> blogQueuedPosts(String blogName, Map<String, ?> options) { return requestBuilder.get(JumblrClient.blogPath(blogName, "/posts/queue"), options).getPosts(); }
[ "public", "List", "<", "Post", ">", "blogQueuedPosts", "(", "String", "blogName", ",", "Map", "<", "String", ",", "?", ">", "options", ")", "{", "return", "requestBuilder", ".", "get", "(", "JumblrClient", ".", "blogPath", "(", "blogName", ",", "\"/posts/q...
Get the queued posts for a given blog @param blogName the name of the blog @param options the options for this call (or null) @return a List of posts
[ "Get", "the", "queued", "posts", "for", "a", "given", "blog" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/JumblrClient.java#L217-L219
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/JumblrClient.java
JumblrClient.userLikes
public List<Post> userLikes(Map<String, ?> options) { return requestBuilder.get("/user/likes", options).getLikedPosts(); }
java
public List<Post> userLikes(Map<String, ?> options) { return requestBuilder.get("/user/likes", options).getLikedPosts(); }
[ "public", "List", "<", "Post", ">", "userLikes", "(", "Map", "<", "String", ",", "?", ">", "options", ")", "{", "return", "requestBuilder", ".", "get", "(", "\"/user/likes\"", ",", "options", ")", ".", "getLikedPosts", "(", ")", ";", "}" ]
Get the likes for the authenticated user @param options the options for this call (or null) @return a List of posts
[ "Get", "the", "likes", "for", "the", "authenticated", "user" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/JumblrClient.java#L258-L260
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/JumblrClient.java
JumblrClient.blogAvatar
public String blogAvatar(String blogName, Integer size) { String pathExt = size == null ? "" : "/" + size.toString(); return requestBuilder.getRedirectUrl(JumblrClient.blogPath(blogName, "/avatar" + pathExt)); }
java
public String blogAvatar(String blogName, Integer size) { String pathExt = size == null ? "" : "/" + size.toString(); return requestBuilder.getRedirectUrl(JumblrClient.blogPath(blogName, "/avatar" + pathExt)); }
[ "public", "String", "blogAvatar", "(", "String", "blogName", ",", "Integer", "size", ")", "{", "String", "pathExt", "=", "size", "==", "null", "?", "\"\"", ":", "\"/\"", "+", "size", ".", "toString", "(", ")", ";", "return", "requestBuilder", ".", "getRe...
Get a specific size avatar for a given blog @param blogName the avatar URL of the blog @param size The size requested @return a string representing the URL of the avatar
[ "Get", "a", "specific", "size", "avatar", "for", "a", "given", "blog" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/JumblrClient.java#L272-L275
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/JumblrClient.java
JumblrClient.like
public void like(Long postId, String reblogKey) { Map<String, String> map = new HashMap<String, String>(); map.put("id", postId.toString()); map.put("reblog_key", reblogKey); requestBuilder.post("/user/like", map); }
java
public void like(Long postId, String reblogKey) { Map<String, String> map = new HashMap<String, String>(); map.put("id", postId.toString()); map.put("reblog_key", reblogKey); requestBuilder.post("/user/like", map); }
[ "public", "void", "like", "(", "Long", "postId", ",", "String", "reblogKey", ")", "{", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "map", ".", "put", "(", "\"id\"", ",", ...
Like a given post @param postId the ID of the post to like @param reblogKey The reblog key for the post
[ "Like", "a", "given", "post" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/JumblrClient.java#L284-L289
train
tumblr/jumblr
src/main/java/com/tumblr/jumblr/JumblrClient.java
JumblrClient.follow
public void follow(String blogName) { Map<String, String> map = new HashMap<String, String>(); map.put("url", JumblrClient.blogUrl(blogName)); requestBuilder.post("/user/follow", map); }
java
public void follow(String blogName) { Map<String, String> map = new HashMap<String, String>(); map.put("url", JumblrClient.blogUrl(blogName)); requestBuilder.post("/user/follow", map); }
[ "public", "void", "follow", "(", "String", "blogName", ")", "{", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "map", ".", "put", "(", "\"url\"", ",", "JumblrClient", ".", ...
Follow a given blog @param blogName The name of the blog to follow
[ "Follow", "a", "given", "blog" ]
373629fd545defb016e227ea758f092507fbd624
https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/JumblrClient.java#L307-L311
train