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
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/api/Query.java
Query.getAllpages
@XmlElementWrapper(name = "allpages") @XmlElement(name = "p", type = P.class) public List<P> getAllpages() { return allpages; }
java
@XmlElementWrapper(name = "allpages") @XmlElement(name = "p", type = P.class) public List<P> getAllpages() { return allpages; }
[ "@", "XmlElementWrapper", "(", "name", "=", "\"allpages\"", ")", "@", "XmlElement", "(", "name", "=", "\"p\"", ",", "type", "=", "P", ".", "class", ")", "public", "List", "<", "P", ">", "getAllpages", "(", ")", "{", "return", "allpages", ";", "}" ]
Gets the value of the allpages property.
[ "Gets", "the", "value", "of", "the", "allpages", "property", "." ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/api/Query.java#L115-L119
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/api/Query.java
Query.getAllImages
@XmlElementWrapper(name = "allimages") @XmlElement(name = "img", type = Img.class) public List<Img> getAllImages() { return allimages; }
java
@XmlElementWrapper(name = "allimages") @XmlElement(name = "img", type = Img.class) public List<Img> getAllImages() { return allimages; }
[ "@", "XmlElementWrapper", "(", "name", "=", "\"allimages\"", ")", "@", "XmlElement", "(", "name", "=", "\"img\"", ",", "type", "=", "Img", ".", "class", ")", "public", "List", "<", "Img", ">", "getAllImages", "(", ")", "{", "return", "allimages", ";", ...
Gets the value of the allimages property.
[ "Gets", "the", "value", "of", "the", "allimages", "property", "." ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/api/Query.java#L133-L137
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/api/Query.java
Query.getPages
@XmlElementWrapper(name = "pages") @XmlElement(name = "page", type = Page.class) public List<Page> getPages() { return pages; }
java
@XmlElementWrapper(name = "pages") @XmlElement(name = "page", type = Page.class) public List<Page> getPages() { return pages; }
[ "@", "XmlElementWrapper", "(", "name", "=", "\"pages\"", ")", "@", "XmlElement", "(", "name", "=", "\"page\"", ",", "type", "=", "Page", ".", "class", ")", "public", "List", "<", "Page", ">", "getPages", "(", ")", "{", "return", "pages", ";", "}" ]
Gets the value of the pages property. @return the list of pages
[ "Gets", "the", "value", "of", "the", "pages", "property", "." ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/api/Query.java#L189-L193
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/SSLWiki.java
SSLWiki.init
public void init() throws Exception { // configure the SSLContext with a TrustManager SSLContext ctx = SSLContext.getInstance("TLS"); if (ignoreCertificates) { ctx.init(new KeyManager[0], new TrustManager[] { new DefaultTrustManager() }, new SecureRandom()); SSLContext.setDefault(ctx); } HostnameVerifier hv = new IgnoreHostName(); HttpsURLConnection.setDefaultHostnameVerifier(hv); }
java
public void init() throws Exception { // configure the SSLContext with a TrustManager SSLContext ctx = SSLContext.getInstance("TLS"); if (ignoreCertificates) { ctx.init(new KeyManager[0], new TrustManager[] { new DefaultTrustManager() }, new SecureRandom()); SSLContext.setDefault(ctx); } HostnameVerifier hv = new IgnoreHostName(); HttpsURLConnection.setDefaultHostnameVerifier(hv); }
[ "public", "void", "init", "(", ")", "throws", "Exception", "{", "// configure the SSLContext with a TrustManager", "SSLContext", "ctx", "=", "SSLContext", ".", "getInstance", "(", "\"TLS\"", ")", ";", "if", "(", "ignoreCertificates", ")", "{", "ctx", ".", "init", ...
initialize this wiki
[ "initialize", "this", "wiki" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/SSLWiki.java#L115-L125
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/SSLWiki.java
SSLWiki.login
public void login() throws Exception { WikiUser wuser = WikiUser.getUser(getWikiid(), getSiteurl()); if (wuser == null) { throw new Exception( "user for " + getWikiid() + "(" + getSiteurl() + ") not configured"); } // wiki.setDebug(true); try { Login login = login(wuser.getUsername(), wuser.getPassword()); LOGGER.log(Level.INFO, this.siteurl + this.scriptPath + this.apiPath + ":" + login.getResult()); if (!"Success".equals(login.getResult())) { throw new Exception("login for '" + wuser.getUsername() + "' at '" + getWikiid() + "(" + this.getSiteurl() + this.getScriptPath() + ")' failed: " + login.getResult()); } } catch (javax.net.ssl.SSLHandshakeException she) { String msg = "login via SSL to " + this.getSiteurl() + " failed\n"; msg += "Exception: " + she.getMessage(); throw new Exception(msg); } }
java
public void login() throws Exception { WikiUser wuser = WikiUser.getUser(getWikiid(), getSiteurl()); if (wuser == null) { throw new Exception( "user for " + getWikiid() + "(" + getSiteurl() + ") not configured"); } // wiki.setDebug(true); try { Login login = login(wuser.getUsername(), wuser.getPassword()); LOGGER.log(Level.INFO, this.siteurl + this.scriptPath + this.apiPath + ":" + login.getResult()); if (!"Success".equals(login.getResult())) { throw new Exception("login for '" + wuser.getUsername() + "' at '" + getWikiid() + "(" + this.getSiteurl() + this.getScriptPath() + ")' failed: " + login.getResult()); } } catch (javax.net.ssl.SSLHandshakeException she) { String msg = "login via SSL to " + this.getSiteurl() + " failed\n"; msg += "Exception: " + she.getMessage(); throw new Exception(msg); } }
[ "public", "void", "login", "(", ")", "throws", "Exception", "{", "WikiUser", "wuser", "=", "WikiUser", ".", "getUser", "(", "getWikiid", "(", ")", ",", "getSiteurl", "(", ")", ")", ";", "if", "(", "wuser", "==", "null", ")", "{", "throw", "new", "Exc...
log me in with the configured user @throws Exception
[ "log", "me", "in", "with", "the", "configured", "user" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/SSLWiki.java#L186-L207
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/jaxb/JaxbFactory.java
JaxbFactory.getUnmarshaller
public Unmarshaller getUnmarshaller() throws JAXBException { JAXBContext context = JAXBContext.newInstance(classOfT); Unmarshaller u = context.createUnmarshaller(); u.setEventHandler(new ValidationEventHandler() { @Override public boolean handleEvent(ValidationEvent event) { return true; } }); return u; }
java
public Unmarshaller getUnmarshaller() throws JAXBException { JAXBContext context = JAXBContext.newInstance(classOfT); Unmarshaller u = context.createUnmarshaller(); u.setEventHandler(new ValidationEventHandler() { @Override public boolean handleEvent(ValidationEvent event) { return true; } }); return u; }
[ "public", "Unmarshaller", "getUnmarshaller", "(", ")", "throws", "JAXBException", "{", "JAXBContext", "context", "=", "JAXBContext", ".", "newInstance", "(", "classOfT", ")", ";", "Unmarshaller", "u", "=", "context", ".", "createUnmarshaller", "(", ")", ";", "u"...
get a fitting Unmarshaller @return - the Unmarshaller for the classOfT set @throws JAXBException
[ "get", "a", "fitting", "Unmarshaller" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/jaxb/JaxbFactory.java#L75-L85
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/jaxb/JaxbFactory.java
JaxbFactory.fromXML
public T fromXML(String xml) throws Exception { Unmarshaller u = this.getUnmarshaller(); u.setProperty(MarshallerProperties.MEDIA_TYPE, "application/xml"); T result = this.fromString(u, xml); return result; }
java
public T fromXML(String xml) throws Exception { Unmarshaller u = this.getUnmarshaller(); u.setProperty(MarshallerProperties.MEDIA_TYPE, "application/xml"); T result = this.fromString(u, xml); return result; }
[ "public", "T", "fromXML", "(", "String", "xml", ")", "throws", "Exception", "{", "Unmarshaller", "u", "=", "this", ".", "getUnmarshaller", "(", ")", ";", "u", ".", "setProperty", "(", "MarshallerProperties", ".", "MEDIA_TYPE", ",", "\"application/xml\"", ")", ...
get an instance of T for the given xml string @param xml - the xml representation of the <T> instance @return T @throws Exception - if the conversion fails
[ "get", "an", "instance", "of", "T", "for", "the", "given", "xml", "string" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/jaxb/JaxbFactory.java#L125-L130
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/jaxb/JaxbFactory.java
JaxbFactory.fromJson
public T fromJson(String json) throws Exception { Unmarshaller u = this.getUnmarshaller(); u.setProperty(MarshallerProperties.MEDIA_TYPE, "application/json"); T result = this.fromString(u, json); return result; }
java
public T fromJson(String json) throws Exception { Unmarshaller u = this.getUnmarshaller(); u.setProperty(MarshallerProperties.MEDIA_TYPE, "application/json"); T result = this.fromString(u, json); return result; }
[ "public", "T", "fromJson", "(", "String", "json", ")", "throws", "Exception", "{", "Unmarshaller", "u", "=", "this", ".", "getUnmarshaller", "(", ")", ";", "u", ".", "setProperty", "(", "MarshallerProperties", ".", "MEDIA_TYPE", ",", "\"application/json\"", ")...
get an instance of T for the given json string @param json - the json representation of the <T> instance @return T @throws Exception
[ "get", "an", "instance", "of", "T", "for", "the", "given", "json", "string" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/jaxb/JaxbFactory.java#L140-L145
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/jaxb/JaxbFactory.java
JaxbFactory.getString
public String getString(Marshaller marshaller, T instance) throws JAXBException { StringWriter sw = new StringWriter(); marshaller.marshal(instance, sw); String result = sw.toString(); return result; }
java
public String getString(Marshaller marshaller, T instance) throws JAXBException { StringWriter sw = new StringWriter(); marshaller.marshal(instance, sw); String result = sw.toString(); return result; }
[ "public", "String", "getString", "(", "Marshaller", "marshaller", ",", "T", "instance", ")", "throws", "JAXBException", "{", "StringWriter", "sw", "=", "new", "StringWriter", "(", ")", ";", "marshaller", ".", "marshal", "(", "instance", ",", "sw", ")", ";", ...
get the string representation of the given marshaller @param marshaller @param instance @return the string representation for the given marshaller @throws JAXBException
[ "get", "the", "string", "representation", "of", "the", "given", "marshaller" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/jaxb/JaxbFactory.java#L170-L176
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/SiteInfoImpl.java
SiteInfoImpl.initNameSpaces
protected void initNameSpaces(General general, List<Ns> namespaceList) { namespaces = new LinkedHashMap<String, Ns>(); namespacesById = new LinkedHashMap<Integer, Ns>(); namespacesByCanonicalName = new LinkedHashMap<String, Ns>(); for (Ns namespace : namespaceList) { String namespacename = namespace.getValue(); namespaces.put(namespacename, namespace); namespacesById.put(namespace.getId(), namespace); String canonical = namespace.getCanonical(); // this is a BUG in 2015-07-02 - some canonical names are not correct // FIXME - when Bug has been fixed in SMW String bugs[] = { "Attribut", "Property", "Konzept", "Concept","Kategorie","Category" }; for (int i = 0; i < bugs.length; i += 2) { if (bugs[i].equals(canonical) && bugs[i].equals(namespacename)) { canonical = bugs[i + 1]; namespace.setCanonical(bugs[i + 1]); } } namespacesByCanonicalName.put(canonical, namespace); } }
java
protected void initNameSpaces(General general, List<Ns> namespaceList) { namespaces = new LinkedHashMap<String, Ns>(); namespacesById = new LinkedHashMap<Integer, Ns>(); namespacesByCanonicalName = new LinkedHashMap<String, Ns>(); for (Ns namespace : namespaceList) { String namespacename = namespace.getValue(); namespaces.put(namespacename, namespace); namespacesById.put(namespace.getId(), namespace); String canonical = namespace.getCanonical(); // this is a BUG in 2015-07-02 - some canonical names are not correct // FIXME - when Bug has been fixed in SMW String bugs[] = { "Attribut", "Property", "Konzept", "Concept","Kategorie","Category" }; for (int i = 0; i < bugs.length; i += 2) { if (bugs[i].equals(canonical) && bugs[i].equals(namespacename)) { canonical = bugs[i + 1]; namespace.setCanonical(bugs[i + 1]); } } namespacesByCanonicalName.put(canonical, namespace); } }
[ "protected", "void", "initNameSpaces", "(", "General", "general", ",", "List", "<", "Ns", ">", "namespaceList", ")", "{", "namespaces", "=", "new", "LinkedHashMap", "<", "String", ",", "Ns", ">", "(", ")", ";", "namespacesById", "=", "new", "LinkedHashMap", ...
initialize the NameSpaces from the given namespaceList @param general @param namespaceList
[ "initialize", "the", "NameSpaces", "from", "the", "given", "namespaceList" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/SiteInfoImpl.java#L69-L89
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/SiteInfoImpl.java
SiteInfoImpl.mapNamespace
public String mapNamespace(String ns, SiteInfo targetWiki) throws Exception { Map<String, Ns> sourceMap = this.getNamespaces(); Map<Integer, Ns> targetMap = targetWiki.getNamespacesById(); Ns sourceNs = sourceMap.get(ns); if (sourceNs == null) { if (debug) LOGGER.log(Level.WARNING, "can not map unknown namespace " + ns); return ns; } Ns targetNs = targetMap.get(sourceNs.getId()); if (targetNs == null) { if (debug) LOGGER.log( Level.WARNING, "missing namespace " + sourceNs.getValue() + " id:" + sourceNs.getId() + " canonical:" + sourceNs.getCanonical()); return ns; } return targetNs.getValue(); }
java
public String mapNamespace(String ns, SiteInfo targetWiki) throws Exception { Map<String, Ns> sourceMap = this.getNamespaces(); Map<Integer, Ns> targetMap = targetWiki.getNamespacesById(); Ns sourceNs = sourceMap.get(ns); if (sourceNs == null) { if (debug) LOGGER.log(Level.WARNING, "can not map unknown namespace " + ns); return ns; } Ns targetNs = targetMap.get(sourceNs.getId()); if (targetNs == null) { if (debug) LOGGER.log( Level.WARNING, "missing namespace " + sourceNs.getValue() + " id:" + sourceNs.getId() + " canonical:" + sourceNs.getCanonical()); return ns; } return targetNs.getValue(); }
[ "public", "String", "mapNamespace", "(", "String", "ns", ",", "SiteInfo", "targetWiki", ")", "throws", "Exception", "{", "Map", "<", "String", ",", "Ns", ">", "sourceMap", "=", "this", ".", "getNamespaces", "(", ")", ";", "Map", "<", "Integer", ",", "Ns"...
map the given namespace to the target wiki @param ns @param targetWiki @return the namespace name for the target wiki @throws Exception
[ "map", "the", "given", "namespace", "to", "the", "target", "wiki" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/SiteInfoImpl.java#L153-L172
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/user/Crypt.java
Crypt.generateRandomKey
public static String generateRandomKey(int pLength) { int asciiFirst = 48; int asciiLast = 122; Integer[] exceptions = { 58,59,60,61,62,63,91,92,93,94,96 }; List<Integer> exceptionsList = Arrays.asList(exceptions); SecureRandom random = new SecureRandom(); StringBuilder builder = new StringBuilder(); for (int i=0; i<pLength; i++) { int charIndex; do { charIndex = random.nextInt(asciiLast - asciiFirst + 1) + asciiFirst; } while (exceptionsList.contains(charIndex)); builder.append((char) charIndex); } return builder.toString(); }
java
public static String generateRandomKey(int pLength) { int asciiFirst = 48; int asciiLast = 122; Integer[] exceptions = { 58,59,60,61,62,63,91,92,93,94,96 }; List<Integer> exceptionsList = Arrays.asList(exceptions); SecureRandom random = new SecureRandom(); StringBuilder builder = new StringBuilder(); for (int i=0; i<pLength; i++) { int charIndex; do { charIndex = random.nextInt(asciiLast - asciiFirst + 1) + asciiFirst; } while (exceptionsList.contains(charIndex)); builder.append((char) charIndex); } return builder.toString(); }
[ "public", "static", "String", "generateRandomKey", "(", "int", "pLength", ")", "{", "int", "asciiFirst", "=", "48", ";", "int", "asciiLast", "=", "122", ";", "Integer", "[", "]", "exceptions", "=", "{", "58", ",", "59", ",", "60", ",", "61", ",", "62...
generate a Random key @param pLength @return the reandom key with the given length
[ "generate", "a", "Random", "key" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/user/Crypt.java#L87-L106
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/user/Crypt.java
Crypt.getRandomCrypt
public static Crypt getRandomCrypt() { String lCypher=generateRandomKey(32); String lSalt=generateRandomKey(8); Crypt result=new Crypt(lCypher,lSalt); return result; }
java
public static Crypt getRandomCrypt() { String lCypher=generateRandomKey(32); String lSalt=generateRandomKey(8); Crypt result=new Crypt(lCypher,lSalt); return result; }
[ "public", "static", "Crypt", "getRandomCrypt", "(", ")", "{", "String", "lCypher", "=", "generateRandomKey", "(", "32", ")", ";", "String", "lSalt", "=", "generateRandomKey", "(", "8", ")", ";", "Crypt", "result", "=", "new", "Crypt", "(", "lCypher", ",", ...
get a random Crypt @return a new crypt with a 32 byte random key and 8byte salt
[ "get", "a", "random", "Crypt" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/user/Crypt.java#L112-L117
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/user/Crypt.java
Crypt.encrypt
String encrypt(String property) throws GeneralSecurityException, UnsupportedEncodingException { SecretKeyFactory keyFactory = SecretKeyFactory .getInstance("PBEWithMD5AndDES"); SecretKey key = keyFactory.generateSecret(new PBEKeySpec(cypher)); Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES"); pbeCipher.init(Cipher.ENCRYPT_MODE, key, new PBEParameterSpec(salt, 20)); return base64Encode(pbeCipher.doFinal(property.getBytes("UTF-8"))); }
java
String encrypt(String property) throws GeneralSecurityException, UnsupportedEncodingException { SecretKeyFactory keyFactory = SecretKeyFactory .getInstance("PBEWithMD5AndDES"); SecretKey key = keyFactory.generateSecret(new PBEKeySpec(cypher)); Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES"); pbeCipher.init(Cipher.ENCRYPT_MODE, key, new PBEParameterSpec(salt, 20)); return base64Encode(pbeCipher.doFinal(property.getBytes("UTF-8"))); }
[ "String", "encrypt", "(", "String", "property", ")", "throws", "GeneralSecurityException", ",", "UnsupportedEncodingException", "{", "SecretKeyFactory", "keyFactory", "=", "SecretKeyFactory", ".", "getInstance", "(", "\"PBEWithMD5AndDES\"", ")", ";", "SecretKey", "key", ...
encrypt the given property @param property @return @throws GeneralSecurityException @throws UnsupportedEncodingException
[ "encrypt", "the", "given", "property" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/user/Crypt.java#L142-L150
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/user/WikiUser.java
WikiUser.getInput
public static String getInput(String name, BufferedReader br) throws IOException { // prompt the user to enter the given name System.out.print("Please Enter " + name + ": "); String value = br.readLine(); return value; }
java
public static String getInput(String name, BufferedReader br) throws IOException { // prompt the user to enter the given name System.out.print("Please Enter " + name + ": "); String value = br.readLine(); return value; }
[ "public", "static", "String", "getInput", "(", "String", "name", ",", "BufferedReader", "br", ")", "throws", "IOException", "{", "// prompt the user to enter the given name", "System", ".", "out", ".", "print", "(", "\"Please Enter \"", "+", "name", "+", "\": \"", ...
get input from standard in @param name @param br - the buffered reader to read from @return the input returned @throws IOException
[ "get", "input", "from", "standard", "in" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/user/WikiUser.java#L76-L83
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/user/WikiUser.java
WikiUser.getPropertyFile
public static File getPropertyFile(String wikiId, String user) { String userPropertiesFileName = System.getProperty("user.home") + "/.mediawiki-japi/" + user + "_" + wikiId + ".ini"; File propFile = new File(userPropertiesFileName); return propFile; }
java
public static File getPropertyFile(String wikiId, String user) { String userPropertiesFileName = System.getProperty("user.home") + "/.mediawiki-japi/" + user + "_" + wikiId + ".ini"; File propFile = new File(userPropertiesFileName); return propFile; }
[ "public", "static", "File", "getPropertyFile", "(", "String", "wikiId", ",", "String", "user", ")", "{", "String", "userPropertiesFileName", "=", "System", ".", "getProperty", "(", "\"user.home\"", ")", "+", "\"/.mediawiki-japi/\"", "+", "user", "+", "\"_\"", "+...
get the property file for the given wikiId and user @param wikiId - the wiki to get the data for @param user - the user @return the property File
[ "get", "the", "property", "file", "for", "the", "given", "wikiId", "and", "user" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/user/WikiUser.java#L92-L97
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/user/WikiUser.java
WikiUser.getPropertyFile
public static File getPropertyFile(String wikiId) { String user = System.getProperty("user.name"); return getPropertyFile(wikiId, user); }
java
public static File getPropertyFile(String wikiId) { String user = System.getProperty("user.name"); return getPropertyFile(wikiId, user); }
[ "public", "static", "File", "getPropertyFile", "(", "String", "wikiId", ")", "{", "String", "user", "=", "System", ".", "getProperty", "(", "\"user.name\"", ")", ";", "return", "getPropertyFile", "(", "wikiId", ",", "user", ")", ";", "}" ]
get the propertyFile for the given wikiId @param wikiId @return the propertyFile
[ "get", "the", "propertyFile", "for", "the", "given", "wikiId" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/user/WikiUser.java#L104-L107
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/user/WikiUser.java
WikiUser.getProperties
public static Properties getProperties(String wikiId) throws FileNotFoundException, IOException { File propFile = getPropertyFile(wikiId); Properties props = new Properties(); props.load(new FileReader(propFile)); return props; }
java
public static Properties getProperties(String wikiId) throws FileNotFoundException, IOException { File propFile = getPropertyFile(wikiId); Properties props = new Properties(); props.load(new FileReader(propFile)); return props; }
[ "public", "static", "Properties", "getProperties", "(", "String", "wikiId", ")", "throws", "FileNotFoundException", ",", "IOException", "{", "File", "propFile", "=", "getPropertyFile", "(", "wikiId", ")", ";", "Properties", "props", "=", "new", "Properties", "(", ...
get the Properties for the given wikiId @param wikiId @return @throws FileNotFoundException @throws IOException
[ "get", "the", "Properties", "for", "the", "given", "wikiId" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/user/WikiUser.java#L117-L123
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/user/WikiUser.java
WikiUser.getUser
public static WikiUser getUser(String wikiId, String siteurl) { WikiUser result = null; try { Properties props = getProperties(wikiId); result = new WikiUser(); result.setUsername(props.getProperty("user")); result.setEmail(props.getProperty("email")); Crypt pcf = new Crypt(props.getProperty("cypher"), props.getProperty("salt")); result.setPassword(pcf.decrypt(props.getProperty("secret"))); } catch (FileNotFoundException e) { String msg = help(wikiId, siteurl); LOGGER.log(Level.SEVERE, msg); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage()); } catch (GeneralSecurityException e) { LOGGER.log(Level.SEVERE, e.getMessage()); } return result; }
java
public static WikiUser getUser(String wikiId, String siteurl) { WikiUser result = null; try { Properties props = getProperties(wikiId); result = new WikiUser(); result.setUsername(props.getProperty("user")); result.setEmail(props.getProperty("email")); Crypt pcf = new Crypt(props.getProperty("cypher"), props.getProperty("salt")); result.setPassword(pcf.decrypt(props.getProperty("secret"))); } catch (FileNotFoundException e) { String msg = help(wikiId, siteurl); LOGGER.log(Level.SEVERE, msg); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage()); } catch (GeneralSecurityException e) { LOGGER.log(Level.SEVERE, e.getMessage()); } return result; }
[ "public", "static", "WikiUser", "getUser", "(", "String", "wikiId", ",", "String", "siteurl", ")", "{", "WikiUser", "result", "=", "null", ";", "try", "{", "Properties", "props", "=", "getProperties", "(", "wikiId", ")", ";", "result", "=", "new", "WikiUse...
get the Wiki user for the given wikiid @param wikiId - the id of the wiki @param siteurl - the siteurl @return a Wikiuser for this site
[ "get", "the", "Wiki", "user", "for", "the", "given", "wikiid" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/user/WikiUser.java#L134-L154
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/user/WikiUser.java
WikiUser.createIniFile
public static void createIniFile(String... args) { try { // open up standard input BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String wikiid = null; if (args.length > 0) wikiid = args[0]; else wikiid = getInput("wiki id", br); String username = null; if (args.length > 1) username = args[1]; else username = getInput("username", br); String password = null; if (args.length > 2) password = args[2]; else password = getInput("password", br); String email = null; if (args.length > 3) email = args[3]; else email = getInput("email", br); File propFile = getPropertyFile(wikiid, username); String remember = null; if (args.length > 4) remember = args[4]; else remember = getInput("shall i store " + username + "'s credentials encrypted in " + propFile.getName() + " y/n?", br); if (remember.trim().toLowerCase().startsWith("y")) { Crypt lCrypt = Crypt.getRandomCrypt(); Properties props = new Properties(); props.setProperty("cypher", lCrypt.getCypher()); props.setProperty("salt", lCrypt.getSalt()); props.setProperty("user", username); props.setProperty("email", email); props.setProperty("secret", lCrypt.encrypt(password)); if (!propFile.getParentFile().exists()) { propFile.getParentFile().mkdirs(); } FileOutputStream propsStream = new FileOutputStream(propFile); props.store(propsStream, "Mediawiki JAPI credentials for " + wikiid); propsStream.close(); } } catch (IOException e1) { LOGGER.log(Level.SEVERE, e1.getMessage()); } catch (GeneralSecurityException e1) { LOGGER.log(Level.SEVERE, e1.getMessage()); } }
java
public static void createIniFile(String... args) { try { // open up standard input BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String wikiid = null; if (args.length > 0) wikiid = args[0]; else wikiid = getInput("wiki id", br); String username = null; if (args.length > 1) username = args[1]; else username = getInput("username", br); String password = null; if (args.length > 2) password = args[2]; else password = getInput("password", br); String email = null; if (args.length > 3) email = args[3]; else email = getInput("email", br); File propFile = getPropertyFile(wikiid, username); String remember = null; if (args.length > 4) remember = args[4]; else remember = getInput("shall i store " + username + "'s credentials encrypted in " + propFile.getName() + " y/n?", br); if (remember.trim().toLowerCase().startsWith("y")) { Crypt lCrypt = Crypt.getRandomCrypt(); Properties props = new Properties(); props.setProperty("cypher", lCrypt.getCypher()); props.setProperty("salt", lCrypt.getSalt()); props.setProperty("user", username); props.setProperty("email", email); props.setProperty("secret", lCrypt.encrypt(password)); if (!propFile.getParentFile().exists()) { propFile.getParentFile().mkdirs(); } FileOutputStream propsStream = new FileOutputStream(propFile); props.store(propsStream, "Mediawiki JAPI credentials for " + wikiid); propsStream.close(); } } catch (IOException e1) { LOGGER.log(Level.SEVERE, e1.getMessage()); } catch (GeneralSecurityException e1) { LOGGER.log(Level.SEVERE, e1.getMessage()); } }
[ "public", "static", "void", "createIniFile", "(", "String", "...", "args", ")", "{", "try", "{", "// open up standard input", "BufferedReader", "br", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "System", ".", "in", ")", ")", ";", "Strin...
create a credentials ini file from the command line
[ "create", "a", "credentials", "ini", "file", "from", "the", "command", "line" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/user/WikiUser.java#L189-L241
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/api/Paraminfo.java
Paraminfo.getModules
@XmlElementWrapper(name="modules") @XmlElement(name="module", type=Module.class) public List<Module> getModules() { return modules; }
java
@XmlElementWrapper(name="modules") @XmlElement(name="module", type=Module.class) public List<Module> getModules() { return modules; }
[ "@", "XmlElementWrapper", "(", "name", "=", "\"modules\"", ")", "@", "XmlElement", "(", "name", "=", "\"module\"", ",", "type", "=", "Module", ".", "class", ")", "public", "List", "<", "Module", ">", "getModules", "(", ")", "{", "return", "modules", ";",...
Ruft den Wert der modules-Eigenschaft ab. @return possible object is {@link Modules }
[ "Ruft", "den", "Wert", "der", "modules", "-", "Eigenschaft", "ab", "." ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/api/Paraminfo.java#L141-L145
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/api/Parse.java
Parse.getSections
@XmlElementWrapper(name = "sections") @XmlElement(name = "s", type = S.class) public List<S> getSections() { return sections; }
java
@XmlElementWrapper(name = "sections") @XmlElement(name = "s", type = S.class) public List<S> getSections() { return sections; }
[ "@", "XmlElementWrapper", "(", "name", "=", "\"sections\"", ")", "@", "XmlElement", "(", "name", "=", "\"s\"", ",", "type", "=", "S", ".", "class", ")", "public", "List", "<", "S", ">", "getSections", "(", ")", "{", "return", "sections", ";", "}" ]
Gets the value of the sections property. @return possible object is {@link Sections }
[ "Gets", "the", "value", "of", "the", "sections", "property", "." ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/api/Parse.java#L106-L110
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/api/Api.java
Api.fromXML
public static Api fromXML(final String xml) throws Exception { Api result=null; try { result=apifactory.fromXML(xml); } catch (JAXBException je) { LOGGER.log(Level.SEVERE,je.getMessage()); LOGGER.log(Level.INFO,xml); throw je; } return result; }
java
public static Api fromXML(final String xml) throws Exception { Api result=null; try { result=apifactory.fromXML(xml); } catch (JAXBException je) { LOGGER.log(Level.SEVERE,je.getMessage()); LOGGER.log(Level.INFO,xml); throw je; } return result; }
[ "public", "static", "Api", "fromXML", "(", "final", "String", "xml", ")", "throws", "Exception", "{", "Api", "result", "=", "null", ";", "try", "{", "result", "=", "apifactory", ".", "fromXML", "(", "xml", ")", ";", "}", "catch", "(", "JAXBException", ...
create a Api from an XML string @param xml - xml representation of Page Schema @return the Api unmarshalled from the given xml @throws Exception
[ "create", "a", "Api", "from", "an", "XML", "string" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/api/Api.java#L313-L323
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.getIsoTimeStamp
public String getIsoTimeStamp() { TimeZone tz = TimeZone.getTimeZone("UTC"); DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); df.setTimeZone(tz); String nowAsISO = df.format(new Date()); return nowAsISO; }
java
public String getIsoTimeStamp() { TimeZone tz = TimeZone.getTimeZone("UTC"); DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); df.setTimeZone(tz); String nowAsISO = df.format(new Date()); return nowAsISO; }
[ "public", "String", "getIsoTimeStamp", "(", ")", "{", "TimeZone", "tz", "=", "TimeZone", ".", "getTimeZone", "(", "\"UTC\"", ")", ";", "DateFormat", "df", "=", "new", "SimpleDateFormat", "(", "\"yyyy-MM-dd'T'HH:mm:ssX\"", ")", ";", "df", ".", "setTimeZone", "(...
get a current IsoTimeStamp @return - the current timestamp
[ "get", "a", "current", "IsoTimeStamp" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L209-L215
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.getStringFromUrl
public static String getStringFromUrl(String urlString) { ApacheHttpClient lclient = ApacheHttpClient.create(); WebResource webResource = lclient.resource(urlString); ClientResponse response = webResource.get(ClientResponse.class); if (response.getStatus() != 200) { throw new RuntimeException("HTTP error code : " + response.getStatus()); } String result = response.getEntity(String.class); return result; }
java
public static String getStringFromUrl(String urlString) { ApacheHttpClient lclient = ApacheHttpClient.create(); WebResource webResource = lclient.resource(urlString); ClientResponse response = webResource.get(ClientResponse.class); if (response.getStatus() != 200) { throw new RuntimeException("HTTP error code : " + response.getStatus()); } String result = response.getEntity(String.class); return result; }
[ "public", "static", "String", "getStringFromUrl", "(", "String", "urlString", ")", "{", "ApacheHttpClient", "lclient", "=", "ApacheHttpClient", ".", "create", "(", ")", ";", "WebResource", "webResource", "=", "lclient", ".", "resource", "(", "urlString", ")", ";...
get a String from a given URL @param urlString @return
[ "get", "a", "String", "from", "a", "given", "URL" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L223-L233
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.getResource
public Builder getResource(String queryUrl) throws Exception { if (debug) LOGGER.log(Level.INFO, queryUrl); WebResource wrs = client.resource(queryUrl); Builder result = wrs.header("USER-AGENT", USER_AGENT); return result; }
java
public Builder getResource(String queryUrl) throws Exception { if (debug) LOGGER.log(Level.INFO, queryUrl); WebResource wrs = client.resource(queryUrl); Builder result = wrs.header("USER-AGENT", USER_AGENT); return result; }
[ "public", "Builder", "getResource", "(", "String", "queryUrl", ")", "throws", "Exception", "{", "if", "(", "debug", ")", "LOGGER", ".", "log", "(", "Level", ".", "INFO", ",", "queryUrl", ")", ";", "WebResource", "wrs", "=", "client", ".", "resource", "("...
get the given Builder for the given queryUrl this is a wrapper to be able to debug all QueryUrl @param queryUrl - either a relative or absolute path @return @throws Exception
[ "get", "the", "given", "Builder", "for", "the", "given", "queryUrl", "this", "is", "a", "wrapper", "to", "be", "able", "to", "debug", "all", "QueryUrl" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L244-L250
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.getPostResponse
public ClientResponse getPostResponse(String queryUrl, String params, TokenResult token, Object pFormDataObject) throws Exception { params = params.replace("|", "%7C"); params = params.replace("+", "%20"); // modal handling of post FormDataMultiPart form = null; MultivaluedMap<String, String> lFormData = null; if (pFormDataObject instanceof FormDataMultiPart) { form = (FormDataMultiPart) pFormDataObject; } else { @SuppressWarnings("unchecked") Map<String, String> pFormData = (Map<String, String>) pFormDataObject; lFormData = new MultivaluedMapImpl(); if (pFormData != null) { for (String key : pFormData.keySet()) { lFormData.add(key, pFormData.get(key)); } } } if (token != null) { switch (token.tokenMode) { case token1_24: if (lFormData != null) { lFormData.add(token.tokenName, token.token); } else { form.field(token.tokenName, token.token); } break; default: params += token.asParam(); } } Builder resource = getResource(queryUrl + params); // FIXME allow to specify content type (not needed for Mediawiki itself // but // could be good for interfacing ) ClientResponse response = null; if (lFormData != null) { response = resource.type(MediaType.APPLICATION_FORM_URLENCODED_TYPE) .post(ClientResponse.class, lFormData); } else { response = resource.type(MediaType.MULTIPART_FORM_DATA_TYPE) .post(ClientResponse.class, form); } return response; }
java
public ClientResponse getPostResponse(String queryUrl, String params, TokenResult token, Object pFormDataObject) throws Exception { params = params.replace("|", "%7C"); params = params.replace("+", "%20"); // modal handling of post FormDataMultiPart form = null; MultivaluedMap<String, String> lFormData = null; if (pFormDataObject instanceof FormDataMultiPart) { form = (FormDataMultiPart) pFormDataObject; } else { @SuppressWarnings("unchecked") Map<String, String> pFormData = (Map<String, String>) pFormDataObject; lFormData = new MultivaluedMapImpl(); if (pFormData != null) { for (String key : pFormData.keySet()) { lFormData.add(key, pFormData.get(key)); } } } if (token != null) { switch (token.tokenMode) { case token1_24: if (lFormData != null) { lFormData.add(token.tokenName, token.token); } else { form.field(token.tokenName, token.token); } break; default: params += token.asParam(); } } Builder resource = getResource(queryUrl + params); // FIXME allow to specify content type (not needed for Mediawiki itself // but // could be good for interfacing ) ClientResponse response = null; if (lFormData != null) { response = resource.type(MediaType.APPLICATION_FORM_URLENCODED_TYPE) .post(ClientResponse.class, lFormData); } else { response = resource.type(MediaType.MULTIPART_FORM_DATA_TYPE) .post(ClientResponse.class, form); } return response; }
[ "public", "ClientResponse", "getPostResponse", "(", "String", "queryUrl", ",", "String", "params", ",", "TokenResult", "token", ",", "Object", "pFormDataObject", ")", "throws", "Exception", "{", "params", "=", "params", ".", "replace", "(", "\"|\"", ",", "\"%7C\...
get a Post response @param queryUrl @param params - direct query parameters @param token - a token if any @param pFormData - the form data - either as multipart of urlencoded @return - the client Response @throws Exception
[ "get", "a", "Post", "response" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L274-L319
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.getResponse
public ClientResponse getResponse(String url, Method method) throws Exception { Builder resource = getResource(url); ClientResponse response = null; switch (method) { case Get: response = resource.get(ClientResponse.class); break; case Post: response = resource.post(ClientResponse.class); break; case Head: response = resource.head(); break; case Put: response = resource.put(ClientResponse.class); break; } return response; }
java
public ClientResponse getResponse(String url, Method method) throws Exception { Builder resource = getResource(url); ClientResponse response = null; switch (method) { case Get: response = resource.get(ClientResponse.class); break; case Post: response = resource.post(ClientResponse.class); break; case Head: response = resource.head(); break; case Put: response = resource.put(ClientResponse.class); break; } return response; }
[ "public", "ClientResponse", "getResponse", "(", "String", "url", ",", "Method", "method", ")", "throws", "Exception", "{", "Builder", "resource", "=", "getResource", "(", "url", ")", ";", "ClientResponse", "response", "=", "null", ";", "switch", "(", "method",...
get a response for the given url and method @param url @param method @return @throws Exception
[ "get", "a", "response", "for", "the", "given", "url", "and", "method" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L333-L352
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.getResponseString
public String getResponseString(ClientResponse response) throws Exception { if (debug) LOGGER.log(Level.INFO, "status: " + response.getStatus()); String responseText = response.getEntity(String.class); if (response.getStatus() != 200) { handleError("status " + response.getStatus() + ":'" + responseText + "'"); } return responseText; }
java
public String getResponseString(ClientResponse response) throws Exception { if (debug) LOGGER.log(Level.INFO, "status: " + response.getStatus()); String responseText = response.getEntity(String.class); if (response.getStatus() != 200) { handleError("status " + response.getStatus() + ":'" + responseText + "'"); } return responseText; }
[ "public", "String", "getResponseString", "(", "ClientResponse", "response", ")", "throws", "Exception", "{", "if", "(", "debug", ")", "LOGGER", ".", "log", "(", "Level", ".", "INFO", ",", "\"status: \"", "+", "response", ".", "getStatus", "(", ")", ")", ";...
get the Response string @param response @return the String representation of a response @throws Exception
[ "get", "the", "Response", "string" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L361-L369
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.getParamMap
public Map<String, String> getParamMap(String params) { Map<String, String> result = new HashMap<String, String>(); String[] paramlist = params.split("&"); for (int i = 0; i < paramlist.length; i++) { String[] parts = paramlist[i].split("="); if (parts.length == 2) result.put(parts[0], parts[1]); } return result; }
java
public Map<String, String> getParamMap(String params) { Map<String, String> result = new HashMap<String, String>(); String[] paramlist = params.split("&"); for (int i = 0; i < paramlist.length; i++) { String[] parts = paramlist[i].split("="); if (parts.length == 2) result.put(parts[0], parts[1]); } return result; }
[ "public", "Map", "<", "String", ",", "String", ">", "getParamMap", "(", "String", "params", ")", "{", "Map", "<", "String", ",", "String", ">", "result", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "String", "[", "]", "...
get a Map of parameter from a & delimited parameter list @param params - the list of parameters @return the map FIXME - should check that split creates and even number of entries - add test case for this
[ "get", "a", "Map", "of", "parameter", "from", "a", "&", "delimited", "parameter", "list" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L379-L388
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.getActionResultText
public String getActionResultText(String action, String params, TokenResult token, Object pFormData, String format) throws Exception { String queryUrl = siteurl + scriptPath + apiPath + "action=" + action + "&format=" + format; ClientResponse response; // decide for the method to use for api access response = this.getPostResponse(queryUrl, params, token, pFormData); String text = this.getResponseString(response); return text; }
java
public String getActionResultText(String action, String params, TokenResult token, Object pFormData, String format) throws Exception { String queryUrl = siteurl + scriptPath + apiPath + "action=" + action + "&format=" + format; ClientResponse response; // decide for the method to use for api access response = this.getPostResponse(queryUrl, params, token, pFormData); String text = this.getResponseString(response); return text; }
[ "public", "String", "getActionResultText", "(", "String", "action", ",", "String", "params", ",", "TokenResult", "token", ",", "Object", "pFormData", ",", "String", "format", ")", "throws", "Exception", "{", "String", "queryUrl", "=", "siteurl", "+", "scriptPath...
get the action result for the given parameters @param action @param params @param token @param pFormData @param format - json or xml @return the String e.g. xml or json @throws Exception
[ "get", "the", "action", "result", "for", "the", "given", "parameters" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L402-L411
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.getActionResult
public Api getActionResult(String action, String params, TokenResult token, Object pFormData, String format) throws Exception { String text = this.getActionResultText(action, params, token, pFormData, format); Api api = null; if ("xml".equals(format)) { if (debug) { // convert the xml to a more readable format String xmlDebug = text.replace(">", ">\n"); LOGGER.log(Level.INFO, xmlDebug); } if (text.startsWith("<?xml version")) api = fromXML(text); else { LOGGER.log(Level.SEVERE, text); throw new Exception("invalid xml:" + text); } } else if ("json".equals(format)) { if (debug) { LOGGER.log(Level.INFO, text.substring(0, Math.min(240, text.length() - 1))); } if (gson == null) gson = new Gson(); api = gson.fromJson(text, Api.class); api.setRawJson(text); } else { throw new IllegalStateException("unknown format " + format); } return api; }
java
public Api getActionResult(String action, String params, TokenResult token, Object pFormData, String format) throws Exception { String text = this.getActionResultText(action, params, token, pFormData, format); Api api = null; if ("xml".equals(format)) { if (debug) { // convert the xml to a more readable format String xmlDebug = text.replace(">", ">\n"); LOGGER.log(Level.INFO, xmlDebug); } if (text.startsWith("<?xml version")) api = fromXML(text); else { LOGGER.log(Level.SEVERE, text); throw new Exception("invalid xml:" + text); } } else if ("json".equals(format)) { if (debug) { LOGGER.log(Level.INFO, text.substring(0, Math.min(240, text.length() - 1))); } if (gson == null) gson = new Gson(); api = gson.fromJson(text, Api.class); api.setRawJson(text); } else { throw new IllegalStateException("unknown format " + format); } return api; }
[ "public", "Api", "getActionResult", "(", "String", "action", ",", "String", "params", ",", "TokenResult", "token", ",", "Object", "pFormData", ",", "String", "format", ")", "throws", "Exception", "{", "String", "text", "=", "this", ".", "getActionResultText", ...
get the result for the given action and params @param action @param params @param token (may be null) @param formData (may be null) @format - the format to use e.g. json or xml @return the API result for the action @throws Exception
[ "get", "the", "result", "for", "the", "given", "action", "and", "params" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L426-L456
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.getActionResult
public Api getActionResult(String action, String params, TokenResult token, Object pFormData) throws Exception { return getActionResult(action, params, token, pFormData, format); }
java
public Api getActionResult(String action, String params, TokenResult token, Object pFormData) throws Exception { return getActionResult(action, params, token, pFormData, format); }
[ "public", "Api", "getActionResult", "(", "String", "action", ",", "String", "params", ",", "TokenResult", "token", ",", "Object", "pFormData", ")", "throws", "Exception", "{", "return", "getActionResult", "(", "action", ",", "params", ",", "token", ",", "pForm...
get the action result for the default format @param action @param params @param token @param pFormData @return - the action result @throws Exception
[ "get", "the", "action", "result", "for", "the", "default", "format" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L468-L471
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.getActionResult
public Api getActionResult(String action, String params) throws Exception { Api result = this.getActionResult(action, params, null, null); return result; }
java
public Api getActionResult(String action, String params) throws Exception { Api result = this.getActionResult(action, params, null, null); return result; }
[ "public", "Api", "getActionResult", "(", "String", "action", ",", "String", "params", ")", "throws", "Exception", "{", "Api", "result", "=", "this", ".", "getActionResult", "(", "action", ",", "params", ",", "null", ",", "null", ")", ";", "return", "result...
get the result for the given action and query @param action @param params @return the API result for the action @throws Exception
[ "get", "the", "result", "for", "the", "given", "action", "and", "query" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L481-L484
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.getQueryResult
public Api getQueryResult(String query) throws Exception { Api result = this.getActionResult("query", query, null, null); return result; }
java
public Api getQueryResult(String query) throws Exception { Api result = this.getActionResult("query", query, null, null); return result; }
[ "public", "Api", "getQueryResult", "(", "String", "query", ")", "throws", "Exception", "{", "Api", "result", "=", "this", ".", "getActionResult", "(", "\"query\"", ",", "query", ",", "null", ",", "null", ")", ";", "return", "result", ";", "}" ]
get the Result for the given query @param query @return the API result for the query @throws Exception
[ "get", "the", "Result", "for", "the", "given", "query" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L493-L496
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.prepareLogin
public TokenResult prepareLogin(String username) throws Exception { username = encode(username); Api apiResult = null; TokenResult token = new TokenResult(); token.tokenName = "lgtoken"; token.tokenMode = TokenMode.token1_19; // see https://github.com/WolfgangFahl/Mediawiki-Japi/issues/31 if (this.isVersion128()) { apiResult = this.getQueryResult("&meta=tokens&type=login"); super.handleError(apiResult); token.token = apiResult.getQuery().getTokens().getLogintoken(); } else { apiResult = getActionResult("login", "&lgname=" + username, null, null); super.handleError(apiResult); Login login = apiResult.getLogin(); token.token = login.getToken(); } return token; }
java
public TokenResult prepareLogin(String username) throws Exception { username = encode(username); Api apiResult = null; TokenResult token = new TokenResult(); token.tokenName = "lgtoken"; token.tokenMode = TokenMode.token1_19; // see https://github.com/WolfgangFahl/Mediawiki-Japi/issues/31 if (this.isVersion128()) { apiResult = this.getQueryResult("&meta=tokens&type=login"); super.handleError(apiResult); token.token = apiResult.getQuery().getTokens().getLogintoken(); } else { apiResult = getActionResult("login", "&lgname=" + username, null, null); super.handleError(apiResult); Login login = apiResult.getLogin(); token.token = login.getToken(); } return token; }
[ "public", "TokenResult", "prepareLogin", "(", "String", "username", ")", "throws", "Exception", "{", "username", "=", "encode", "(", "username", ")", ";", "Api", "apiResult", "=", "null", ";", "TokenResult", "token", "=", "new", "TokenResult", "(", ")", ";",...
prepare the login by getting the login token @param username @return the ApiResult @throws Exception
[ "prepare", "the", "login", "by", "getting", "the", "login", "token" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L569-L587
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.login
public Login login(String username, String password, String domain) throws Exception { // login is a two step process // first we get a token TokenResult token = prepareLogin(username); // and then with the token we login using the password Login login = login(token, username, password, domain); return login; }
java
public Login login(String username, String password, String domain) throws Exception { // login is a two step process // first we get a token TokenResult token = prepareLogin(username); // and then with the token we login using the password Login login = login(token, username, password, domain); return login; }
[ "public", "Login", "login", "(", "String", "username", ",", "String", "password", ",", "String", "domain", ")", "throws", "Exception", "{", "// login is a two step process", "// first we get a token", "TokenResult", "token", "=", "prepareLogin", "(", "username", ")", ...
login with the given username, password and domain @param username @param password @param domain @return Login @throws Exception
[ "login", "with", "the", "given", "username", "password", "and", "domain" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L659-L667
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.login
public Login login(String username, String password) throws Exception { return login(username, password, null); }
java
public Login login(String username, String password) throws Exception { return login(username, password, null); }
[ "public", "Login", "login", "(", "String", "username", ",", "String", "password", ")", "throws", "Exception", "{", "return", "login", "(", "username", ",", "password", ",", "null", ")", ";", "}" ]
login with the given username and password @param username @param password @return Login @throws Exception
[ "login", "with", "the", "given", "username", "and", "password" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L677-L679
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.logout
public void logout() throws Exception { Api apiResult = getActionResult("logout", "", null, null); if (apiResult != null) { userid = null; // FIXME check apiResult } if (cookies != null) { cookies.clear(); cookies = null; } }
java
public void logout() throws Exception { Api apiResult = getActionResult("logout", "", null, null); if (apiResult != null) { userid = null; // FIXME check apiResult } if (cookies != null) { cookies.clear(); cookies = null; } }
[ "public", "void", "logout", "(", ")", "throws", "Exception", "{", "Api", "apiResult", "=", "getActionResult", "(", "\"logout\"", ",", "\"\"", ",", "null", ",", "null", ")", ";", "if", "(", "apiResult", "!=", "null", ")", "{", "userid", "=", "null", ";"...
end the session @throws Exception
[ "end", "the", "session" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L692-L702
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.getSectionText
public String getSectionText(String pageTitle, int sectionNumber) throws Exception { String result = this.getPageContent(pageTitle, "&rvsection=" + sectionNumber, false); return result; }
java
public String getSectionText(String pageTitle, int sectionNumber) throws Exception { String result = this.getPageContent(pageTitle, "&rvsection=" + sectionNumber, false); return result; }
[ "public", "String", "getSectionText", "(", "String", "pageTitle", ",", "int", "sectionNumber", ")", "throws", "Exception", "{", "String", "result", "=", "this", ".", "getPageContent", "(", "pageTitle", ",", "\"&rvsection=\"", "+", "sectionNumber", ",", "false", ...
get the text for the given section @param pageTitle @param sectionNumber @return @throws Exception
[ "get", "the", "text", "for", "the", "given", "section" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L799-L804
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.getParse
public Parse getParse(String params) throws Exception { String action = "parse"; Api api = getActionResult(action, params); super.handleError(api); return api.getParse(); }
java
public Parse getParse(String params) throws Exception { String action = "parse"; Api api = getActionResult(action, params); super.handleError(api); return api.getParse(); }
[ "public", "Parse", "getParse", "(", "String", "params", ")", "throws", "Exception", "{", "String", "action", "=", "\"parse\"", ";", "Api", "api", "=", "getActionResult", "(", "action", ",", "params", ")", ";", "super", ".", "handleError", "(", "api", ")", ...
get the parse Result for the given params @param params @return the Parse Result @throws Exception
[ "get", "the", "parse", "Result", "for", "the", "given", "params" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L829-L834
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.upload
public synchronized void upload(InputStream fileToUpload, String filename, String contents, String comment) throws Exception { TokenResult token = getEditToken("File:" + filename, "edit"); final FormDataMultiPart multiPart = new FormDataMultiPart(); // http://stackoverflow.com/questions/5772225/trying-to-upload-a-file-to-a-jax-rs-jersey-server multiPart.bodyPart(new StreamDataBodyPart("file", fileToUpload)); multiPart.field("filename", filename); multiPart.field("ignorewarnings", "true"); multiPart.field("text", contents); if (!comment.isEmpty()) multiPart.field("comment", comment); String params = ""; Api api = this.getActionResult("upload", params, token, multiPart); handleError(api); }
java
public synchronized void upload(InputStream fileToUpload, String filename, String contents, String comment) throws Exception { TokenResult token = getEditToken("File:" + filename, "edit"); final FormDataMultiPart multiPart = new FormDataMultiPart(); // http://stackoverflow.com/questions/5772225/trying-to-upload-a-file-to-a-jax-rs-jersey-server multiPart.bodyPart(new StreamDataBodyPart("file", fileToUpload)); multiPart.field("filename", filename); multiPart.field("ignorewarnings", "true"); multiPart.field("text", contents); if (!comment.isEmpty()) multiPart.field("comment", comment); String params = ""; Api api = this.getActionResult("upload", params, token, multiPart); handleError(api); }
[ "public", "synchronized", "void", "upload", "(", "InputStream", "fileToUpload", ",", "String", "filename", ",", "String", "contents", ",", "String", "comment", ")", "throws", "Exception", "{", "TokenResult", "token", "=", "getEditToken", "(", "\"File:\"", "+", "...
upload from the given inputstream @param fileToUpload @param filename @param contents @param comment @throws Exception
[ "upload", "from", "the", "given", "inputstream" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L1094-L1108
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.showVersion
public static void showVersion() { System.err.println("Mediawiki-Japi Version: " + VERSION); System.err.println(); System.err .println(" github: https://github.com/WolfgangFahl/Mediawiki-Japi"); System.err.println(""); }
java
public static void showVersion() { System.err.println("Mediawiki-Japi Version: " + VERSION); System.err.println(); System.err .println(" github: https://github.com/WolfgangFahl/Mediawiki-Japi"); System.err.println(""); }
[ "public", "static", "void", "showVersion", "(", ")", "{", "System", ".", "err", ".", "println", "(", "\"Mediawiki-Japi Version: \"", "+", "VERSION", ")", ";", "System", ".", "err", ".", "println", "(", ")", ";", "System", ".", "err", ".", "println", "(",...
show the Version
[ "show", "the", "Version" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L1195-L1201
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.usage
public void usage(String msg) { System.err.println(msg); showVersion(); System.err.println(" usage: java com.bitplan.mediawiki.japi.Mediawiki"); parser.printUsage(System.err); exitCode = 1; }
java
public void usage(String msg) { System.err.println(msg); showVersion(); System.err.println(" usage: java com.bitplan.mediawiki.japi.Mediawiki"); parser.printUsage(System.err); exitCode = 1; }
[ "public", "void", "usage", "(", "String", "msg", ")", "{", "System", ".", "err", ".", "println", "(", "msg", ")", ";", "showVersion", "(", ")", ";", "System", ".", "err", ".", "println", "(", "\" usage: java com.bitplan.mediawiki.japi.Mediawiki\"", ")", ";"...
show a usage
[ "show", "a", "usage" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L1206-L1213
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.createAccount
public Api createAccount(String name, String eMail, String realname, boolean mailpassword, String reason, String language) throws Exception { String createtoken="?"; if (getVersion().compareToIgnoreCase("Mediawiki 1.27") >= 0) { Api apiResult = this.getQueryResult("&meta=tokens&type=createaccount"); super.handleError(apiResult); createtoken = apiResult.getQuery().getTokens().getCreateaccounttoken(); } Api api=null; if (getVersion().compareToIgnoreCase("Mediawiki 1.27") >= 0) { Map<String, String> lFormData = new HashMap<String, String>(); lFormData.put("createtoken",createtoken); lFormData.put("username",name); lFormData.put("email",eMail); lFormData.put("realname",realname); lFormData.put("mailpassword", mailpassword?"1":"0"); lFormData.put("reason", reason); lFormData.put("createcontinue", "1"); String params=""; api = getActionResult("createaccount", params,null,lFormData); } else { String params = "&name=" + this.encode(name); params += "&email=" + this.encode(eMail); params += "&realname=" + this.encode(realname); params += "&mailpassword=" + mailpassword; params += "&reason=" + this.encode(reason); params += "&token="; api = getActionResult("createaccount", params); handleError(api); String token = api.getCreateaccount().getToken(); params += token; api = getActionResult("createaccount", params); } return api; }
java
public Api createAccount(String name, String eMail, String realname, boolean mailpassword, String reason, String language) throws Exception { String createtoken="?"; if (getVersion().compareToIgnoreCase("Mediawiki 1.27") >= 0) { Api apiResult = this.getQueryResult("&meta=tokens&type=createaccount"); super.handleError(apiResult); createtoken = apiResult.getQuery().getTokens().getCreateaccounttoken(); } Api api=null; if (getVersion().compareToIgnoreCase("Mediawiki 1.27") >= 0) { Map<String, String> lFormData = new HashMap<String, String>(); lFormData.put("createtoken",createtoken); lFormData.put("username",name); lFormData.put("email",eMail); lFormData.put("realname",realname); lFormData.put("mailpassword", mailpassword?"1":"0"); lFormData.put("reason", reason); lFormData.put("createcontinue", "1"); String params=""; api = getActionResult("createaccount", params,null,lFormData); } else { String params = "&name=" + this.encode(name); params += "&email=" + this.encode(eMail); params += "&realname=" + this.encode(realname); params += "&mailpassword=" + mailpassword; params += "&reason=" + this.encode(reason); params += "&token="; api = getActionResult("createaccount", params); handleError(api); String token = api.getCreateaccount().getToken(); params += token; api = getActionResult("createaccount", params); } return api; }
[ "public", "Api", "createAccount", "(", "String", "name", ",", "String", "eMail", ",", "String", "realname", ",", "boolean", "mailpassword", ",", "String", "reason", ",", "String", "language", ")", "throws", "Exception", "{", "String", "createtoken", "=", "\"?\...
create the given user account @param name @param eMail @param realname @param mailpassword @param reason @param language @throws Exception
[ "create", "the", "given", "user", "account" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L1307-L1341
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.sortByTitleAndFilterDoubles
public List<Rc> sortByTitleAndFilterDoubles(List<Rc> rcList) { List<Rc> result = new ArrayList<Rc>(); List<Rc> sorted = new ArrayList<Rc>(); sorted.addAll(rcList); Collections.sort(sorted, new Comparator<Rc>() { @Override public int compare(Rc lRc, Rc rRc) { int result = lRc.getTitle().compareTo(rRc.getTitle()); if (result == 0) { result = rRc.getTimestamp().compare(lRc.getTimestamp()); } return result; } }); Rc previous = null; for (Rc rc : sorted) { if (previous == null || (!rc.getTitle().equals(previous.getTitle()))) { result.add(rc); } previous = rc; } Collections.sort(result, new Comparator<Rc>() { @Override public int compare(Rc lRc, Rc rRc) { int result = rRc.getTimestamp().compare(lRc.getTimestamp()); return result; } }); return result; }
java
public List<Rc> sortByTitleAndFilterDoubles(List<Rc> rcList) { List<Rc> result = new ArrayList<Rc>(); List<Rc> sorted = new ArrayList<Rc>(); sorted.addAll(rcList); Collections.sort(sorted, new Comparator<Rc>() { @Override public int compare(Rc lRc, Rc rRc) { int result = lRc.getTitle().compareTo(rRc.getTitle()); if (result == 0) { result = rRc.getTimestamp().compare(lRc.getTimestamp()); } return result; } }); Rc previous = null; for (Rc rc : sorted) { if (previous == null || (!rc.getTitle().equals(previous.getTitle()))) { result.add(rc); } previous = rc; } Collections.sort(result, new Comparator<Rc>() { @Override public int compare(Rc lRc, Rc rRc) { int result = rRc.getTimestamp().compare(lRc.getTimestamp()); return result; } }); return result; }
[ "public", "List", "<", "Rc", ">", "sortByTitleAndFilterDoubles", "(", "List", "<", "Rc", ">", "rcList", ")", "{", "List", "<", "Rc", ">", "result", "=", "new", "ArrayList", "<", "Rc", ">", "(", ")", ";", "List", "<", "Rc", ">", "sorted", "=", "new"...
sort the given List by title and filter double titles @param rcList @return
[ "sort", "the", "given", "List", "by", "title", "and", "filter", "double", "titles" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L1445-L1474
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.dateToMWTimeStamp
public String dateToMWTimeStamp(Date date) { SimpleDateFormat mwTimeStampFormat = new SimpleDateFormat("yyyyMMddHHmmss"); String result = mwTimeStampFormat.format(date); return result; }
java
public String dateToMWTimeStamp(Date date) { SimpleDateFormat mwTimeStampFormat = new SimpleDateFormat("yyyyMMddHHmmss"); String result = mwTimeStampFormat.format(date); return result; }
[ "public", "String", "dateToMWTimeStamp", "(", "Date", "date", ")", "{", "SimpleDateFormat", "mwTimeStampFormat", "=", "new", "SimpleDateFormat", "(", "\"yyyyMMddHHmmss\"", ")", ";", "String", "result", "=", "mwTimeStampFormat", ".", "format", "(", "date", ")", ";"...
convert a data to a MediaWiki API timestamp @param date @return
[ "convert", "a", "data", "to", "a", "MediaWiki", "API", "timestamp" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L1482-L1486
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java
Mediawiki.getMostRecentChanges
public List<Rc> getMostRecentChanges(int days, int rcLimit) throws Exception { Date today = new Date(); Calendar cal = new GregorianCalendar(); cal.setTime(today); cal.add(Calendar.DAY_OF_MONTH, -days); Date date30daysbefore = cal.getTime(); String rcstart = dateToMWTimeStamp(today); String rcend = dateToMWTimeStamp(date30daysbefore); List<Rc> rcList = this.getRecentChanges(rcstart, rcend, rcLimit); List<Rc> result = this.sortByTitleAndFilterDoubles(rcList); return result; }
java
public List<Rc> getMostRecentChanges(int days, int rcLimit) throws Exception { Date today = new Date(); Calendar cal = new GregorianCalendar(); cal.setTime(today); cal.add(Calendar.DAY_OF_MONTH, -days); Date date30daysbefore = cal.getTime(); String rcstart = dateToMWTimeStamp(today); String rcend = dateToMWTimeStamp(date30daysbefore); List<Rc> rcList = this.getRecentChanges(rcstart, rcend, rcLimit); List<Rc> result = this.sortByTitleAndFilterDoubles(rcList); return result; }
[ "public", "List", "<", "Rc", ">", "getMostRecentChanges", "(", "int", "days", ",", "int", "rcLimit", ")", "throws", "Exception", "{", "Date", "today", "=", "new", "Date", "(", ")", ";", "Calendar", "cal", "=", "new", "GregorianCalendar", "(", ")", ";", ...
get the most recent changes @param days @param rcLimit @return @throws Exception
[ "get", "the", "most", "recent", "changes" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/Mediawiki.java#L1496-L1507
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/MediaWikiApiImpl.java
MediaWikiApiImpl.handleError
protected void handleError(String errMsg) throws Exception { // log it LOGGER.log(Level.SEVERE, errMsg); // and throw an error if this is configured if (this.isThrowExceptionOnError()) { throw new Exception(errMsg); } }
java
protected void handleError(String errMsg) throws Exception { // log it LOGGER.log(Level.SEVERE, errMsg); // and throw an error if this is configured if (this.isThrowExceptionOnError()) { throw new Exception(errMsg); } }
[ "protected", "void", "handleError", "(", "String", "errMsg", ")", "throws", "Exception", "{", "// log it", "LOGGER", ".", "log", "(", "Level", ".", "SEVERE", ",", "errMsg", ")", ";", "// and throw an error if this is configured", "if", "(", "this", ".", "isThrow...
handle the given error Message according to the exception setting @param errMsg @throws Exception
[ "handle", "the", "given", "error", "Message", "according", "to", "the", "exception", "setting" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/MediaWikiApiImpl.java#L95-L102
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/MediaWikiApiImpl.java
MediaWikiApiImpl.handleError
protected void handleError(Error error) throws Exception { String errMsg="error: "+error.getCode()+" info: "+error.getInfo(); handleError(errMsg); }
java
protected void handleError(Error error) throws Exception { String errMsg="error: "+error.getCode()+" info: "+error.getInfo(); handleError(errMsg); }
[ "protected", "void", "handleError", "(", "Error", "error", ")", "throws", "Exception", "{", "String", "errMsg", "=", "\"error: \"", "+", "error", ".", "getCode", "(", ")", "+", "\" info: \"", "+", "error", ".", "getInfo", "(", ")", ";", "handleError", "(",...
handle the given api error @param error @throws Exception
[ "handle", "the", "given", "api", "error" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/MediaWikiApiImpl.java#L109-L112
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/MediaWikiApiImpl.java
MediaWikiApiImpl.fromXML
public Api fromXML(String xml) throws Exception { // retrieve the JAXB wrapper representation from the xml received Api api = Api.fromXML(xml); // check whether an error code was sent Error error = api.getError(); // if there is an error - handle it if (error != null) { // prepare the error message String errMsg = "error code=" + error.getCode() + " info:'" + error.getInfo() + "'"; this.handleError(errMsg); } return api; }
java
public Api fromXML(String xml) throws Exception { // retrieve the JAXB wrapper representation from the xml received Api api = Api.fromXML(xml); // check whether an error code was sent Error error = api.getError(); // if there is an error - handle it if (error != null) { // prepare the error message String errMsg = "error code=" + error.getCode() + " info:'" + error.getInfo() + "'"; this.handleError(errMsg); } return api; }
[ "public", "Api", "fromXML", "(", "String", "xml", ")", "throws", "Exception", "{", "// retrieve the JAXB wrapper representation from the xml received", "Api", "api", "=", "Api", ".", "fromXML", "(", "xml", ")", ";", "// check whether an error code was sent", "Error", "e...
return Api from the given xml @param xml - the xml go unmarshal @return @throws Exception
[ "return", "Api", "from", "the", "given", "xml" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/MediaWikiApiImpl.java#L143-L156
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/MediaWikiApiImpl.java
MediaWikiApiImpl.encode
protected String encode(String param) throws Exception { String result = URLEncoder.encode(param, "UTF-8"); return result; }
java
protected String encode(String param) throws Exception { String result = URLEncoder.encode(param, "UTF-8"); return result; }
[ "protected", "String", "encode", "(", "String", "param", ")", "throws", "Exception", "{", "String", "result", "=", "URLEncoder", ".", "encode", "(", "param", ",", "\"UTF-8\"", ")", ";", "return", "result", ";", "}" ]
request parameter encoding @param param @return an encoded url parameter @throws Exception
[ "request", "parameter", "encoding" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/MediaWikiApiImpl.java#L239-L242
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/MediaWikiApiImpl.java
MediaWikiApiImpl.decode
protected String decode(String html) throws Exception { String result=StringEscapeUtils.unescapeHtml4(html); return result; }
java
protected String decode(String html) throws Exception { String result=StringEscapeUtils.unescapeHtml4(html); return result; }
[ "protected", "String", "decode", "(", "String", "html", ")", "throws", "Exception", "{", "String", "result", "=", "StringEscapeUtils", ".", "unescapeHtml4", "(", "html", ")", ";", "return", "result", ";", "}" ]
decode the given html markup @param html @return decoded html @throws Exception
[ "decode", "the", "given", "html", "markup" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/MediaWikiApiImpl.java#L250-L253
train
WolfgangFahl/Mediawiki-Japi
src/main/java/com/bitplan/mediawiki/japi/MediaWikiApiImpl.java
MediaWikiApiImpl.normalizeTitle
public String normalizeTitle(String title) throws Exception { String result = encode(title); result=result.replace("+","_"); return result; }
java
public String normalizeTitle(String title) throws Exception { String result = encode(title); result=result.replace("+","_"); return result; }
[ "public", "String", "normalizeTitle", "(", "String", "title", ")", "throws", "Exception", "{", "String", "result", "=", "encode", "(", "title", ")", ";", "result", "=", "result", ".", "replace", "(", "\"+\"", ",", "\"_\"", ")", ";", "return", "result", "...
normalize the given page title @param title @return the normalized title e.g. replacing blanks FIXME encode is not good enough @throws Exception
[ "normalize", "the", "given", "page", "title" ]
78d0177ebfe02eb05da5550839727861f1e888a5
https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/MediaWikiApiImpl.java#L263-L267
train
lastaflute/lastaflute
src/main/java/org/lastaflute/db/dbflute/accesscontext/SuspendedAccessContext.java
SuspendedAccessContext.getAccessContextOnThread
public static AccessContext getAccessContextOnThread() { final Stack<AccessContext> stack = threadLocal.get(); return stack != null ? stack.peek() : null; }
java
public static AccessContext getAccessContextOnThread() { final Stack<AccessContext> stack = threadLocal.get(); return stack != null ? stack.peek() : null; }
[ "public", "static", "AccessContext", "getAccessContextOnThread", "(", ")", "{", "final", "Stack", "<", "AccessContext", ">", "stack", "=", "threadLocal", ".", "get", "(", ")", ";", "return", "stack", "!=", "null", "?", "stack", ".", "peek", "(", ")", ":", ...
Get prepared access-context on thread. @return The context of DB access. (NullAllowed)
[ "Get", "prepared", "access", "-", "context", "on", "thread", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/db/dbflute/accesscontext/SuspendedAccessContext.java#L34-L37
train
lastaflute/lastaflute
src/main/java/org/lastaflute/db/dbflute/accesscontext/SuspendedAccessContext.java
SuspendedAccessContext.setAccessContextOnThread
public static void setAccessContextOnThread(AccessContext accessContext) { if (accessContext == null) { String msg = "The argument[accessContext] must not be null."; throw new IllegalArgumentException(msg); } Stack<AccessContext> stack = threadLocal.get(); if (stack == null) { stack = new Stack<AccessContext>(); threadLocal.set(stack); } stack.add(accessContext); }
java
public static void setAccessContextOnThread(AccessContext accessContext) { if (accessContext == null) { String msg = "The argument[accessContext] must not be null."; throw new IllegalArgumentException(msg); } Stack<AccessContext> stack = threadLocal.get(); if (stack == null) { stack = new Stack<AccessContext>(); threadLocal.set(stack); } stack.add(accessContext); }
[ "public", "static", "void", "setAccessContextOnThread", "(", "AccessContext", "accessContext", ")", "{", "if", "(", "accessContext", "==", "null", ")", "{", "String", "msg", "=", "\"The argument[accessContext] must not be null.\"", ";", "throw", "new", "IllegalArgumentE...
Set prepared access-context on thread. @param accessContext The context of DB access. (NotNull)
[ "Set", "prepared", "access", "-", "context", "on", "thread", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/db/dbflute/accesscontext/SuspendedAccessContext.java#L43-L54
train
lastaflute/lastaflute
src/main/java/org/lastaflute/db/dbflute/accesscontext/SuspendedAccessContext.java
SuspendedAccessContext.isExistAccessContextOnThread
public static boolean isExistAccessContextOnThread() { final Stack<AccessContext> stack = threadLocal.get(); return stack != null ? !stack.isEmpty() : false; }
java
public static boolean isExistAccessContextOnThread() { final Stack<AccessContext> stack = threadLocal.get(); return stack != null ? !stack.isEmpty() : false; }
[ "public", "static", "boolean", "isExistAccessContextOnThread", "(", ")", "{", "final", "Stack", "<", "AccessContext", ">", "stack", "=", "threadLocal", ".", "get", "(", ")", ";", "return", "stack", "!=", "null", "?", "!", "stack", ".", "isEmpty", "(", ")",...
Is existing prepared access-context on thread? @return The determination, true or false.
[ "Is", "existing", "prepared", "access", "-", "context", "on", "thread?" ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/db/dbflute/accesscontext/SuspendedAccessContext.java#L60-L63
train
lastaflute/lastaflute
src/main/java/org/lastaflute/web/servlet/request/ResponseDownloadPerformer.java
ResponseDownloadPerformer.downloadStreamCall
public void downloadStreamCall(ResponseDownloadResource resource, HttpServletResponse response) { final WrittenStreamCall streamCall = resource.getStreamCall(); if (streamCall == null) { String msg = "Either byte data or input stream is required: " + resource; throw new IllegalArgumentException(msg); } try { final Integer contentLength = resource.getContentLength(); if (contentLength != null) { response.setContentLength(contentLength); } final OutputStream out = response.getOutputStream(); try { streamCall.callback(createWrittenStreamOut(out)); flushDownloadStream(out); } finally { closeDownloadStream(out); } } catch (RuntimeException e) { throw new ResponseDownloadFailureException("Failed to download the input stream: " + resource, e); } catch (IOException e) { handleDownloadIOException(resource, e); } }
java
public void downloadStreamCall(ResponseDownloadResource resource, HttpServletResponse response) { final WrittenStreamCall streamCall = resource.getStreamCall(); if (streamCall == null) { String msg = "Either byte data or input stream is required: " + resource; throw new IllegalArgumentException(msg); } try { final Integer contentLength = resource.getContentLength(); if (contentLength != null) { response.setContentLength(contentLength); } final OutputStream out = response.getOutputStream(); try { streamCall.callback(createWrittenStreamOut(out)); flushDownloadStream(out); } finally { closeDownloadStream(out); } } catch (RuntimeException e) { throw new ResponseDownloadFailureException("Failed to download the input stream: " + resource, e); } catch (IOException e) { handleDownloadIOException(resource, e); } }
[ "public", "void", "downloadStreamCall", "(", "ResponseDownloadResource", "resource", ",", "HttpServletResponse", "response", ")", "{", "final", "WrittenStreamCall", "streamCall", "=", "resource", ".", "getStreamCall", "(", ")", ";", "if", "(", "streamCall", "==", "n...
switched to stream call way for closing headache
[ "switched", "to", "stream", "call", "way", "for", "closing", "headache" ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/servlet/request/ResponseDownloadPerformer.java#L77-L100
train
lastaflute/lastaflute
src/main/java/org/lastaflute/core/magic/TransactionTimeContext.java
TransactionTimeContext.getTransactionTime
public static Date getTransactionTime() { final Stack<Date> stack = threadLocal.get(); return stack != null ? stack.peek() : null; }
java
public static Date getTransactionTime() { final Stack<Date> stack = threadLocal.get(); return stack != null ? stack.peek() : null; }
[ "public", "static", "Date", "getTransactionTime", "(", ")", "{", "final", "Stack", "<", "Date", ">", "stack", "=", "threadLocal", ".", "get", "(", ")", ";", "return", "stack", "!=", "null", "?", "stack", ".", "peek", "(", ")", ":", "null", ";", "}" ]
Get the value of the transaction time. @return The value of the transaction time. (NullAllowed)
[ "Get", "the", "value", "of", "the", "transaction", "time", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/core/magic/TransactionTimeContext.java#L35-L38
train
lastaflute/lastaflute
src/main/java/org/lastaflute/core/magic/TransactionTimeContext.java
TransactionTimeContext.setTransactionTime
public static void setTransactionTime(Date transactionTime) { if (transactionTime == null) { String msg = "The argument 'transactionTime' should not be null."; throw new IllegalArgumentException(msg); } Stack<Date> stack = threadLocal.get(); if (stack == null) { stack = new Stack<Date>(); threadLocal.set(stack); } stack.push(transactionTime); }
java
public static void setTransactionTime(Date transactionTime) { if (transactionTime == null) { String msg = "The argument 'transactionTime' should not be null."; throw new IllegalArgumentException(msg); } Stack<Date> stack = threadLocal.get(); if (stack == null) { stack = new Stack<Date>(); threadLocal.set(stack); } stack.push(transactionTime); }
[ "public", "static", "void", "setTransactionTime", "(", "Date", "transactionTime", ")", "{", "if", "(", "transactionTime", "==", "null", ")", "{", "String", "msg", "=", "\"The argument 'transactionTime' should not be null.\"", ";", "throw", "new", "IllegalArgumentExcepti...
Set the value of the transaction time. @param transactionTime The value of the transaction time. (NotNull)
[ "Set", "the", "value", "of", "the", "transaction", "time", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/core/magic/TransactionTimeContext.java#L44-L55
train
lastaflute/lastaflute
src/main/java/org/lastaflute/web/ruts/config/ActionMapping.java
ActionMapping.findActionExecute
public ActionExecute findActionExecute(String paramPath) { // null allowed when not found for (ActionExecute execute : executeMap.values()) { if (execute.determineTargetByPathParameter(paramPath)) { return execute; } } return null; }
java
public ActionExecute findActionExecute(String paramPath) { // null allowed when not found for (ActionExecute execute : executeMap.values()) { if (execute.determineTargetByPathParameter(paramPath)) { return execute; } } return null; }
[ "public", "ActionExecute", "findActionExecute", "(", "String", "paramPath", ")", "{", "// null allowed when not found", "for", "(", "ActionExecute", "execute", ":", "executeMap", ".", "values", "(", ")", ")", "{", "if", "(", "execute", ".", "determineTargetByPathPar...
optional unused for performance
[ "optional", "unused", "for", "performance" ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/ruts/config/ActionMapping.java#L79-L86
train
lastaflute/lastaflute
src/main/java/org/lastaflute/core/mail/LaTypicalPostcard.java
LaTypicalPostcard.doSetFrom
protected void doSetFrom(String from, String personal) { assertArgumentNotEmpty("from", from); assertArgumentNotEmpty("personal", personal); // only from required postcard.setFrom(createAddress(from, personal)); }
java
protected void doSetFrom(String from, String personal) { assertArgumentNotEmpty("from", from); assertArgumentNotEmpty("personal", personal); // only from required postcard.setFrom(createAddress(from, personal)); }
[ "protected", "void", "doSetFrom", "(", "String", "from", ",", "String", "personal", ")", "{", "assertArgumentNotEmpty", "(", "\"from\"", ",", "from", ")", ";", "assertArgumentNotEmpty", "(", "\"personal\"", ",", "personal", ")", ";", "// only from required", "post...
public methods are prepared at sub-class
[ "public", "methods", "are", "prepared", "at", "sub", "-", "class" ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/core/mail/LaTypicalPostcard.java#L112-L116
train
lastaflute/lastaflute
src/main/java/org/lastaflute/core/mail/LaTypicalPostcard.java
LaTypicalPostcard.pushLogging
public void pushLogging(String key, Object value) { assertArgumentNotNull("key", key); assertArgumentNotNull("value", value); postcard.pushLogging(key, value); }
java
public void pushLogging(String key, Object value) { assertArgumentNotNull("key", key); assertArgumentNotNull("value", value); postcard.pushLogging(key, value); }
[ "public", "void", "pushLogging", "(", "String", "key", ",", "Object", "value", ")", "{", "assertArgumentNotNull", "(", "\"key\"", ",", "key", ")", ";", "assertArgumentNotNull", "(", "\"value\"", ",", "value", ")", ";", "postcard", ".", "pushLogging", "(", "k...
Push element of mail logging. @param key The key of the element. (NotNull) @param value The value of the element. (NotNull)
[ "Push", "element", "of", "mail", "logging", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/core/mail/LaTypicalPostcard.java#L272-L276
train
lastaflute/lastaflute
src/main/java/org/lastaflute/core/interceptor/ControllableBaseInterceptor.java
ControllableBaseInterceptor.createAnnotationTypeList
protected List<Class<? extends Annotation>> createAnnotationTypeList(Class<?>... annotations) { final List<Class<? extends Annotation>> annotationList = new ArrayList<Class<? extends Annotation>>(); for (Class<?> annoType : annotations) { @SuppressWarnings("unchecked") final Class<? extends Annotation> castType = (Class<? extends Annotation>) annoType; annotationList.add(castType); } return annotationList; }
java
protected List<Class<? extends Annotation>> createAnnotationTypeList(Class<?>... annotations) { final List<Class<? extends Annotation>> annotationList = new ArrayList<Class<? extends Annotation>>(); for (Class<?> annoType : annotations) { @SuppressWarnings("unchecked") final Class<? extends Annotation> castType = (Class<? extends Annotation>) annoType; annotationList.add(castType); } return annotationList; }
[ "protected", "List", "<", "Class", "<", "?", "extends", "Annotation", ">", ">", "createAnnotationTypeList", "(", "Class", "<", "?", ">", "...", "annotations", ")", "{", "final", "List", "<", "Class", "<", "?", "extends", "Annotation", ">", ">", "annotation...
for Generic headache. @param annotations The array of annotation. (NotNull, EmptyAllowed) @return The list of annotation type. (NotNull, EmptyAllowed)
[ "for", "Generic", "headache", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/core/interceptor/ControllableBaseInterceptor.java#L93-L101
train
lastaflute/lastaflute
src/main/java/org/lastaflute/web/hook/GodHandPrologue.java
GodHandPrologue.createSqlStringFilter
protected SqlStringFilter createSqlStringFilter(ActionRuntime runtime) { final Method actionMethod = runtime.getExecuteMethod(); return newRomanticTraceableSqlStringFilter(actionMethod, () -> { return buildSqlMarkingAdditionalInfo(); // lazy because it may be auto-login later }); }
java
protected SqlStringFilter createSqlStringFilter(ActionRuntime runtime) { final Method actionMethod = runtime.getExecuteMethod(); return newRomanticTraceableSqlStringFilter(actionMethod, () -> { return buildSqlMarkingAdditionalInfo(); // lazy because it may be auto-login later }); }
[ "protected", "SqlStringFilter", "createSqlStringFilter", "(", "ActionRuntime", "runtime", ")", "{", "final", "Method", "actionMethod", "=", "runtime", ".", "getExecuteMethod", "(", ")", ";", "return", "newRomanticTraceableSqlStringFilter", "(", "actionMethod", ",", "(",...
Create the filter of SQL string for DBFlute. @param runtime The runtime meta of action execute. (NotNull) @return The filter of SQL string. (NullAllowed: if null, no filter)
[ "Create", "the", "filter", "of", "SQL", "string", "for", "DBFlute", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/hook/GodHandPrologue.java#L169-L174
train
lastaflute/lastaflute
src/main/java/org/lastaflute/web/hook/GodHandPrologue.java
GodHandPrologue.checkLoginRequired
protected void checkLoginRequired(ActionRuntime runtime) throws LoginRequiredException { loginManager.ifPresent(nager -> { nager.checkLoginRequired(createLogingHandlingResource(runtime)); }); }
java
protected void checkLoginRequired(ActionRuntime runtime) throws LoginRequiredException { loginManager.ifPresent(nager -> { nager.checkLoginRequired(createLogingHandlingResource(runtime)); }); }
[ "protected", "void", "checkLoginRequired", "(", "ActionRuntime", "runtime", ")", "throws", "LoginRequiredException", "{", "loginManager", ".", "ifPresent", "(", "nager", "->", "{", "nager", ".", "checkLoginRequired", "(", "createLogingHandlingResource", "(", "runtime", ...
Check the login required for the requested action. @param runtime The runtime meta of action execute to determine required action. (NotNull) @throws LoginRequiredException When it fails to access the action for non-login.
[ "Check", "the", "login", "required", "for", "the", "requested", "action", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/hook/GodHandPrologue.java#L215-L219
train
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/model/CollectionDataModel.java
CollectionDataModel.setWrappedData
public void setWrappedData(Object data) { if (data == null) { inner = null; arrayFromInner = null; setRowIndex(-1); } else { inner = (Collection<E>) data; arrayFromInner = (E[]) new Object[inner.size()]; inner.toArray(arrayFromInner); setRowIndex(0); } }
java
public void setWrappedData(Object data) { if (data == null) { inner = null; arrayFromInner = null; setRowIndex(-1); } else { inner = (Collection<E>) data; arrayFromInner = (E[]) new Object[inner.size()]; inner.toArray(arrayFromInner); setRowIndex(0); } }
[ "public", "void", "setWrappedData", "(", "Object", "data", ")", "{", "if", "(", "data", "==", "null", ")", "{", "inner", "=", "null", ";", "arrayFromInner", "=", "null", ";", "setRowIndex", "(", "-", "1", ")", ";", "}", "else", "{", "inner", "=", "...
Set the wrapped data. @param data the wrapped data. @throws ClassCastException if <code>data</code> is non-<code>null</code> and is not a <code>Collection</code>
[ "Set", "the", "wrapped", "data", "." ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/model/CollectionDataModel.java#L210-L221
train
lastaflute/lastaflute
src/main/java/org/lastaflute/core/template/SimpleTemplateManager.java
SimpleTemplateManager.createSqlAnalyzer
protected SqlAnalyzer createSqlAnalyzer(String templateText, boolean blockNullParameter) { final SqlAnalyzer analyzer = new SqlAnalyzer(templateText, blockNullParameter) { @Override protected String filterAtFirst(String sql) { return sql; // keep body } @Override protected EmbeddedVariableNode newEmbeddedVariableNode(String expr, String testValue, String specifiedSql, boolean blockNullParameter, NodeAdviceFactory adviceFactory, boolean replaceOnly, boolean terminalDot, boolean overlookNativeBinding) { return createTemplikeEmbeddedVariableNode(expr, testValue, specifiedSql, blockNullParameter, adviceFactory, replaceOnly, terminalDot, overlookNativeBinding); } }.overlookNativeBinding().switchBindingToReplaceOnlyEmbedded(); // adjust for plain template return analyzer; }
java
protected SqlAnalyzer createSqlAnalyzer(String templateText, boolean blockNullParameter) { final SqlAnalyzer analyzer = new SqlAnalyzer(templateText, blockNullParameter) { @Override protected String filterAtFirst(String sql) { return sql; // keep body } @Override protected EmbeddedVariableNode newEmbeddedVariableNode(String expr, String testValue, String specifiedSql, boolean blockNullParameter, NodeAdviceFactory adviceFactory, boolean replaceOnly, boolean terminalDot, boolean overlookNativeBinding) { return createTemplikeEmbeddedVariableNode(expr, testValue, specifiedSql, blockNullParameter, adviceFactory, replaceOnly, terminalDot, overlookNativeBinding); } }.overlookNativeBinding().switchBindingToReplaceOnlyEmbedded(); // adjust for plain template return analyzer; }
[ "protected", "SqlAnalyzer", "createSqlAnalyzer", "(", "String", "templateText", ",", "boolean", "blockNullParameter", ")", "{", "final", "SqlAnalyzer", "analyzer", "=", "new", "SqlAnalyzer", "(", "templateText", ",", "blockNullParameter", ")", "{", "@", "Override", ...
almost same as mailflute
[ "almost", "same", "as", "mailflute" ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/core/template/SimpleTemplateManager.java#L236-L252
train
lastaflute/lastaflute
src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java
TypicalLoginAssist.findLoginUser
@Override public OptionalEntity<USER_ENTITY> findLoginUser(Object userId) { assertUserIdRequired(userId); try { @SuppressWarnings("unchecked") final ID castId = (ID) userId; return doFindLoginUser(castId); } catch (ClassCastException e) { // also find method, because of generic cast throw new IllegalStateException("Cannot cast the user ID: " + userId.getClass() + ", " + userId, e); } }
java
@Override public OptionalEntity<USER_ENTITY> findLoginUser(Object userId) { assertUserIdRequired(userId); try { @SuppressWarnings("unchecked") final ID castId = (ID) userId; return doFindLoginUser(castId); } catch (ClassCastException e) { // also find method, because of generic cast throw new IllegalStateException("Cannot cast the user ID: " + userId.getClass() + ", " + userId, e); } }
[ "@", "Override", "public", "OptionalEntity", "<", "USER_ENTITY", ">", "findLoginUser", "(", "Object", "userId", ")", "{", "assertUserIdRequired", "(", "userId", ")", ";", "try", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "final", "ID", "castId", ...
Find the login user in the database. @param userId for the login user. (NotNull) @return The optional entity of the found user. (NotNull, EmptyAllowed: when the login user is not found)
[ "Find", "the", "login", "user", "in", "the", "database", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java#L217-L227
train
lastaflute/lastaflute
src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java
TypicalLoginAssist.doLogin
protected void doLogin(LoginCredential credential, LoginSpecifiedOption option) throws LoginFailureException { handleLoginSuccess(findLoginUser(credential).orElseThrow(() -> { final String msg = "Not found the user by the credential: " + credential + ", " + option; return handleLoginFailure(msg, credential, OptionalThing.of(option)); }), option); }
java
protected void doLogin(LoginCredential credential, LoginSpecifiedOption option) throws LoginFailureException { handleLoginSuccess(findLoginUser(credential).orElseThrow(() -> { final String msg = "Not found the user by the credential: " + credential + ", " + option; return handleLoginFailure(msg, credential, OptionalThing.of(option)); }), option); }
[ "protected", "void", "doLogin", "(", "LoginCredential", "credential", ",", "LoginSpecifiedOption", "option", ")", "throws", "LoginFailureException", "{", "handleLoginSuccess", "(", "findLoginUser", "(", "credential", ")", ".", "orElseThrow", "(", "(", ")", "->", "{"...
Do actually login for the user by credential. @param credential The login credential for the login user. (NotNull) @param option The option of login specified by caller. (NotNull) @throws LoginFailureException When it fails to do login by the user info.
[ "Do", "actually", "login", "for", "the", "user", "by", "credential", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java#L280-L285
train
lastaflute/lastaflute
src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java
TypicalLoginAssist.handleLoginSuccess
protected void handleLoginSuccess(USER_ENTITY userEntity, LoginSpecifiedOption option) { assertUserEntityRequired(userEntity); final USER_BEAN userBean = saveLoginInfoToSession(userEntity); if (userBean instanceof SyncCheckable) { ((SyncCheckable) userBean).manageLastestSyncCheckTime(timeManager.currentDateTime()); } if (option.isRememberMe()) { saveRememberMeKeyToCookie(userEntity, userBean); } if (!option.isSilentLogin()) { // mainly here saveLoginHistory(userEntity, userBean, option); processOnBrightLogin(userEntity, userBean, option); } else { processOnSilentLogin(userEntity, userBean, option); } }
java
protected void handleLoginSuccess(USER_ENTITY userEntity, LoginSpecifiedOption option) { assertUserEntityRequired(userEntity); final USER_BEAN userBean = saveLoginInfoToSession(userEntity); if (userBean instanceof SyncCheckable) { ((SyncCheckable) userBean).manageLastestSyncCheckTime(timeManager.currentDateTime()); } if (option.isRememberMe()) { saveRememberMeKeyToCookie(userEntity, userBean); } if (!option.isSilentLogin()) { // mainly here saveLoginHistory(userEntity, userBean, option); processOnBrightLogin(userEntity, userBean, option); } else { processOnSilentLogin(userEntity, userBean, option); } }
[ "protected", "void", "handleLoginSuccess", "(", "USER_ENTITY", "userEntity", ",", "LoginSpecifiedOption", "option", ")", "{", "assertUserEntityRequired", "(", "userEntity", ")", ";", "final", "USER_BEAN", "userBean", "=", "saveLoginInfoToSession", "(", "userEntity", ")"...
Handle login success for the found login user. @param userEntity The found entity of the login user. (NotNull) @param option The option of login specified by caller. (NotNull)
[ "Handle", "login", "success", "for", "the", "found", "login", "user", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java#L316-L331
train
lastaflute/lastaflute
src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java
TypicalLoginAssist.saveLoginInfoToSession
protected USER_BEAN saveLoginInfoToSession(USER_ENTITY userEntity) { regenerateSessionId(); logger.debug("...Saving login info to session"); final USER_BEAN userBean = createUserBean(userEntity); sessionManager.setAttribute(getUserBeanKey(), userBean); return userBean; }
java
protected USER_BEAN saveLoginInfoToSession(USER_ENTITY userEntity) { regenerateSessionId(); logger.debug("...Saving login info to session"); final USER_BEAN userBean = createUserBean(userEntity); sessionManager.setAttribute(getUserBeanKey(), userBean); return userBean; }
[ "protected", "USER_BEAN", "saveLoginInfoToSession", "(", "USER_ENTITY", "userEntity", ")", "{", "regenerateSessionId", "(", ")", ";", "logger", ".", "debug", "(", "\"...Saving login info to session\"", ")", ";", "final", "USER_BEAN", "userBean", "=", "createUserBean", ...
Save login info as user bean to session. @param userEntity The entity of the found user. (NotNull) @return The user bean saved in session. (NotNull)
[ "Save", "login", "info", "as", "user", "bean", "to", "session", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java#L349-L355
train
lastaflute/lastaflute
src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java
TypicalLoginAssist.saveRememberMeKeyToCookie
protected void saveRememberMeKeyToCookie(USER_ENTITY userEntity, USER_BEAN userBean) { final int expireDays = getRememberMeAccessTokenExpireDays(); getCookieRememberMeKey().ifPresent(cookieKey -> { doSaveRememberMeCookie(userEntity, userBean, expireDays, cookieKey); }); }
java
protected void saveRememberMeKeyToCookie(USER_ENTITY userEntity, USER_BEAN userBean) { final int expireDays = getRememberMeAccessTokenExpireDays(); getCookieRememberMeKey().ifPresent(cookieKey -> { doSaveRememberMeCookie(userEntity, userBean, expireDays, cookieKey); }); }
[ "protected", "void", "saveRememberMeKeyToCookie", "(", "USER_ENTITY", "userEntity", ",", "USER_BEAN", "userBean", ")", "{", "final", "int", "expireDays", "=", "getRememberMeAccessTokenExpireDays", "(", ")", ";", "getCookieRememberMeKey", "(", ")", ".", "ifPresent", "(...
Save remember-me key to cookie. @param userEntity The selected entity of login user. (NotNull) @param userBean The user bean saved in session. (NotNull)
[ "Save", "remember", "-", "me", "key", "to", "cookie", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java#L407-L412
train
lastaflute/lastaflute
src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java
TypicalLoginAssist.doSaveRememberMeCookie
protected void doSaveRememberMeCookie(USER_ENTITY userEntity, USER_BEAN userBean, int expireDays, String cookieKey) { logger.debug("...Saving remember-me key to cookie: key={}", cookieKey); final String value = buildRememberMeCookieValue(userEntity, userBean, expireDays); final int expireSeconds = expireDays * 60 * 60 * 24; // cookie's expire, same as access token cookieManager.setCookieCiphered(cookieKey, value, expireSeconds); }
java
protected void doSaveRememberMeCookie(USER_ENTITY userEntity, USER_BEAN userBean, int expireDays, String cookieKey) { logger.debug("...Saving remember-me key to cookie: key={}", cookieKey); final String value = buildRememberMeCookieValue(userEntity, userBean, expireDays); final int expireSeconds = expireDays * 60 * 60 * 24; // cookie's expire, same as access token cookieManager.setCookieCiphered(cookieKey, value, expireSeconds); }
[ "protected", "void", "doSaveRememberMeCookie", "(", "USER_ENTITY", "userEntity", ",", "USER_BEAN", "userBean", ",", "int", "expireDays", ",", "String", "cookieKey", ")", "{", "logger", ".", "debug", "(", "\"...Saving remember-me key to cookie: key={}\"", ",", "cookieKey...
Do save remember-me key to cookie. @param userEntity The selected entity of login user. (NotNull) @param userBean The user bean saved in session. (NotNull) @param expireDays The expire days of both access token and cookie value. @param cookieKey The key of the cookie. (NotNull)
[ "Do", "save", "remember", "-", "me", "key", "to", "cookie", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java#L436-L441
train
lastaflute/lastaflute
src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java
TypicalLoginAssist.isValidRememberMeCookie
protected boolean isValidRememberMeCookie(String userKey, String expireDate) { final String currentDate = formatForRememberMeExpireDate(timeManager.currentHandyDate()); if (currentDate.compareTo(expireDate) < 0) { // String v.s. String return true; // valid access token within time limit } // expired here logger.debug("The access token for remember-me expired: userKey={} expireDate={}", userKey, expireDate); return false; }
java
protected boolean isValidRememberMeCookie(String userKey, String expireDate) { final String currentDate = formatForRememberMeExpireDate(timeManager.currentHandyDate()); if (currentDate.compareTo(expireDate) < 0) { // String v.s. String return true; // valid access token within time limit } // expired here logger.debug("The access token for remember-me expired: userKey={} expireDate={}", userKey, expireDate); return false; }
[ "protected", "boolean", "isValidRememberMeCookie", "(", "String", "userKey", ",", "String", "expireDate", ")", "{", "final", "String", "currentDate", "=", "formatForRememberMeExpireDate", "(", "timeManager", ".", "currentHandyDate", "(", ")", ")", ";", "if", "(", ...
Are the user ID and expire date extracted from cookie valid? @param userKey The key of the login user. (NotNull) @param expireDate The string expression for expire date of remember-me access token. (NotNull) @return Is a validation for remember-me OK?
[ "Are", "the", "user", "ID", "and", "expire", "date", "extracted", "from", "cookie", "valid?" ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java#L593-L601
train
lastaflute/lastaflute
src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java
TypicalLoginAssist.doRememberMe
protected boolean doRememberMe(ID userId, String expireDate, RememberMeLoginSpecifiedOption option) { final boolean updateToken = option.isUpdateToken(); final boolean silentLogin = option.isSilentLogin(); if (logger.isDebugEnabled()) { final StringBuilder sb = new StringBuilder(); sb.append("...Doing remember-me: user=").append(userId); sb.append(", expire=").append(expireDate); if (updateToken) { sb.append(", updateToken"); } if (silentLogin) { sb.append(", silently"); } logger.debug(sb.toString()); } try { identityLogin(userId, op -> op.rememberMe(updateToken).silentLogin(silentLogin)); return true; } catch (NumberFormatException invalidUserKey) { // just in case // to know invalid user key or bug logger.debug("*The user key might be invalid: {}, {}", userId, invalidUserKey.getMessage()); return false; } catch (LoginFailureException autoLoginFailed) { return false; } }
java
protected boolean doRememberMe(ID userId, String expireDate, RememberMeLoginSpecifiedOption option) { final boolean updateToken = option.isUpdateToken(); final boolean silentLogin = option.isSilentLogin(); if (logger.isDebugEnabled()) { final StringBuilder sb = new StringBuilder(); sb.append("...Doing remember-me: user=").append(userId); sb.append(", expire=").append(expireDate); if (updateToken) { sb.append(", updateToken"); } if (silentLogin) { sb.append(", silently"); } logger.debug(sb.toString()); } try { identityLogin(userId, op -> op.rememberMe(updateToken).silentLogin(silentLogin)); return true; } catch (NumberFormatException invalidUserKey) { // just in case // to know invalid user key or bug logger.debug("*The user key might be invalid: {}, {}", userId, invalidUserKey.getMessage()); return false; } catch (LoginFailureException autoLoginFailed) { return false; } }
[ "protected", "boolean", "doRememberMe", "(", "ID", "userId", ",", "String", "expireDate", ",", "RememberMeLoginSpecifiedOption", "option", ")", "{", "final", "boolean", "updateToken", "=", "option", ".", "isUpdateToken", "(", ")", ";", "final", "boolean", "silentL...
Do actually remember-me for the user. @param userId The ID of the login user, used by identity login. (NotNull) @param expireDate The string expression for expire date of remember-me access token. (NotNull) @param option The option of remember-me login specified by caller. (NotNull) @return Is the remember-me success?
[ "Do", "actually", "remember", "-", "me", "for", "the", "user", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java#L635-L660
train
lastaflute/lastaflute
src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java
TypicalLoginAssist.asLoginRequired
protected void asLoginRequired(LoginHandlingResource resource) throws LoginRequiredException { logger.debug("...Checking login status for login required"); if (tryAlreadyLoginOrRememberMe(resource)) { checkPermission(resource); // throws if denied return; // Good } if (needsSavingRequestedLoginRedirect(resource)) { saveRequestedLoginRedirectInfo(); } throwLoginRequiredException("Cannot access the action: " + resource); }
java
protected void asLoginRequired(LoginHandlingResource resource) throws LoginRequiredException { logger.debug("...Checking login status for login required"); if (tryAlreadyLoginOrRememberMe(resource)) { checkPermission(resource); // throws if denied return; // Good } if (needsSavingRequestedLoginRedirect(resource)) { saveRequestedLoginRedirectInfo(); } throwLoginRequiredException("Cannot access the action: " + resource); }
[ "protected", "void", "asLoginRequired", "(", "LoginHandlingResource", "resource", ")", "throws", "LoginRequiredException", "{", "logger", ".", "debug", "(", "\"...Checking login status for login required\"", ")", ";", "if", "(", "tryAlreadyLoginOrRememberMe", "(", "resource...
Check as the login-required action. @param resource The resource of login handling to determine. (NotNull) @throws LoginRequiredException When it fails to access the action for non-login.
[ "Check", "as", "the", "login", "-", "required", "action", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java#L705-L715
train
lastaflute/lastaflute
src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java
TypicalLoginAssist.asNonLoginRequired
protected void asNonLoginRequired(LoginHandlingResource resource) throws LoginRequiredException { if (!isSuppressRememberMeOfNonLoginRequired(resource)) { // option just in case logger.debug("...Checking login status for non login required"); if (tryAlreadyLoginOrRememberMe(resource)) { checkPermission(resource); // throws if denied return; // Good } } if (isLoginRedirectBeanKeptAction(resource)) { // keep login-redirect path in session logger.debug("...Passing login check as login action (or redirect-kept action)"); } else { clearLoginRedirectBean(); logger.debug("...Passing login check as non login required"); } }
java
protected void asNonLoginRequired(LoginHandlingResource resource) throws LoginRequiredException { if (!isSuppressRememberMeOfNonLoginRequired(resource)) { // option just in case logger.debug("...Checking login status for non login required"); if (tryAlreadyLoginOrRememberMe(resource)) { checkPermission(resource); // throws if denied return; // Good } } if (isLoginRedirectBeanKeptAction(resource)) { // keep login-redirect path in session logger.debug("...Passing login check as login action (or redirect-kept action)"); } else { clearLoginRedirectBean(); logger.debug("...Passing login check as non login required"); } }
[ "protected", "void", "asNonLoginRequired", "(", "LoginHandlingResource", "resource", ")", "throws", "LoginRequiredException", "{", "if", "(", "!", "isSuppressRememberMeOfNonLoginRequired", "(", "resource", ")", ")", "{", "// option just in case", "logger", ".", "debug", ...
Check as the non login required action. @param resource The resource of login handling to determine. (NotNull) @throws LoginRequiredException When it fails to access the action for login authority.
[ "Check", "as", "the", "non", "login", "required", "action", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/login/TypicalLoginAssist.java#L874-L889
train
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/ComponentStateHelper.java
ComponentStateHelper.remove
public Object remove(Serializable key) { if(component.initialStateMarked()) { Object retVal = deltaMap.remove(key); if(retVal==null) { return defaultMap.remove(key); } else { defaultMap.remove(key); return retVal; } } else { return defaultMap.remove(key); } }
java
public Object remove(Serializable key) { if(component.initialStateMarked()) { Object retVal = deltaMap.remove(key); if(retVal==null) { return defaultMap.remove(key); } else { defaultMap.remove(key); return retVal; } } else { return defaultMap.remove(key); } }
[ "public", "Object", "remove", "(", "Serializable", "key", ")", "{", "if", "(", "component", ".", "initialStateMarked", "(", ")", ")", "{", "Object", "retVal", "=", "deltaMap", ".", "remove", "(", "key", ")", ";", "if", "(", "retVal", "==", "null", ")",...
We need to remove from both maps, if we do remove an existing key. @param key @return the removed object in the delta-map. if not present, the removed object from the main map
[ "We", "need", "to", "remove", "from", "both", "maps", "if", "we", "do", "remove", "an", "existing", "key", "." ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/ComponentStateHelper.java#L116-L131
train
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/ComponentStateHelper.java
ComponentStateHelper.saveState
public Object saveState(FacesContext context) { if (context == null) { throw new NullPointerException(); } if(component.initialStateMarked()) { return saveMap(context, deltaMap); } else { return saveMap(context, defaultMap); } }
java
public Object saveState(FacesContext context) { if (context == null) { throw new NullPointerException(); } if(component.initialStateMarked()) { return saveMap(context, deltaMap); } else { return saveMap(context, defaultMap); } }
[ "public", "Object", "saveState", "(", "FacesContext", "context", ")", "{", "if", "(", "context", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", ")", ";", "}", "if", "(", "component", ".", "initialStateMarked", "(", ")", ")", "{", "r...
One and only implementation of save-state - makes all other implementations unnecessary. @param context @return the saved state
[ "One", "and", "only", "implementation", "of", "save", "-", "state", "-", "makes", "all", "other", "implementations", "unnecessary", "." ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/ComponentStateHelper.java#L251-L261
train
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/ComponentStateHelper.java
ComponentStateHelper.restoreState
public void restoreState(FacesContext context, Object state) { if (context == null) { throw new NullPointerException(); } if (state == null) { return; } if (!component.initialStateMarked() && !defaultMap.isEmpty()) { defaultMap.clear(); if(deltaMap != null && !deltaMap.isEmpty()) { deltaMap.clear(); } } Object[] savedState = (Object[]) state; if (savedState[savedState.length - 1] != null) { component.initialState = (Boolean) savedState[savedState.length - 1]; } int length = (savedState.length-1)/2; for (int i = 0; i < length; i++) { Object value = savedState[i * 2 + 1]; Serializable serializable = (Serializable) savedState[i * 2]; if (value != null) { if (value instanceof Collection) { value = restoreAttachedState(context, value); } else if (value instanceof StateHolderSaver) { value = ((StateHolderSaver) value).restore(context); } else { value = (value instanceof Serializable ? value : restoreAttachedState(context, value)); } } if (value instanceof Map) { for (Map.Entry<String, Object> entry : ((Map<String, Object>) value) .entrySet()) { this.put(serializable, entry.getKey(), entry.getValue()); } } else if (value instanceof List) { List<Object> list = (List) get(serializable); for (Object o : ((List<Object>) value)) { if (list == null || !list.contains(o)) { this.add(serializable, o); } } } else { put(serializable, value); } } }
java
public void restoreState(FacesContext context, Object state) { if (context == null) { throw new NullPointerException(); } if (state == null) { return; } if (!component.initialStateMarked() && !defaultMap.isEmpty()) { defaultMap.clear(); if(deltaMap != null && !deltaMap.isEmpty()) { deltaMap.clear(); } } Object[] savedState = (Object[]) state; if (savedState[savedState.length - 1] != null) { component.initialState = (Boolean) savedState[savedState.length - 1]; } int length = (savedState.length-1)/2; for (int i = 0; i < length; i++) { Object value = savedState[i * 2 + 1]; Serializable serializable = (Serializable) savedState[i * 2]; if (value != null) { if (value instanceof Collection) { value = restoreAttachedState(context, value); } else if (value instanceof StateHolderSaver) { value = ((StateHolderSaver) value).restore(context); } else { value = (value instanceof Serializable ? value : restoreAttachedState(context, value)); } } if (value instanceof Map) { for (Map.Entry<String, Object> entry : ((Map<String, Object>) value) .entrySet()) { this.put(serializable, entry.getKey(), entry.getValue()); } } else if (value instanceof List) { List<Object> list = (List) get(serializable); for (Object o : ((List<Object>) value)) { if (list == null || !list.contains(o)) { this.add(serializable, o); } } } else { put(serializable, value); } } }
[ "public", "void", "restoreState", "(", "FacesContext", "context", ",", "Object", "state", ")", "{", "if", "(", "context", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", ")", ";", "}", "if", "(", "state", "==", "null", ")", "{", "r...
One and only implementation of restore state. Makes all other implementations unnecessary. @param context FacesContext @param state the state to be restored.
[ "One", "and", "only", "implementation", "of", "restore", "state", ".", "Makes", "all", "other", "implementations", "unnecessary", "." ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/ComponentStateHelper.java#L273-L326
train
shevek/jcpp
src/main/java/org/anarres/cpp/SourceIterator.java
SourceIterator.advance
private void advance() { try { if (tok == null) tok = source.token(); } catch (LexerException e) { throw new IllegalStateException(e); } catch (IOException e) { throw new IllegalStateException(e); } }
java
private void advance() { try { if (tok == null) tok = source.token(); } catch (LexerException e) { throw new IllegalStateException(e); } catch (IOException e) { throw new IllegalStateException(e); } }
[ "private", "void", "advance", "(", ")", "{", "try", "{", "if", "(", "tok", "==", "null", ")", "tok", "=", "source", ".", "token", "(", ")", ";", "}", "catch", "(", "LexerException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ...
Rethrows IOException inside IllegalStateException.
[ "Rethrows", "IOException", "inside", "IllegalStateException", "." ]
71462c702097cabf8304202c740f780285fc35a8
https://github.com/shevek/jcpp/blob/71462c702097cabf8304202c740f780285fc35a8/src/main/java/org/anarres/cpp/SourceIterator.java#L42-L51
train
shevek/jcpp
src/main/java/org/anarres/cpp/SourceIterator.java
SourceIterator.next
@Override public Token next() { if (!hasNext()) throw new NoSuchElementException(); Token t = this.tok; this.tok = null; return t; }
java
@Override public Token next() { if (!hasNext()) throw new NoSuchElementException(); Token t = this.tok; this.tok = null; return t; }
[ "@", "Override", "public", "Token", "next", "(", ")", "{", "if", "(", "!", "hasNext", "(", ")", ")", "throw", "new", "NoSuchElementException", "(", ")", ";", "Token", "t", "=", "this", ".", "tok", ";", "this", ".", "tok", "=", "null", ";", "return"...
Returns the next token from the enclosed Source. The EOF token is never returned by the iterator. @throws IllegalStateException if the Source throws a LexerException or IOException
[ "Returns", "the", "next", "token", "from", "the", "enclosed", "Source", "." ]
71462c702097cabf8304202c740f780285fc35a8
https://github.com/shevek/jcpp/blob/71462c702097cabf8304202c740f780285fc35a8/src/main/java/org/anarres/cpp/SourceIterator.java#L73-L80
train
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/behavior/AjaxBehavior.java
AjaxBehavior.saveBindings
private static Object saveBindings(FacesContext context, Map<String, ValueExpression> bindings) { // Note: This code is copied from UIComponentBase. In a future // version of the JSF spec, it would be useful to define a // attribute/property/bindings/state helper object that can be // shared across components/behaviors/validaters/converters. if (bindings == null) { return (null); } Object values[] = new Object[2]; values[0] = bindings.keySet().toArray(new String[bindings.size()]); Object[] bindingValues = bindings.values().toArray(); for (int i = 0; i < bindingValues.length; i++) { bindingValues[i] = UIComponentBase.saveAttachedState(context, bindingValues[i]); } values[1] = bindingValues; return (values); }
java
private static Object saveBindings(FacesContext context, Map<String, ValueExpression> bindings) { // Note: This code is copied from UIComponentBase. In a future // version of the JSF spec, it would be useful to define a // attribute/property/bindings/state helper object that can be // shared across components/behaviors/validaters/converters. if (bindings == null) { return (null); } Object values[] = new Object[2]; values[0] = bindings.keySet().toArray(new String[bindings.size()]); Object[] bindingValues = bindings.values().toArray(); for (int i = 0; i < bindingValues.length; i++) { bindingValues[i] = UIComponentBase.saveAttachedState(context, bindingValues[i]); } values[1] = bindingValues; return (values); }
[ "private", "static", "Object", "saveBindings", "(", "FacesContext", "context", ",", "Map", "<", "String", ",", "ValueExpression", ">", "bindings", ")", "{", "// Note: This code is copied from UIComponentBase. In a future", "// version of the JSF spec, it would be useful to defin...
Utility for saving bindings state
[ "Utility", "for", "saving", "bindings", "state" ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/behavior/AjaxBehavior.java#L559-L582
train
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/behavior/AjaxBehavior.java
AjaxBehavior.restoreBindings
private static Map<String, ValueExpression> restoreBindings(FacesContext context, Object state) { // Note: This code is copied from UIComponentBase. See note above // in saveBindings(). if (state == null) { return (null); } Object values[] = (Object[]) state; String names[] = (String[]) values[0]; Object states[] = (Object[]) values[1]; Map<String, ValueExpression> bindings = new HashMap<String, ValueExpression>(names.length); for (int i = 0; i < names.length; i++) { bindings.put(names[i], (ValueExpression) UIComponentBase.restoreAttachedState(context, states[i])); } return (bindings); }
java
private static Map<String, ValueExpression> restoreBindings(FacesContext context, Object state) { // Note: This code is copied from UIComponentBase. See note above // in saveBindings(). if (state == null) { return (null); } Object values[] = (Object[]) state; String names[] = (String[]) values[0]; Object states[] = (Object[]) values[1]; Map<String, ValueExpression> bindings = new HashMap<String, ValueExpression>(names.length); for (int i = 0; i < names.length; i++) { bindings.put(names[i], (ValueExpression) UIComponentBase.restoreAttachedState(context, states[i])); } return (bindings); }
[ "private", "static", "Map", "<", "String", ",", "ValueExpression", ">", "restoreBindings", "(", "FacesContext", "context", ",", "Object", "state", ")", "{", "// Note: This code is copied from UIComponentBase. See note above", "// in saveBindings().", "if", "(", "state", ...
Utility for restoring bindings from state
[ "Utility", "for", "restoring", "bindings", "from", "state" ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/behavior/AjaxBehavior.java#L585-L603
train
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/behavior/AjaxBehavior.java
AjaxBehavior.setLiteralValue
private void setLiteralValue(String propertyName, ValueExpression expression) { assert(expression.isLiteralText()); Object value; ELContext context = FacesContext.getCurrentInstance().getELContext(); try { value = expression.getValue(context); } catch (ELException ele) { throw new FacesException(ele); } if (ONEVENT.equals(propertyName)) { onevent = (String)value; } else if (DELAY.equals(propertyName)) { delay = (String)value; } else if (ONERROR.equals(propertyName)) { onerror = (String)value; } else if (IMMEDIATE.equals(propertyName)) { immediate = (Boolean)value; } else if (RESET_VALUES.equals(propertyName)) { resetValues = (Boolean)value; } else if (DISABLED.equals(propertyName)) { disabled = (Boolean)value; } else if (EXECUTE.equals(propertyName)) { execute = toList(propertyName, expression, value); } else if (RENDER.equals(propertyName)) { render = toList(propertyName, expression, value); } }
java
private void setLiteralValue(String propertyName, ValueExpression expression) { assert(expression.isLiteralText()); Object value; ELContext context = FacesContext.getCurrentInstance().getELContext(); try { value = expression.getValue(context); } catch (ELException ele) { throw new FacesException(ele); } if (ONEVENT.equals(propertyName)) { onevent = (String)value; } else if (DELAY.equals(propertyName)) { delay = (String)value; } else if (ONERROR.equals(propertyName)) { onerror = (String)value; } else if (IMMEDIATE.equals(propertyName)) { immediate = (Boolean)value; } else if (RESET_VALUES.equals(propertyName)) { resetValues = (Boolean)value; } else if (DISABLED.equals(propertyName)) { disabled = (Boolean)value; } else if (EXECUTE.equals(propertyName)) { execute = toList(propertyName, expression, value); } else if (RENDER.equals(propertyName)) { render = toList(propertyName, expression, value); } }
[ "private", "void", "setLiteralValue", "(", "String", "propertyName", ",", "ValueExpression", "expression", ")", "{", "assert", "(", "expression", ".", "isLiteralText", "(", ")", ")", ";", "Object", "value", ";", "ELContext", "context", "=", "FacesContext", ".", ...
Sets a property, converting it from a literal
[ "Sets", "a", "property", "converting", "it", "from", "a", "literal" ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/behavior/AjaxBehavior.java#L689-L720
train
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/behavior/AjaxBehavior.java
AjaxBehavior.toSingletonList
private static List<String> toSingletonList(String propertyName, String value) { if ((null == value) || (value.length() == 0)) { return null; } if (value.charAt(0) == '@') { // These are very common, so we use shared copies // of these collections instead of re-creating. List<String> list; if (ALL.equals(value)) { list = ALL_LIST; } else if (FORM.equals(value)){ list = FORM_LIST; } else if (THIS.equals(value)) { list = THIS_LIST; } else if (NONE.equals(value)) { list = NONE_LIST; } else { // RELEASE_PENDING i18n ; throw new FacesException(value + " : Invalid id keyword specified for '" + propertyName + "' attribute"); } return list; } return Collections.singletonList(value); }
java
private static List<String> toSingletonList(String propertyName, String value) { if ((null == value) || (value.length() == 0)) { return null; } if (value.charAt(0) == '@') { // These are very common, so we use shared copies // of these collections instead of re-creating. List<String> list; if (ALL.equals(value)) { list = ALL_LIST; } else if (FORM.equals(value)){ list = FORM_LIST; } else if (THIS.equals(value)) { list = THIS_LIST; } else if (NONE.equals(value)) { list = NONE_LIST; } else { // RELEASE_PENDING i18n ; throw new FacesException(value + " : Invalid id keyword specified for '" + propertyName + "' attribute"); } return list; } return Collections.singletonList(value); }
[ "private", "static", "List", "<", "String", ">", "toSingletonList", "(", "String", "propertyName", ",", "String", "value", ")", "{", "if", "(", "(", "null", "==", "value", ")", "||", "(", "value", ".", "length", "(", ")", "==", "0", ")", ")", "{", ...
Converts a String with no spaces to a singleton list
[ "Converts", "a", "String", "with", "no", "spaces", "to", "a", "singleton", "list" ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/behavior/AjaxBehavior.java#L760-L791
train
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/UISelectMany.java
UISelectMany.toObjectArray
private static Object[] toObjectArray(Object primitiveArray) { if (primitiveArray == null) { throw new NullPointerException(); } if (primitiveArray instanceof Object[]) { return (Object[]) primitiveArray; } if (primitiveArray instanceof Collection) { return ((Collection) primitiveArray).toArray(); } Class clazz = primitiveArray.getClass(); if (!clazz.isArray()) { return null; } int length = Array.getLength(primitiveArray); Object[] array = new Object[length]; for (int i = 0; i < length; i++) { array[i] = Array.get(primitiveArray, i); } return array; }
java
private static Object[] toObjectArray(Object primitiveArray) { if (primitiveArray == null) { throw new NullPointerException(); } if (primitiveArray instanceof Object[]) { return (Object[]) primitiveArray; } if (primitiveArray instanceof Collection) { return ((Collection) primitiveArray).toArray(); } Class clazz = primitiveArray.getClass(); if (!clazz.isArray()) { return null; } int length = Array.getLength(primitiveArray); Object[] array = new Object[length]; for (int i = 0; i < length; i++) { array[i] = Array.get(primitiveArray, i); } return array; }
[ "private", "static", "Object", "[", "]", "toObjectArray", "(", "Object", "primitiveArray", ")", "{", "if", "(", "primitiveArray", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", ")", ";", "}", "if", "(", "primitiveArray", "instanceof", "...
Convert an array of primitives to an array of boxed objects. @param primitiveArray object containing the primitive values @return an Object array, or null if the incoming value is not in fact an array at all.
[ "Convert", "an", "array", "of", "primitives", "to", "an", "array", "of", "boxed", "objects", "." ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/UISelectMany.java#L517-L542
train
lastaflute/lastaflute
src/main/java/org/lastaflute/core/message/UserMessages.java
UserMessages.hasMessageOf
public boolean hasMessageOf(String property) { assertArgumentNotNull("property", property); final UserMessageItem item = getPropertyItem(property); return item != null && !item.getMessageList().isEmpty(); }
java
public boolean hasMessageOf(String property) { assertArgumentNotNull("property", property); final UserMessageItem item = getPropertyItem(property); return item != null && !item.getMessageList().isEmpty(); }
[ "public", "boolean", "hasMessageOf", "(", "String", "property", ")", "{", "assertArgumentNotNull", "(", "\"property\"", ",", "property", ")", ";", "final", "UserMessageItem", "item", "=", "getPropertyItem", "(", "property", ")", ";", "return", "item", "!=", "nul...
Does the property has user message? @param property the name of property, which may have user messages. (NotNull) @return The determination, true or false.
[ "Does", "the", "property", "has", "user", "message?" ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/core/message/UserMessages.java#L182-L186
train
lastaflute/lastaflute
src/main/java/org/lastaflute/core/message/UserMessages.java
UserMessages.hasMessageOf
public boolean hasMessageOf(String property, String messageKey) { assertArgumentNotNull("property", property); assertArgumentNotNull("messageKey", messageKey); final UserMessageItem item = getPropertyItem(property); return item != null && item.getMessageList().stream().anyMatch(message -> { final String myKey = resolveMessageKey(messageKey); if (message.isResource()) { if (myKey.equals(resolveMessageKey(message.getMessageKey()))) { return true; } } else { // direct message if (message.getValidatorMessageKey().filter(vlkey -> resolveMessageKey(vlkey).equals(myKey)).isPresent()) { return true; } } return false; }); }
java
public boolean hasMessageOf(String property, String messageKey) { assertArgumentNotNull("property", property); assertArgumentNotNull("messageKey", messageKey); final UserMessageItem item = getPropertyItem(property); return item != null && item.getMessageList().stream().anyMatch(message -> { final String myKey = resolveMessageKey(messageKey); if (message.isResource()) { if (myKey.equals(resolveMessageKey(message.getMessageKey()))) { return true; } } else { // direct message if (message.getValidatorMessageKey().filter(vlkey -> resolveMessageKey(vlkey).equals(myKey)).isPresent()) { return true; } } return false; }); }
[ "public", "boolean", "hasMessageOf", "(", "String", "property", ",", "String", "messageKey", ")", "{", "assertArgumentNotNull", "(", "\"property\"", ",", "property", ")", ";", "assertArgumentNotNull", "(", "\"messageKey\"", ",", "messageKey", ")", ";", "final", "U...
Does the property has user message for the message key? @param property the name of property, which may have user messages. (NotNull) @param messageKey The message key to find message. (NotNull) @return The determination, true or false.
[ "Does", "the", "property", "has", "user", "message", "for", "the", "message", "key?" ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/core/message/UserMessages.java#L194-L211
train
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/webapp/UIComponentClassicTagBase.java
UIComponentClassicTagBase._indexOfStartingFrom
private static int _indexOfStartingFrom(List<?> list, int startIndex, Object searchValue) { int itemCount = list.size(); boolean found = false; // start searching from location remembered from last time for (int currIndex = startIndex; currIndex < itemCount; currIndex++) { Object currId = list.get(currIndex); if ((searchValue == currId) || ((searchValue != null) && searchValue.equals(currId))) { return currIndex; } } // handle case where we started past the first item and didn't find the // searchValue. Now search from the beginning to where we started if (startIndex > 0) { for (int currIndex = 0; currIndex < startIndex; currIndex++) { Object currId = list.get(currIndex); if ((searchValue == currId) || ((searchValue != null) && searchValue.equals(currId))) { return currIndex; } } } // didn't find it return -1; }
java
private static int _indexOfStartingFrom(List<?> list, int startIndex, Object searchValue) { int itemCount = list.size(); boolean found = false; // start searching from location remembered from last time for (int currIndex = startIndex; currIndex < itemCount; currIndex++) { Object currId = list.get(currIndex); if ((searchValue == currId) || ((searchValue != null) && searchValue.equals(currId))) { return currIndex; } } // handle case where we started past the first item and didn't find the // searchValue. Now search from the beginning to where we started if (startIndex > 0) { for (int currIndex = 0; currIndex < startIndex; currIndex++) { Object currId = list.get(currIndex); if ((searchValue == currId) || ((searchValue != null) && searchValue.equals(currId))) { return currIndex; } } } // didn't find it return -1; }
[ "private", "static", "int", "_indexOfStartingFrom", "(", "List", "<", "?", ">", "list", ",", "int", "startIndex", ",", "Object", "searchValue", ")", "{", "int", "itemCount", "=", "list", ".", "size", "(", ")", ";", "boolean", "found", "=", "false", ";", ...
Similar to List.indexOf, except that we start searching from a specific index and then wrap aroud. For this to be performant, the List should implement RandomAccess. @param <T> @param list List to seatch @param startIndex index to start searching for value from @param searchValue Value to search for (null not supported) @return The index at which the value was first found, or -1 if not found
[ "Similar", "to", "List", ".", "indexOf", "except", "that", "we", "start", "searching", "from", "a", "specific", "index", "and", "then", "wrap", "aroud", ".", "For", "this", "to", "be", "performant", "the", "List", "should", "implement", "RandomAccess", "." ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/webapp/UIComponentClassicTagBase.java#L884-L918
train
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/UIComponent.java
UIComponent.findComponentResourceBundleLocaleMatch
private Resource findComponentResourceBundleLocaleMatch(FacesContext context, String resourceName, String libraryName) { Resource result = null; ResourceBundle resourceBundle = null; int i; if (-1 != (i = resourceName.lastIndexOf("."))) { resourceName = resourceName.substring(0, i) + ".properties"; if (null != context) { result = context.getApplication().getResourceHandler(). createResource(resourceName, libraryName); InputStream propertiesInputStream = null; try { propertiesInputStream = result.getInputStream(); resourceBundle = new PropertyResourceBundle(propertiesInputStream); } catch (IOException ex) { Logger.getLogger(UIComponent.class.getName()).log(Level.SEVERE, null, ex); } finally{ if(null != propertiesInputStream){ try{ propertiesInputStream.close(); } catch(IOException ioe){ if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.log(Level.SEVERE, null, ioe); } } } } } } result = (null != resourceBundle) ? result : null; return result; }
java
private Resource findComponentResourceBundleLocaleMatch(FacesContext context, String resourceName, String libraryName) { Resource result = null; ResourceBundle resourceBundle = null; int i; if (-1 != (i = resourceName.lastIndexOf("."))) { resourceName = resourceName.substring(0, i) + ".properties"; if (null != context) { result = context.getApplication().getResourceHandler(). createResource(resourceName, libraryName); InputStream propertiesInputStream = null; try { propertiesInputStream = result.getInputStream(); resourceBundle = new PropertyResourceBundle(propertiesInputStream); } catch (IOException ex) { Logger.getLogger(UIComponent.class.getName()).log(Level.SEVERE, null, ex); } finally{ if(null != propertiesInputStream){ try{ propertiesInputStream.close(); } catch(IOException ioe){ if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.log(Level.SEVERE, null, ioe); } } } } } } result = (null != resourceBundle) ? result : null; return result; }
[ "private", "Resource", "findComponentResourceBundleLocaleMatch", "(", "FacesContext", "context", ",", "String", "resourceName", ",", "String", "libraryName", ")", "{", "Resource", "result", "=", "null", ";", "ResourceBundle", "resourceBundle", "=", "null", ";", "int",...
way to handle this.
[ "way", "to", "handle", "this", "." ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/UIComponent.java#L1191-L1224
train
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/UIViewRoot.java
UIViewRoot.clearFacesEvents
private void clearFacesEvents(FacesContext context) { if (context.getRenderResponse() || context.getResponseComplete()) { if (events != null) { for (List<FacesEvent> eventList : events) { if (eventList != null) { eventList.clear(); } } events = null; } } }
java
private void clearFacesEvents(FacesContext context) { if (context.getRenderResponse() || context.getResponseComplete()) { if (events != null) { for (List<FacesEvent> eventList : events) { if (eventList != null) { eventList.clear(); } } events = null; } } }
[ "private", "void", "clearFacesEvents", "(", "FacesContext", "context", ")", "{", "if", "(", "context", ".", "getRenderResponse", "(", ")", "||", "context", ".", "getResponseComplete", "(", ")", ")", "{", "if", "(", "events", "!=", "null", ")", "{", "for", ...
or if there is a response complete signal.
[ "or", "if", "there", "is", "a", "response", "complete", "signal", "." ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/UIViewRoot.java#L1293-L1304
train
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/UIViewRoot.java
UIViewRoot.getLocaleFromString
private static Locale getLocaleFromString(String localeStr) throws IllegalArgumentException { // length must be at least 2. if (null == localeStr || localeStr.length() < 2) { throw new IllegalArgumentException("Illegal locale String: " + localeStr); } Locale result = null; String lang = null; String country = null; String variant = null; char[] seps = { '-', '_' }; int inputLength = localeStr.length(); int i = 0; int j = 0; // to have a language, the length must be >= 2 if ((inputLength >= 2) && ((i = indexOfSet(localeStr, seps, 0)) == -1)) { // we have only Language, no country or variant if (2 != localeStr.length()) { throw new IllegalArgumentException("Illegal locale String: " + localeStr); } lang = localeStr.toLowerCase(); } // we have a separator, it must be either '-' or '_' if (i != -1) { lang = localeStr.substring(0, i); // look for the country sep. // to have a country, the length must be >= 5 if ((inputLength >= 5) && (-1 == (j = indexOfSet(localeStr, seps, i + 1)))) { // no further separators, length must be 5 if (inputLength != 5) { throw new IllegalArgumentException("Illegal locale String: " + localeStr); } country = localeStr.substring(i + 1); } if (j != -1) { country = localeStr.substring(i + 1, j); // if we have enough separators for language, locale, // and variant, the length must be >= 8. if (inputLength >= 8) { variant = localeStr.substring(j + 1); } else { throw new IllegalArgumentException("Illegal locale String: " + localeStr); } } } if (variant != null && country != null && lang != null) { result = new Locale(lang, country, variant); } else if (lang != null && country != null) { result = new Locale(lang, country); } else if (lang != null) { result = new Locale(lang, ""); } return result; }
java
private static Locale getLocaleFromString(String localeStr) throws IllegalArgumentException { // length must be at least 2. if (null == localeStr || localeStr.length() < 2) { throw new IllegalArgumentException("Illegal locale String: " + localeStr); } Locale result = null; String lang = null; String country = null; String variant = null; char[] seps = { '-', '_' }; int inputLength = localeStr.length(); int i = 0; int j = 0; // to have a language, the length must be >= 2 if ((inputLength >= 2) && ((i = indexOfSet(localeStr, seps, 0)) == -1)) { // we have only Language, no country or variant if (2 != localeStr.length()) { throw new IllegalArgumentException("Illegal locale String: " + localeStr); } lang = localeStr.toLowerCase(); } // we have a separator, it must be either '-' or '_' if (i != -1) { lang = localeStr.substring(0, i); // look for the country sep. // to have a country, the length must be >= 5 if ((inputLength >= 5) && (-1 == (j = indexOfSet(localeStr, seps, i + 1)))) { // no further separators, length must be 5 if (inputLength != 5) { throw new IllegalArgumentException("Illegal locale String: " + localeStr); } country = localeStr.substring(i + 1); } if (j != -1) { country = localeStr.substring(i + 1, j); // if we have enough separators for language, locale, // and variant, the length must be >= 8. if (inputLength >= 8) { variant = localeStr.substring(j + 1); } else { throw new IllegalArgumentException("Illegal locale String: " + localeStr); } } } if (variant != null && country != null && lang != null) { result = new Locale(lang, country, variant); } else if (lang != null && country != null) { result = new Locale(lang, country); } else if (lang != null) { result = new Locale(lang, ""); } return result; }
[ "private", "static", "Locale", "getLocaleFromString", "(", "String", "localeStr", ")", "throws", "IllegalArgumentException", "{", "// length must be at least 2.", "if", "(", "null", "==", "localeStr", "||", "localeStr", ".", "length", "(", ")", "<", "2", ")", "{",...
language-country-variant.
[ "language", "-", "country", "-", "variant", "." ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/UIViewRoot.java#L1383-L1451
train
lastaflute/lastaflute
src/main/java/org/lastaflute/web/servlet/filter/RequestLoggingFilter.java
RequestLoggingFilter.convertToPerformanceView
protected String convertToPerformanceView(long afterMinusBefore) { // from DfTraceViewUtil.java if (afterMinusBefore < 0) { return String.valueOf(afterMinusBefore); } long sec = afterMinusBefore / 1000; final long min = sec / 60; sec = sec % 60; final long mil = afterMinusBefore % 1000; final StringBuffer sb = new StringBuffer(); if (min >= 10) { // Minute sb.append(min).append("m"); } else if (min < 10 && min >= 0) { sb.append("0").append(min).append("m"); } if (sec >= 10) { // Second sb.append(sec).append("s"); } else if (sec < 10 && sec >= 0) { sb.append("0").append(sec).append("s"); } if (mil >= 100) { // Millisecond sb.append(mil).append("ms"); } else if (mil < 100 && mil >= 10) { sb.append("0").append(mil).append("ms"); } else if (mil < 10 && mil >= 0) { sb.append("00").append(mil).append("ms"); } return sb.toString(); }
java
protected String convertToPerformanceView(long afterMinusBefore) { // from DfTraceViewUtil.java if (afterMinusBefore < 0) { return String.valueOf(afterMinusBefore); } long sec = afterMinusBefore / 1000; final long min = sec / 60; sec = sec % 60; final long mil = afterMinusBefore % 1000; final StringBuffer sb = new StringBuffer(); if (min >= 10) { // Minute sb.append(min).append("m"); } else if (min < 10 && min >= 0) { sb.append("0").append(min).append("m"); } if (sec >= 10) { // Second sb.append(sec).append("s"); } else if (sec < 10 && sec >= 0) { sb.append("0").append(sec).append("s"); } if (mil >= 100) { // Millisecond sb.append(mil).append("ms"); } else if (mil < 100 && mil >= 10) { sb.append("0").append(mil).append("ms"); } else if (mil < 10 && mil >= 0) { sb.append("00").append(mil).append("ms"); } return sb.toString(); }
[ "protected", "String", "convertToPerformanceView", "(", "long", "afterMinusBefore", ")", "{", "// from DfTraceViewUtil.java", "if", "(", "afterMinusBefore", "<", "0", ")", "{", "return", "String", ".", "valueOf", "(", "afterMinusBefore", ")", ";", "}", "long", "se...
Convert to performance view. @param afterMinusBefore The difference between before time and after time. @return The view string to show performance. e.g. 01m40s012ms (NotNull)
[ "Convert", "to", "performance", "view", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/servlet/filter/RequestLoggingFilter.java#L1251-L1281
train
lastaflute/lastaflute
src/main/java/org/lastaflute/web/ruts/message/objective/ObjectiveMessageResources.java
ObjectiveMessageResources.resolveLabelParameter
protected List<Object> resolveLabelParameter(Locale locale, String key, Object[] args) { final MessageResourceBundle bundle = getBundle(locale); if (args == null || args.length == 0) { return DfCollectionUtil.emptyList(); } final List<Object> resolvedList = new ArrayList<Object>(args.length); for (Object arg : args) { if (canBeLabelKey(arg)) { final String labelKey = (String) arg; final String label = bundle.get(labelKey); if (label != null) { resolvedList.add(label); continue; } else { throwMessageLabelByLabelParameterNotFoundException(locale, key, labelKey); } } resolvedList.add(arg); } return resolvedList; }
java
protected List<Object> resolveLabelParameter(Locale locale, String key, Object[] args) { final MessageResourceBundle bundle = getBundle(locale); if (args == null || args.length == 0) { return DfCollectionUtil.emptyList(); } final List<Object> resolvedList = new ArrayList<Object>(args.length); for (Object arg : args) { if (canBeLabelKey(arg)) { final String labelKey = (String) arg; final String label = bundle.get(labelKey); if (label != null) { resolvedList.add(label); continue; } else { throwMessageLabelByLabelParameterNotFoundException(locale, key, labelKey); } } resolvedList.add(arg); } return resolvedList; }
[ "protected", "List", "<", "Object", ">", "resolveLabelParameter", "(", "Locale", "locale", ",", "String", "key", ",", "Object", "[", "]", "args", ")", "{", "final", "MessageResourceBundle", "bundle", "=", "getBundle", "(", "locale", ")", ";", "if", "(", "a...
Resolve label parameters in the arguments. @param locale The locale of current request. (NullAllowed: when system default locale) @param key The key of the message, basically for exception message. (NotNull) @param args The array of arguments for message. (NullAllowed: if null, returns empty list) @return The list of filtered parameters resolved label arguments. (NotNull, EmptyAllowed)
[ "Resolve", "label", "parameters", "in", "the", "arguments", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/ruts/message/objective/ObjectiveMessageResources.java#L623-L643
train
shevek/jcpp
src/main/java/org/anarres/cpp/DefaultPreprocessorListener.java
DefaultPreprocessorListener.handleWarning
@Override public void handleWarning(Source source, int line, int column, String msg) throws LexerException { warnings++; print(source.getName() + ":" + line + ":" + column + ": warning: " + msg); }
java
@Override public void handleWarning(Source source, int line, int column, String msg) throws LexerException { warnings++; print(source.getName() + ":" + line + ":" + column + ": warning: " + msg); }
[ "@", "Override", "public", "void", "handleWarning", "(", "Source", "source", ",", "int", "line", ",", "int", "column", ",", "String", "msg", ")", "throws", "LexerException", "{", "warnings", "++", ";", "print", "(", "source", ".", "getName", "(", ")", "+...
Handles a warning. The behaviour of this method is defined by the implementation. It may simply record the error message, or it may throw an exception.
[ "Handles", "a", "warning", "." ]
71462c702097cabf8304202c740f780285fc35a8
https://github.com/shevek/jcpp/blob/71462c702097cabf8304202c740f780285fc35a8/src/main/java/org/anarres/cpp/DefaultPreprocessorListener.java#L68-L75
train
shevek/jcpp
src/main/java/org/anarres/cpp/DefaultPreprocessorListener.java
DefaultPreprocessorListener.handleError
@Override public void handleError(Source source, int line, int column, String msg) throws LexerException { errors++; print(source.getName() + ":" + line + ":" + column + ": error: " + msg); }
java
@Override public void handleError(Source source, int line, int column, String msg) throws LexerException { errors++; print(source.getName() + ":" + line + ":" + column + ": error: " + msg); }
[ "@", "Override", "public", "void", "handleError", "(", "Source", "source", ",", "int", "line", ",", "int", "column", ",", "String", "msg", ")", "throws", "LexerException", "{", "errors", "++", ";", "print", "(", "source", ".", "getName", "(", ")", "+", ...
Handles an error. The behaviour of this method is defined by the implementation. It may simply record the error message, or it may throw an exception.
[ "Handles", "an", "error", "." ]
71462c702097cabf8304202c740f780285fc35a8
https://github.com/shevek/jcpp/blob/71462c702097cabf8304202c740f780285fc35a8/src/main/java/org/anarres/cpp/DefaultPreprocessorListener.java#L84-L91
train
lastaflute/lastaflute
src/main/java/org/lastaflute/db/dbflute/classification/TypicalListedClassificationProvider.java
TypicalListedClassificationProvider.findMeta
protected OptionalThing<ClassificationMeta> findMeta(Class<?> defmetaType, String classificationName) { return LaClassificationUtil.findMeta(defmetaType, classificationName); }
java
protected OptionalThing<ClassificationMeta> findMeta(Class<?> defmetaType, String classificationName) { return LaClassificationUtil.findMeta(defmetaType, classificationName); }
[ "protected", "OptionalThing", "<", "ClassificationMeta", ">", "findMeta", "(", "Class", "<", "?", ">", "defmetaType", ",", "String", "classificationName", ")", "{", "return", "LaClassificationUtil", ".", "findMeta", "(", "defmetaType", ",", "classificationName", ")"...
helper for sub class
[ "helper", "for", "sub", "class" ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/db/dbflute/classification/TypicalListedClassificationProvider.java#L104-L106
train
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/UIInput.java
UIInput.executeValidate
private void executeValidate(FacesContext context) { try { validate(context); } catch (RuntimeException e) { context.renderResponse(); throw e; } if (!isValid()) { context.validationFailed(); context.renderResponse(); } }
java
private void executeValidate(FacesContext context) { try { validate(context); } catch (RuntimeException e) { context.renderResponse(); throw e; } if (!isValid()) { context.validationFailed(); context.renderResponse(); } }
[ "private", "void", "executeValidate", "(", "FacesContext", "context", ")", "{", "try", "{", "validate", "(", "context", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "context", ".", "renderResponse", "(", ")", ";", "throw", "e", ";", "}...
Executes validation logic.
[ "Executes", "validation", "logic", "." ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/UIInput.java#L1246-L1258
train