id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
0
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/apps/CookieApplication.java
CookieApplication.createContext
public Object createContext(ApplicationRequest request, ApplicationResponse response) { return new CookieContext( request, response, mDomain, mPath, mIsSecure); }
java
public Object createContext(ApplicationRequest request, ApplicationResponse response) { return new CookieContext( request, response, mDomain, mPath, mIsSecure); }
[ "public", "Object", "createContext", "(", "ApplicationRequest", "request", ",", "ApplicationResponse", "response", ")", "{", "return", "new", "CookieContext", "(", "request", ",", "response", ",", "mDomain", ",", "mPath", ",", "mIsSecure", ")", ";", "}" ]
Creates a context for the templates. @param request The user's http request @param response The user's http response @return the context for the templates
[ "Creates", "a", "context", "for", "the", "templates", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/apps/CookieApplication.java#L101-L106
1
teatrove/teatrove
examples/directory-browser/src/main/java/org/teatrove/examples/directorybrowser/DirectoryBrowserContext.java
DirectoryBrowserContext.getFiles
public File[] getFiles() { String path = mRequest.getParameter("path"); if (path == null) { path = mApp.getInitParameter("defaultPath"); } if (path == null) { path = "/"; } File activefile = new File(path); if( activefile.isDirectory()) { return activefile.listFiles(); } else { return null; } }
java
public File[] getFiles() { String path = mRequest.getParameter("path"); if (path == null) { path = mApp.getInitParameter("defaultPath"); } if (path == null) { path = "/"; } File activefile = new File(path); if( activefile.isDirectory()) { return activefile.listFiles(); } else { return null; } }
[ "public", "File", "[", "]", "getFiles", "(", ")", "{", "String", "path", "=", "mRequest", ".", "getParameter", "(", "\"path\"", ")", ";", "if", "(", "path", "==", "null", ")", "{", "path", "=", "mApp", ".", "getInitParameter", "(", "\"defaultPath\"", ")", ";", "}", "if", "(", "path", "==", "null", ")", "{", "path", "=", "\"/\"", ";", "}", "File", "activefile", "=", "new", "File", "(", "path", ")", ";", "if", "(", "activefile", ".", "isDirectory", "(", ")", ")", "{", "return", "activefile", ".", "listFiles", "(", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Gets an array of files in the directory specified by the "path" query parameter.
[ "Gets", "an", "array", "of", "files", "in", "the", "directory", "specified", "by", "the", "path", "query", "parameter", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/examples/directory-browser/src/main/java/org/teatrove/examples/directorybrowser/DirectoryBrowserContext.java#L31-L47
2
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/util/ConcurrentLinkedList.java
ConcurrentLinkedList.clear
public void clear() { mPutLock.lock(); mPollLock.lock(); try { mSize.set(0); mHead = new Node(null); mTail = new Node(null); mHead.mNext = mTail; } finally { mPollLock.unlock(); mPutLock.unlock(); } }
java
public void clear() { mPutLock.lock(); mPollLock.lock(); try { mSize.set(0); mHead = new Node(null); mTail = new Node(null); mHead.mNext = mTail; } finally { mPollLock.unlock(); mPutLock.unlock(); } }
[ "public", "void", "clear", "(", ")", "{", "mPutLock", ".", "lock", "(", ")", ";", "mPollLock", ".", "lock", "(", ")", ";", "try", "{", "mSize", ".", "set", "(", "0", ")", ";", "mHead", "=", "new", "Node", "(", "null", ")", ";", "mTail", "=", "new", "Node", "(", "null", ")", ";", "mHead", ".", "mNext", "=", "mTail", ";", "}", "finally", "{", "mPollLock", ".", "unlock", "(", ")", ";", "mPutLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Clears the contents of the queue. This is a blocking operation.
[ "Clears", "the", "contents", "of", "the", "queue", ".", "This", "is", "a", "blocking", "operation", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/ConcurrentLinkedList.java#L101-L114
3
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/util/ConcurrentLinkedList.java
ConcurrentLinkedList.remove
public boolean remove(Node<E> e) { mPutLock.lock(); mPollLock.lock(); try { if (e == null) return false; if (e.mRemoved) return false; if (mSize.get() == 0) return false; if (e == mTail) { removeTail(); return true; } if (e == mHead.mNext) { removeHead(); return true; } if (mSize.get() < 3) return false; if (e.mPrev == null || e.mNext == null) return false; e.mPrev.mNext = e.mNext; e.mNext.mPrev = e.mPrev; e.mRemoved = true; mSize.decrementAndGet(); mNodePool.returnNode(e); return true; } finally { mPollLock.unlock(); mPutLock.unlock(); } }
java
public boolean remove(Node<E> e) { mPutLock.lock(); mPollLock.lock(); try { if (e == null) return false; if (e.mRemoved) return false; if (mSize.get() == 0) return false; if (e == mTail) { removeTail(); return true; } if (e == mHead.mNext) { removeHead(); return true; } if (mSize.get() < 3) return false; if (e.mPrev == null || e.mNext == null) return false; e.mPrev.mNext = e.mNext; e.mNext.mPrev = e.mPrev; e.mRemoved = true; mSize.decrementAndGet(); mNodePool.returnNode(e); return true; } finally { mPollLock.unlock(); mPutLock.unlock(); } }
[ "public", "boolean", "remove", "(", "Node", "<", "E", ">", "e", ")", "{", "mPutLock", ".", "lock", "(", ")", ";", "mPollLock", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "e", "==", "null", ")", "return", "false", ";", "if", "(", "e", ".", "mRemoved", ")", "return", "false", ";", "if", "(", "mSize", ".", "get", "(", ")", "==", "0", ")", "return", "false", ";", "if", "(", "e", "==", "mTail", ")", "{", "removeTail", "(", ")", ";", "return", "true", ";", "}", "if", "(", "e", "==", "mHead", ".", "mNext", ")", "{", "removeHead", "(", ")", ";", "return", "true", ";", "}", "if", "(", "mSize", ".", "get", "(", ")", "<", "3", ")", "return", "false", ";", "if", "(", "e", ".", "mPrev", "==", "null", "||", "e", ".", "mNext", "==", "null", ")", "return", "false", ";", "e", ".", "mPrev", ".", "mNext", "=", "e", ".", "mNext", ";", "e", ".", "mNext", ".", "mPrev", "=", "e", ".", "mPrev", ";", "e", ".", "mRemoved", "=", "true", ";", "mSize", ".", "decrementAndGet", "(", ")", ";", "mNodePool", ".", "returnNode", "(", "e", ")", ";", "return", "true", ";", "}", "finally", "{", "mPollLock", ".", "unlock", "(", ")", ";", "mPutLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Removes a given Node handle. This is a blocking operation that runs in constant time.
[ "Removes", "a", "given", "Node", "handle", ".", "This", "is", "a", "blocking", "operation", "that", "runs", "in", "constant", "time", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/ConcurrentLinkedList.java#L169-L208
4
teatrove/teatrove
build-tools/teacompiler/teacompiler-maven-plugin/src/main/java/org/teatrove/maven/plugins/teacompiler/contextclassbuilder/DefaultContextClassBuilderHelper.java
DefaultContextClassBuilderHelper.getComponent
public Object getComponent(String role, String roleHint) throws ComponentLookupException { return container.lookup(role, roleHint); }
java
public Object getComponent(String role, String roleHint) throws ComponentLookupException { return container.lookup(role, roleHint); }
[ "public", "Object", "getComponent", "(", "String", "role", ",", "String", "roleHint", ")", "throws", "ComponentLookupException", "{", "return", "container", ".", "lookup", "(", "role", ",", "roleHint", ")", ";", "}" ]
Gets the component. @param role the role @param roleHint the role hint @return the component @throws org.codehaus.plexus.component.repository.exception.ComponentLookupException the component lookup exception
[ "Gets", "the", "component", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/teacompiler/teacompiler-maven-plugin/src/main/java/org/teatrove/maven/plugins/teacompiler/contextclassbuilder/DefaultContextClassBuilderHelper.java#L157-L159
5
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/net/LazySocket.java
LazySocket.setTcpNoDelay
public void setTcpNoDelay(boolean on) throws SocketException { if (mSocket != null) { mSocket.setTcpNoDelay(on); } else { setOption(0, on ? Boolean.TRUE : Boolean.FALSE); } }
java
public void setTcpNoDelay(boolean on) throws SocketException { if (mSocket != null) { mSocket.setTcpNoDelay(on); } else { setOption(0, on ? Boolean.TRUE : Boolean.FALSE); } }
[ "public", "void", "setTcpNoDelay", "(", "boolean", "on", ")", "throws", "SocketException", "{", "if", "(", "mSocket", "!=", "null", ")", "{", "mSocket", ".", "setTcpNoDelay", "(", "on", ")", ";", "}", "else", "{", "setOption", "(", "0", ",", "on", "?", "Boolean", ".", "TRUE", ":", "Boolean", ".", "FALSE", ")", ";", "}", "}" ]
Option 0.
[ "Option", "0", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/net/LazySocket.java#L123-L130
6
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/net/LazySocket.java
LazySocket.setSoLinger
public void setSoLinger(boolean on, int linger) throws SocketException { if (mSocket != null) { mSocket.setSoLinger(on, linger); } else { Object value; if (on) { value = new Integer(linger); } else { value = Boolean.FALSE; } setOption(1, value); } }
java
public void setSoLinger(boolean on, int linger) throws SocketException { if (mSocket != null) { mSocket.setSoLinger(on, linger); } else { Object value; if (on) { value = new Integer(linger); } else { value = Boolean.FALSE; } setOption(1, value); } }
[ "public", "void", "setSoLinger", "(", "boolean", "on", ",", "int", "linger", ")", "throws", "SocketException", "{", "if", "(", "mSocket", "!=", "null", ")", "{", "mSocket", ".", "setSoLinger", "(", "on", ",", "linger", ")", ";", "}", "else", "{", "Object", "value", ";", "if", "(", "on", ")", "{", "value", "=", "new", "Integer", "(", "linger", ")", ";", "}", "else", "{", "value", "=", "Boolean", ".", "FALSE", ";", "}", "setOption", "(", "1", ",", "value", ")", ";", "}", "}" ]
Option 1.
[ "Option", "1", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/net/LazySocket.java#L137-L151
7
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/net/LazySocket.java
LazySocket.setSoTimeout
public void setSoTimeout(int timeout) throws SocketException { if (mSocket != null) { mSocket.setSoTimeout(timeout); } else { setOption(2, new Integer(timeout)); } }
java
public void setSoTimeout(int timeout) throws SocketException { if (mSocket != null) { mSocket.setSoTimeout(timeout); } else { setOption(2, new Integer(timeout)); } }
[ "public", "void", "setSoTimeout", "(", "int", "timeout", ")", "throws", "SocketException", "{", "if", "(", "mSocket", "!=", "null", ")", "{", "mSocket", ".", "setSoTimeout", "(", "timeout", ")", ";", "}", "else", "{", "setOption", "(", "2", ",", "new", "Integer", "(", "timeout", ")", ")", ";", "}", "}" ]
Option 2.
[ "Option", "2", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/net/LazySocket.java#L158-L165
8
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/net/LazySocket.java
LazySocket.setSendBufferSize
public void setSendBufferSize(int size) throws SocketException { if (mSocket != null) { mSocket.setSendBufferSize(size); } else { setOption(3, new Integer(size)); } }
java
public void setSendBufferSize(int size) throws SocketException { if (mSocket != null) { mSocket.setSendBufferSize(size); } else { setOption(3, new Integer(size)); } }
[ "public", "void", "setSendBufferSize", "(", "int", "size", ")", "throws", "SocketException", "{", "if", "(", "mSocket", "!=", "null", ")", "{", "mSocket", ".", "setSendBufferSize", "(", "size", ")", ";", "}", "else", "{", "setOption", "(", "3", ",", "new", "Integer", "(", "size", ")", ")", ";", "}", "}" ]
Option 3.
[ "Option", "3", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/net/LazySocket.java#L172-L179
9
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/net/LazySocket.java
LazySocket.setReceiveBufferSize
public void setReceiveBufferSize(int size) throws SocketException { if (mSocket != null) { mSocket.setReceiveBufferSize(size); } else { setOption(4, new Integer(size)); } }
java
public void setReceiveBufferSize(int size) throws SocketException { if (mSocket != null) { mSocket.setReceiveBufferSize(size); } else { setOption(4, new Integer(size)); } }
[ "public", "void", "setReceiveBufferSize", "(", "int", "size", ")", "throws", "SocketException", "{", "if", "(", "mSocket", "!=", "null", ")", "{", "mSocket", ".", "setReceiveBufferSize", "(", "size", ")", ";", "}", "else", "{", "setOption", "(", "4", ",", "new", "Integer", "(", "size", ")", ")", ";", "}", "}" ]
Option 4.
[ "Option", "4", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/net/LazySocket.java#L186-L193
10
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/net/LazySocket.java
LazySocket.recycle
CheckedSocket recycle() { CheckedSocket s; if (mClosed) { s = null; } else { s = mSocket; mSocket = null; mClosed = true; } return s; }
java
CheckedSocket recycle() { CheckedSocket s; if (mClosed) { s = null; } else { s = mSocket; mSocket = null; mClosed = true; } return s; }
[ "CheckedSocket", "recycle", "(", ")", "{", "CheckedSocket", "s", ";", "if", "(", "mClosed", ")", "{", "s", "=", "null", ";", "}", "else", "{", "s", "=", "mSocket", ";", "mSocket", "=", "null", ";", "mClosed", "=", "true", ";", "}", "return", "s", ";", "}" ]
Returns the internal wrapped socket or null if not connected. After calling recycle, this LazySocket instance is closed.
[ "Returns", "the", "internal", "wrapped", "socket", "or", "null", "if", "not", "connected", ".", "After", "calling", "recycle", "this", "LazySocket", "instance", "is", "closed", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/net/LazySocket.java#L242-L253
11
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/AdminApplication.java
AdminApplication.getAdminLinks
public AppAdminLinks getAdminLinks() { AppAdminLinks links = new AppAdminLinks(mConfig.getName()); //links.addAdminLink("Instrumentation","/system/console?page=instrumentation"); //links.addAdminLink("Dashboard","/system/console?page=dashboard"); //links.addAdminLink("Janitor","/system/console?page=janitor"); //links.addAdminLink("Compile","/system/console?page=compile"); //links.addAdminLink("Templates","/system/console?page=templates"); //links.addAdminLink("Functions","/system/console?page=functions"); //links.addAdminLink("Applications", "/system/console?page=applications"); //links.addAdminLink("Logs","/system/console?page=logs"); //links.addAdminLink("Servlet Engine", "/system/console?page=servlet_engine"); //links.addAdminLink("Echo Request", "/system/console?page=echo_request"); links.addAdminLink("Templates","/system/teaservlet/AdminTemplates"); links.addAdminLink("Functions","/system/teaservlet/AdminFunctions"); links.addAdminLink("Applications", "/system/teaservlet/AdminApplications"); links.addAdminLink("Logs","/system/teaservlet/LogViewer"); links.addAdminLink("Servlet Engine", "/system/teaservlet/AdminServletEngine"); return links; }
java
public AppAdminLinks getAdminLinks() { AppAdminLinks links = new AppAdminLinks(mConfig.getName()); //links.addAdminLink("Instrumentation","/system/console?page=instrumentation"); //links.addAdminLink("Dashboard","/system/console?page=dashboard"); //links.addAdminLink("Janitor","/system/console?page=janitor"); //links.addAdminLink("Compile","/system/console?page=compile"); //links.addAdminLink("Templates","/system/console?page=templates"); //links.addAdminLink("Functions","/system/console?page=functions"); //links.addAdminLink("Applications", "/system/console?page=applications"); //links.addAdminLink("Logs","/system/console?page=logs"); //links.addAdminLink("Servlet Engine", "/system/console?page=servlet_engine"); //links.addAdminLink("Echo Request", "/system/console?page=echo_request"); links.addAdminLink("Templates","/system/teaservlet/AdminTemplates"); links.addAdminLink("Functions","/system/teaservlet/AdminFunctions"); links.addAdminLink("Applications", "/system/teaservlet/AdminApplications"); links.addAdminLink("Logs","/system/teaservlet/LogViewer"); links.addAdminLink("Servlet Engine", "/system/teaservlet/AdminServletEngine"); return links; }
[ "public", "AppAdminLinks", "getAdminLinks", "(", ")", "{", "AppAdminLinks", "links", "=", "new", "AppAdminLinks", "(", "mConfig", ".", "getName", "(", ")", ")", ";", "//links.addAdminLink(\"Instrumentation\",\"/system/console?page=instrumentation\");", "//links.addAdminLink(\"Dashboard\",\"/system/console?page=dashboard\");", "//links.addAdminLink(\"Janitor\",\"/system/console?page=janitor\");", "//links.addAdminLink(\"Compile\",\"/system/console?page=compile\");", "//links.addAdminLink(\"Templates\",\"/system/console?page=templates\");", "//links.addAdminLink(\"Functions\",\"/system/console?page=functions\");", "//links.addAdminLink(\"Applications\", \"/system/console?page=applications\");", "//links.addAdminLink(\"Logs\",\"/system/console?page=logs\");", "//links.addAdminLink(\"Servlet Engine\", \"/system/console?page=servlet_engine\");", "//links.addAdminLink(\"Echo Request\", \"/system/console?page=echo_request\");", "links", ".", "addAdminLink", "(", "\"Templates\"", ",", "\"/system/teaservlet/AdminTemplates\"", ")", ";", "links", ".", "addAdminLink", "(", "\"Functions\"", ",", "\"/system/teaservlet/AdminFunctions\"", ")", ";", "links", ".", "addAdminLink", "(", "\"Applications\"", ",", "\"/system/teaservlet/AdminApplications\"", ")", ";", "links", ".", "addAdminLink", "(", "\"Logs\"", ",", "\"/system/teaservlet/LogViewer\"", ")", ";", "links", ".", "addAdminLink", "(", "\"Servlet Engine\"", ",", "\"/system/teaservlet/AdminServletEngine\"", ")", ";", "return", "links", ";", "}" ]
This implementation uses hard coded link information, but other applications can dynamically determine their admin links.
[ "This", "implementation", "uses", "hard", "coded", "link", "information", "but", "other", "applications", "can", "dynamically", "determine", "their", "admin", "links", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/AdminApplication.java#L343-L365
12
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/TeaServlet.java
TeaServlet.init
public void init(ServletConfig config) throws ServletException { super.init(config); mServletConfig = config; config.getServletContext().log("Initializing TeaServlet..."); String ver = System.getProperty("java.version"); if (ver.startsWith("0.") || ver.startsWith("1.2") || ver.startsWith("1.3")) { config.getServletContext() .log("The TeaServlet requires Java 1.4 or higher to run properly"); } mServletContext = setServletContext(config); mServletName = setServletName(config); mProperties = new PropertyMap(); mSubstitutions = SubstitutionFactory.getDefaults(); mResourceFactory = new TeaServletResourceFactory(config.getServletContext(), mSubstitutions); Enumeration<?> e = config.getInitParameterNames(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); String value = SubstitutionFactory.substitute(config.getInitParameter(key)); if (key.equals("debug")) { mDebugEnabled = Boolean.parseBoolean(value); continue; } mProperties.put(key, value); } loadDefaults(); discoverProperties(); createListeners(); createLog(mServletContext); mLog.applyProperties(mProperties.subMap("log")); createMemoryLog(mLog); mInstrumentationEnabled = mProperties.getBoolean("instrumentation.enabled", true); Initializer initializer = new Initializer(); if (mProperties.getBoolean("startup.background", false)) { mInitializer = Executors.newSingleThreadExecutor().submit(initializer); } else { initializer.call(); } }
java
public void init(ServletConfig config) throws ServletException { super.init(config); mServletConfig = config; config.getServletContext().log("Initializing TeaServlet..."); String ver = System.getProperty("java.version"); if (ver.startsWith("0.") || ver.startsWith("1.2") || ver.startsWith("1.3")) { config.getServletContext() .log("The TeaServlet requires Java 1.4 or higher to run properly"); } mServletContext = setServletContext(config); mServletName = setServletName(config); mProperties = new PropertyMap(); mSubstitutions = SubstitutionFactory.getDefaults(); mResourceFactory = new TeaServletResourceFactory(config.getServletContext(), mSubstitutions); Enumeration<?> e = config.getInitParameterNames(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); String value = SubstitutionFactory.substitute(config.getInitParameter(key)); if (key.equals("debug")) { mDebugEnabled = Boolean.parseBoolean(value); continue; } mProperties.put(key, value); } loadDefaults(); discoverProperties(); createListeners(); createLog(mServletContext); mLog.applyProperties(mProperties.subMap("log")); createMemoryLog(mLog); mInstrumentationEnabled = mProperties.getBoolean("instrumentation.enabled", true); Initializer initializer = new Initializer(); if (mProperties.getBoolean("startup.background", false)) { mInitializer = Executors.newSingleThreadExecutor().submit(initializer); } else { initializer.call(); } }
[ "public", "void", "init", "(", "ServletConfig", "config", ")", "throws", "ServletException", "{", "super", ".", "init", "(", "config", ")", ";", "mServletConfig", "=", "config", ";", "config", ".", "getServletContext", "(", ")", ".", "log", "(", "\"Initializing TeaServlet...\"", ")", ";", "String", "ver", "=", "System", ".", "getProperty", "(", "\"java.version\"", ")", ";", "if", "(", "ver", ".", "startsWith", "(", "\"0.\"", ")", "||", "ver", ".", "startsWith", "(", "\"1.2\"", ")", "||", "ver", ".", "startsWith", "(", "\"1.3\"", ")", ")", "{", "config", ".", "getServletContext", "(", ")", ".", "log", "(", "\"The TeaServlet requires Java 1.4 or higher to run properly\"", ")", ";", "}", "mServletContext", "=", "setServletContext", "(", "config", ")", ";", "mServletName", "=", "setServletName", "(", "config", ")", ";", "mProperties", "=", "new", "PropertyMap", "(", ")", ";", "mSubstitutions", "=", "SubstitutionFactory", ".", "getDefaults", "(", ")", ";", "mResourceFactory", "=", "new", "TeaServletResourceFactory", "(", "config", ".", "getServletContext", "(", ")", ",", "mSubstitutions", ")", ";", "Enumeration", "<", "?", ">", "e", "=", "config", ".", "getInitParameterNames", "(", ")", ";", "while", "(", "e", ".", "hasMoreElements", "(", ")", ")", "{", "String", "key", "=", "(", "String", ")", "e", ".", "nextElement", "(", ")", ";", "String", "value", "=", "SubstitutionFactory", ".", "substitute", "(", "config", ".", "getInitParameter", "(", "key", ")", ")", ";", "if", "(", "key", ".", "equals", "(", "\"debug\"", ")", ")", "{", "mDebugEnabled", "=", "Boolean", ".", "parseBoolean", "(", "value", ")", ";", "continue", ";", "}", "mProperties", ".", "put", "(", "key", ",", "value", ")", ";", "}", "loadDefaults", "(", ")", ";", "discoverProperties", "(", ")", ";", "createListeners", "(", ")", ";", "createLog", "(", "mServletContext", ")", ";", "mLog", ".", "applyProperties", "(", "mProperties", ".", "subMap", "(", "\"log\"", ")", ")", ";", "createMemoryLog", "(", "mLog", ")", ";", "mInstrumentationEnabled", "=", "mProperties", ".", "getBoolean", "(", "\"instrumentation.enabled\"", ",", "true", ")", ";", "Initializer", "initializer", "=", "new", "Initializer", "(", ")", ";", "if", "(", "mProperties", ".", "getBoolean", "(", "\"startup.background\"", ",", "false", ")", ")", "{", "mInitializer", "=", "Executors", ".", "newSingleThreadExecutor", "(", ")", ".", "submit", "(", "initializer", ")", ";", "}", "else", "{", "initializer", ".", "call", "(", ")", ";", "}", "}" ]
Initializes the TeaServlet. Creates the logger and loads the user's application. @param config the servlet config
[ "Initializes", "the", "TeaServlet", ".", "Creates", "the", "logger", "and", "loads", "the", "user", "s", "application", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/TeaServlet.java#L154-L208
13
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/TeaServlet.java
TeaServlet.doGet
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (processStatus(request, response)) { return; } if (!isRunning()) { int errorCode = mProperties.getInt("startup.codes.error", 503); response.sendError(errorCode); return; } if (mUseSpiderableRequest) { request = new SpiderableRequest(request, mQuerySeparator, mParameterSeparator, mValueSeparator); } // start transaction TeaServletTransaction tsTrans = getEngine().createTransaction(request, response, true); // load associated request/response ApplicationRequest appRequest = tsTrans.getRequest(); ApplicationResponse appResponse = tsTrans.getResponse(); // process template processTemplate(appRequest, appResponse); appResponse.finish(); // flush the output response.flushBuffer(); }
java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (processStatus(request, response)) { return; } if (!isRunning()) { int errorCode = mProperties.getInt("startup.codes.error", 503); response.sendError(errorCode); return; } if (mUseSpiderableRequest) { request = new SpiderableRequest(request, mQuerySeparator, mParameterSeparator, mValueSeparator); } // start transaction TeaServletTransaction tsTrans = getEngine().createTransaction(request, response, true); // load associated request/response ApplicationRequest appRequest = tsTrans.getRequest(); ApplicationResponse appResponse = tsTrans.getResponse(); // process template processTemplate(appRequest, appResponse); appResponse.finish(); // flush the output response.flushBuffer(); }
[ "protected", "void", "doGet", "(", "HttpServletRequest", "request", ",", "HttpServletResponse", "response", ")", "throws", "ServletException", ",", "IOException", "{", "if", "(", "processStatus", "(", "request", ",", "response", ")", ")", "{", "return", ";", "}", "if", "(", "!", "isRunning", "(", ")", ")", "{", "int", "errorCode", "=", "mProperties", ".", "getInt", "(", "\"startup.codes.error\"", ",", "503", ")", ";", "response", ".", "sendError", "(", "errorCode", ")", ";", "return", ";", "}", "if", "(", "mUseSpiderableRequest", ")", "{", "request", "=", "new", "SpiderableRequest", "(", "request", ",", "mQuerySeparator", ",", "mParameterSeparator", ",", "mValueSeparator", ")", ";", "}", "// start transaction", "TeaServletTransaction", "tsTrans", "=", "getEngine", "(", ")", ".", "createTransaction", "(", "request", ",", "response", ",", "true", ")", ";", "// load associated request/response", "ApplicationRequest", "appRequest", "=", "tsTrans", ".", "getRequest", "(", ")", ";", "ApplicationResponse", "appResponse", "=", "tsTrans", ".", "getResponse", "(", ")", ";", "// process template", "processTemplate", "(", "appRequest", ",", "appResponse", ")", ";", "appResponse", ".", "finish", "(", ")", ";", "// flush the output", "response", ".", "flushBuffer", "(", ")", ";", "}" ]
Process the user's http get request. Process the template that maps to the URI that was hit. @param request the user's http request @param response the user's http response
[ "Process", "the", "user", "s", "http", "get", "request", ".", "Process", "the", "template", "that", "maps", "to", "the", "URI", "that", "was", "hit", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/TeaServlet.java#L458-L493
14
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/TeaServlet.java
TeaServlet.processResource
private boolean processResource(ApplicationRequest appRequest, ApplicationResponse appResponse) throws IOException { // get the associated system path String requestURI = null; if ((requestURI = appRequest.getPathInfo()) == null) { String context = appRequest.getContextPath(); requestURI = appRequest.getRequestURI(); if (requestURI.startsWith(context)) { requestURI = requestURI.substring(context.length()); } } // check for valid asset Asset asset = getEngine().getAssetEngine().getAsset(requestURI); if (asset == null) { return false; } // set mime type appResponse.setContentType(asset.getMimeType()); // write contents int read = -1; byte[] contents = new byte[1024]; InputStream input = asset.getInputStream(); ServletOutputStream output = appResponse.getOutputStream(); while ((read = input.read(contents)) >= 0) { output.write(contents, 0, read); } // complete response appResponse.finish(); // success return true; }
java
private boolean processResource(ApplicationRequest appRequest, ApplicationResponse appResponse) throws IOException { // get the associated system path String requestURI = null; if ((requestURI = appRequest.getPathInfo()) == null) { String context = appRequest.getContextPath(); requestURI = appRequest.getRequestURI(); if (requestURI.startsWith(context)) { requestURI = requestURI.substring(context.length()); } } // check for valid asset Asset asset = getEngine().getAssetEngine().getAsset(requestURI); if (asset == null) { return false; } // set mime type appResponse.setContentType(asset.getMimeType()); // write contents int read = -1; byte[] contents = new byte[1024]; InputStream input = asset.getInputStream(); ServletOutputStream output = appResponse.getOutputStream(); while ((read = input.read(contents)) >= 0) { output.write(contents, 0, read); } // complete response appResponse.finish(); // success return true; }
[ "private", "boolean", "processResource", "(", "ApplicationRequest", "appRequest", ",", "ApplicationResponse", "appResponse", ")", "throws", "IOException", "{", "// get the associated system path", "String", "requestURI", "=", "null", ";", "if", "(", "(", "requestURI", "=", "appRequest", ".", "getPathInfo", "(", ")", ")", "==", "null", ")", "{", "String", "context", "=", "appRequest", ".", "getContextPath", "(", ")", ";", "requestURI", "=", "appRequest", ".", "getRequestURI", "(", ")", ";", "if", "(", "requestURI", ".", "startsWith", "(", "context", ")", ")", "{", "requestURI", "=", "requestURI", ".", "substring", "(", "context", ".", "length", "(", ")", ")", ";", "}", "}", "// check for valid asset", "Asset", "asset", "=", "getEngine", "(", ")", ".", "getAssetEngine", "(", ")", ".", "getAsset", "(", "requestURI", ")", ";", "if", "(", "asset", "==", "null", ")", "{", "return", "false", ";", "}", "// set mime type", "appResponse", ".", "setContentType", "(", "asset", ".", "getMimeType", "(", ")", ")", ";", "// write contents", "int", "read", "=", "-", "1", ";", "byte", "[", "]", "contents", "=", "new", "byte", "[", "1024", "]", ";", "InputStream", "input", "=", "asset", ".", "getInputStream", "(", ")", ";", "ServletOutputStream", "output", "=", "appResponse", ".", "getOutputStream", "(", ")", ";", "while", "(", "(", "read", "=", "input", ".", "read", "(", "contents", ")", ")", ">=", "0", ")", "{", "output", ".", "write", "(", "contents", ",", "0", ",", "read", ")", ";", "}", "// complete response", "appResponse", ".", "finish", "(", ")", ";", "// success", "return", "true", ";", "}" ]
Inserts a plugin to expose parts of the teaservlet via the EngineAccess interface. private void createEngineAccessPlugin(PluginContext context) { Plugin engineAccess = new EngineAccessPlugin(this); context.addPlugin(engineAccess); context.addPluginListener(engineAccess); }
[ "Inserts", "a", "plugin", "to", "expose", "parts", "of", "the", "teaservlet", "via", "the", "EngineAccess", "interface", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/TeaServlet.java#L862-L900
15
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/TeaServlet.java
TeaServlet.convertParameter
protected Object convertParameter(String value, Class<?> toType) { if (toType == Boolean.class) { return ! "".equals(value) ? new Boolean("true".equals(value)) : null; } if (toType == Integer.class) { try { return new Integer(value); } catch (NumberFormatException e) { return null; } } else if (toType == Long.class) { try { return new Long(value); } catch (NumberFormatException e) { return null; } } else if (toType == Float.class) { try { return new Float(value); } catch (NumberFormatException e) { return null; } } else if (toType == Double.class) { try { return new Double(value); } catch (NumberFormatException e) { return null; } } else if (toType == Number.class || toType == Object.class) { try { return new Integer(value); } catch (NumberFormatException e) { } try { return new Long(value); } catch (NumberFormatException e) { } try { return new Double(value); } catch (NumberFormatException e) { return (toType == Object.class) ? value : null; } } else { return null; } }
java
protected Object convertParameter(String value, Class<?> toType) { if (toType == Boolean.class) { return ! "".equals(value) ? new Boolean("true".equals(value)) : null; } if (toType == Integer.class) { try { return new Integer(value); } catch (NumberFormatException e) { return null; } } else if (toType == Long.class) { try { return new Long(value); } catch (NumberFormatException e) { return null; } } else if (toType == Float.class) { try { return new Float(value); } catch (NumberFormatException e) { return null; } } else if (toType == Double.class) { try { return new Double(value); } catch (NumberFormatException e) { return null; } } else if (toType == Number.class || toType == Object.class) { try { return new Integer(value); } catch (NumberFormatException e) { } try { return new Long(value); } catch (NumberFormatException e) { } try { return new Double(value); } catch (NumberFormatException e) { return (toType == Object.class) ? value : null; } } else { return null; } }
[ "protected", "Object", "convertParameter", "(", "String", "value", ",", "Class", "<", "?", ">", "toType", ")", "{", "if", "(", "toType", "==", "Boolean", ".", "class", ")", "{", "return", "!", "\"\"", ".", "equals", "(", "value", ")", "?", "new", "Boolean", "(", "\"true\"", ".", "equals", "(", "value", ")", ")", ":", "null", ";", "}", "if", "(", "toType", "==", "Integer", ".", "class", ")", "{", "try", "{", "return", "new", "Integer", "(", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "return", "null", ";", "}", "}", "else", "if", "(", "toType", "==", "Long", ".", "class", ")", "{", "try", "{", "return", "new", "Long", "(", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "return", "null", ";", "}", "}", "else", "if", "(", "toType", "==", "Float", ".", "class", ")", "{", "try", "{", "return", "new", "Float", "(", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "return", "null", ";", "}", "}", "else", "if", "(", "toType", "==", "Double", ".", "class", ")", "{", "try", "{", "return", "new", "Double", "(", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "return", "null", ";", "}", "}", "else", "if", "(", "toType", "==", "Number", ".", "class", "||", "toType", "==", "Object", ".", "class", ")", "{", "try", "{", "return", "new", "Integer", "(", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "}", "try", "{", "return", "new", "Long", "(", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "}", "try", "{", "return", "new", "Double", "(", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "return", "(", "toType", "==", "Object", ".", "class", ")", "?", "value", ":", "null", ";", "}", "}", "else", "{", "return", "null", ";", "}", "}" ]
Converts the given HTTP parameter value to the requested type so that it can be passed directly as a template parameter. This method is called if the template that is directly requested accepts non-String parameters, and the request provides non-null values for those parameters. The template may request an array of values for a parameter, in which case this method is called not to create the array, but rather to convert any elements put into the array. <p>This implementation supports converting parameters of the following types, and returns null for all others. If a conversion fails, null is returned. <ul> <li>Integer <li>Long <li>Float <li>Double <li>Number <li>Object </ul> When converting to Number, an instance of Integer, Long or Double is returned, depending on which parse succeeds first. A request for an Object returns either a Number or a String, depending on the success of a number parse. @param value non-null HTTP parameter value to convert @param toType Type to convert to @return an instance of toType or null
[ "Converts", "the", "given", "HTTP", "parameter", "value", "to", "the", "requested", "type", "so", "that", "it", "can", "be", "passed", "directly", "as", "a", "template", "parameter", ".", "This", "method", "is", "called", "if", "the", "template", "that", "is", "directly", "requested", "accepts", "non", "-", "String", "parameters", "and", "the", "request", "provides", "non", "-", "null", "values", "for", "those", "parameters", ".", "The", "template", "may", "request", "an", "array", "of", "values", "for", "a", "parameter", "in", "which", "case", "this", "method", "is", "called", "not", "to", "create", "the", "array", "but", "rather", "to", "convert", "any", "elements", "put", "into", "the", "array", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/TeaServlet.java#L1164-L1222
16
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/util/StringReplacer.java
StringReplacer.replace
public static String replace(String source, String pattern, String replacement) { return replace(source, pattern, replacement, 0); }
java
public static String replace(String source, String pattern, String replacement) { return replace(source, pattern, replacement, 0); }
[ "public", "static", "String", "replace", "(", "String", "source", ",", "String", "pattern", ",", "String", "replacement", ")", "{", "return", "replace", "(", "source", ",", "pattern", ",", "replacement", ",", "0", ")", ";", "}" ]
Replaces all exact matches of the given pattern in the source string with the provided replacement. @param source the source string @param pattern the simple string pattern to search for @param replacement the string to use for replacing matched patterns. @return the string with any replacements applied.
[ "Replaces", "all", "exact", "matches", "of", "the", "given", "pattern", "in", "the", "source", "string", "with", "the", "provided", "replacement", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/StringReplacer.java#L40-L43
17
teatrove/teatrove
build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/BeanDocContext.java
BeanDocContext.print
public void print(Object obj) throws IOException { if (mOut != null) { // static Tea! mOut.write(toString(obj)); } }
java
public void print(Object obj) throws IOException { if (mOut != null) { // static Tea! mOut.write(toString(obj)); } }
[ "public", "void", "print", "(", "Object", "obj", ")", "throws", "IOException", "{", "if", "(", "mOut", "!=", "null", ")", "{", "// static Tea!", "mOut", ".", "write", "(", "toString", "(", "obj", ")", ")", ";", "}", "}" ]
The standard context method, implemented to write to the file.
[ "The", "standard", "context", "method", "implemented", "to", "write", "to", "the", "file", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/BeanDocContext.java#L83-L89
18
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/parsetree/Expression.java
Expression.setType
public void setType(Type type) { Type actual = Type.preserveType(this.getType(), type); mConversions.clear(); mExceptionPossible = false; if (actual != null) { // Prefer cast for initial type for correct operation of // setInitialType if a conversion needs to be inserted at the // beginning. mConversions.add(new Conversion(null, actual, true)); } }
java
public void setType(Type type) { Type actual = Type.preserveType(this.getType(), type); mConversions.clear(); mExceptionPossible = false; if (actual != null) { // Prefer cast for initial type for correct operation of // setInitialType if a conversion needs to be inserted at the // beginning. mConversions.add(new Conversion(null, actual, true)); } }
[ "public", "void", "setType", "(", "Type", "type", ")", "{", "Type", "actual", "=", "Type", ".", "preserveType", "(", "this", ".", "getType", "(", ")", ",", "type", ")", ";", "mConversions", ".", "clear", "(", ")", ";", "mExceptionPossible", "=", "false", ";", "if", "(", "actual", "!=", "null", ")", "{", "// Prefer cast for initial type for correct operation of", "// setInitialType if a conversion needs to be inserted at the", "// beginning.", "mConversions", ".", "add", "(", "new", "Conversion", "(", "null", ",", "actual", ",", "true", ")", ")", ";", "}", "}" ]
Sets the type of this expression, clearing the conversion chain.
[ "Sets", "the", "type", "of", "this", "expression", "clearing", "the", "conversion", "chain", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/parsetree/Expression.java#L314-L325
19
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/parsetree/Expression.java
Expression.setInitialType
public void setInitialType(Type type) { Type initial = getInitialType(); Type actual = Type.preserveType(initial, type); if (actual != null && !actual.equals(initial)) { if (initial == null) { setType(actual); } else { Iterator<Conversion> it = mConversions.iterator(); mConversions = new LinkedList<Conversion>(); // Prefer cast for initial type for correct operation of // setInitialType if a conversion needs to be inserted at the // beginning. mConversions.add(new Conversion(null, actual, true)); while (it.hasNext()) { Conversion conv = (Conversion)it.next(); convertTo(conv.getToType(), conv.isCastPreferred()); } } } }
java
public void setInitialType(Type type) { Type initial = getInitialType(); Type actual = Type.preserveType(initial, type); if (actual != null && !actual.equals(initial)) { if (initial == null) { setType(actual); } else { Iterator<Conversion> it = mConversions.iterator(); mConversions = new LinkedList<Conversion>(); // Prefer cast for initial type for correct operation of // setInitialType if a conversion needs to be inserted at the // beginning. mConversions.add(new Conversion(null, actual, true)); while (it.hasNext()) { Conversion conv = (Conversion)it.next(); convertTo(conv.getToType(), conv.isCastPreferred()); } } } }
[ "public", "void", "setInitialType", "(", "Type", "type", ")", "{", "Type", "initial", "=", "getInitialType", "(", ")", ";", "Type", "actual", "=", "Type", ".", "preserveType", "(", "initial", ",", "type", ")", ";", "if", "(", "actual", "!=", "null", "&&", "!", "actual", ".", "equals", "(", "initial", ")", ")", "{", "if", "(", "initial", "==", "null", ")", "{", "setType", "(", "actual", ")", ";", "}", "else", "{", "Iterator", "<", "Conversion", ">", "it", "=", "mConversions", ".", "iterator", "(", ")", ";", "mConversions", "=", "new", "LinkedList", "<", "Conversion", ">", "(", ")", ";", "// Prefer cast for initial type for correct operation of", "// setInitialType if a conversion needs to be inserted at the", "// beginning.", "mConversions", ".", "add", "(", "new", "Conversion", "(", "null", ",", "actual", ",", "true", ")", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "Conversion", "conv", "=", "(", "Conversion", ")", "it", ".", "next", "(", ")", ";", "convertTo", "(", "conv", ".", "getToType", "(", ")", ",", "conv", ".", "isCastPreferred", "(", ")", ")", ";", "}", "}", "}", "}" ]
Sets the intial type in the conversion chain, but does not clear the conversions.
[ "Sets", "the", "intial", "type", "in", "the", "conversion", "chain", "but", "does", "not", "clear", "the", "conversions", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/parsetree/Expression.java#L331-L351
20
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Scanner.java
Scanner.peekToken
public synchronized Token peekToken() throws IOException { if (mLookahead.empty()) { return mLookahead.push(scanToken()); } else { return mLookahead.peek(); } }
java
public synchronized Token peekToken() throws IOException { if (mLookahead.empty()) { return mLookahead.push(scanToken()); } else { return mLookahead.peek(); } }
[ "public", "synchronized", "Token", "peekToken", "(", ")", "throws", "IOException", "{", "if", "(", "mLookahead", ".", "empty", "(", ")", ")", "{", "return", "mLookahead", ".", "push", "(", "scanToken", "(", ")", ")", ";", "}", "else", "{", "return", "mLookahead", ".", "peek", "(", ")", ";", "}", "}" ]
Returns EOF as the last token.
[ "Returns", "EOF", "as", "the", "last", "token", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Scanner.java#L115-L122
21
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Scanner.java
Scanner.scanText
private Token scanText(int c) throws IOException { // Read first character in text so that source info does not include // tags. c = mSource.read(); int startLine = mSource.getLineNumber(); int startPos = mSource.getStartPosition(); int endPos = mSource.getEndPosition(); StringBuilder buf = new StringBuilder(256); while (c != -1) { if (c == SourceReader.ENTER_CODE) { if (mEmitSpecial) { mLookahead.push(makeStringToken(Token.ENTER_CODE, mSource.getBeginTag())); } break; } else if (c == SourceReader.ENTER_TEXT) { buf.append(mSource.getEndTag()); } else { buf.append((char)c); } if (mSource.peek() < 0) { endPos = mSource.getEndPosition(); } c = mSource.read(); } if (c == -1) { // If the last token in the source file is text, trim all trailing // whitespace from it. int length = buf.length(); int i; for (i = length - 1; i >= 0; i--) { if (buf.charAt(i) > ' ') { break; } } buf.setLength(i + 1); } String str = buf.toString(); return new StringToken(startLine, startPos, endPos, Token.STRING, str); }
java
private Token scanText(int c) throws IOException { // Read first character in text so that source info does not include // tags. c = mSource.read(); int startLine = mSource.getLineNumber(); int startPos = mSource.getStartPosition(); int endPos = mSource.getEndPosition(); StringBuilder buf = new StringBuilder(256); while (c != -1) { if (c == SourceReader.ENTER_CODE) { if (mEmitSpecial) { mLookahead.push(makeStringToken(Token.ENTER_CODE, mSource.getBeginTag())); } break; } else if (c == SourceReader.ENTER_TEXT) { buf.append(mSource.getEndTag()); } else { buf.append((char)c); } if (mSource.peek() < 0) { endPos = mSource.getEndPosition(); } c = mSource.read(); } if (c == -1) { // If the last token in the source file is text, trim all trailing // whitespace from it. int length = buf.length(); int i; for (i = length - 1; i >= 0; i--) { if (buf.charAt(i) > ' ') { break; } } buf.setLength(i + 1); } String str = buf.toString(); return new StringToken(startLine, startPos, endPos, Token.STRING, str); }
[ "private", "Token", "scanText", "(", "int", "c", ")", "throws", "IOException", "{", "// Read first character in text so that source info does not include", "// tags.", "c", "=", "mSource", ".", "read", "(", ")", ";", "int", "startLine", "=", "mSource", ".", "getLineNumber", "(", ")", ";", "int", "startPos", "=", "mSource", ".", "getStartPosition", "(", ")", ";", "int", "endPos", "=", "mSource", ".", "getEndPosition", "(", ")", ";", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", "256", ")", ";", "while", "(", "c", "!=", "-", "1", ")", "{", "if", "(", "c", "==", "SourceReader", ".", "ENTER_CODE", ")", "{", "if", "(", "mEmitSpecial", ")", "{", "mLookahead", ".", "push", "(", "makeStringToken", "(", "Token", ".", "ENTER_CODE", ",", "mSource", ".", "getBeginTag", "(", ")", ")", ")", ";", "}", "break", ";", "}", "else", "if", "(", "c", "==", "SourceReader", ".", "ENTER_TEXT", ")", "{", "buf", ".", "append", "(", "mSource", ".", "getEndTag", "(", ")", ")", ";", "}", "else", "{", "buf", ".", "append", "(", "(", "char", ")", "c", ")", ";", "}", "if", "(", "mSource", ".", "peek", "(", ")", "<", "0", ")", "{", "endPos", "=", "mSource", ".", "getEndPosition", "(", ")", ";", "}", "c", "=", "mSource", ".", "read", "(", ")", ";", "}", "if", "(", "c", "==", "-", "1", ")", "{", "// If the last token in the source file is text, trim all trailing", "// whitespace from it.", "int", "length", "=", "buf", ".", "length", "(", ")", ";", "int", "i", ";", "for", "(", "i", "=", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "buf", ".", "charAt", "(", "i", ")", ">", "'", "'", ")", "{", "break", ";", "}", "}", "buf", ".", "setLength", "(", "i", "+", "1", ")", ";", "}", "String", "str", "=", "buf", ".", "toString", "(", ")", ";", "return", "new", "StringToken", "(", "startLine", ",", "startPos", ",", "endPos", ",", "Token", ".", "STRING", ",", "str", ")", ";", "}" ]
The ENTER_TEXT code has already been scanned when this is called.
[ "The", "ENTER_TEXT", "code", "has", "already", "been", "scanned", "when", "this", "is", "called", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Scanner.java#L400-L451
22
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/util/CompleteIntrospector.java
CompleteIntrospector.main
public static void main(String[] args) throws Exception { Map map = getAllProperties(Class.forName(args[0])); Iterator keys = map.keySet().iterator(); while (keys.hasNext()) { String key = (String)keys.next(); PropertyDescriptor desc = (PropertyDescriptor)map.get(key); System.out.println(key + " = " + desc); } }
java
public static void main(String[] args) throws Exception { Map map = getAllProperties(Class.forName(args[0])); Iterator keys = map.keySet().iterator(); while (keys.hasNext()) { String key = (String)keys.next(); PropertyDescriptor desc = (PropertyDescriptor)map.get(key); System.out.println(key + " = " + desc); } }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "Exception", "{", "Map", "map", "=", "getAllProperties", "(", "Class", ".", "forName", "(", "args", "[", "0", "]", ")", ")", ";", "Iterator", "keys", "=", "map", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "keys", ".", "hasNext", "(", ")", ")", "{", "String", "key", "=", "(", "String", ")", "keys", ".", "next", "(", ")", ";", "PropertyDescriptor", "desc", "=", "(", "PropertyDescriptor", ")", "map", ".", "get", "(", "key", ")", ";", "System", ".", "out", ".", "println", "(", "key", "+", "\" = \"", "+", "desc", ")", ";", "}", "}" ]
Test program.
[ "Test", "program", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/CompleteIntrospector.java#L48-L56
23
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/util/CompleteIntrospector.java
CompleteIntrospector.getAllProperties
public static Map getAllProperties(Class clazz) throws IntrospectionException { synchronized (cPropertiesCache) { Map properties; Reference ref = (Reference)cPropertiesCache.get(clazz); if (ref != null) { properties = (Map)ref.get(); if (properties != null) { return properties; } else { // Clean up cleared reference. cPropertiesCache.remove(clazz); } } properties = Collections.unmodifiableMap(createProperties(clazz)); cPropertiesCache.put(clazz, new SoftReference(properties)); return properties; } }
java
public static Map getAllProperties(Class clazz) throws IntrospectionException { synchronized (cPropertiesCache) { Map properties; Reference ref = (Reference)cPropertiesCache.get(clazz); if (ref != null) { properties = (Map)ref.get(); if (properties != null) { return properties; } else { // Clean up cleared reference. cPropertiesCache.remove(clazz); } } properties = Collections.unmodifiableMap(createProperties(clazz)); cPropertiesCache.put(clazz, new SoftReference(properties)); return properties; } }
[ "public", "static", "Map", "getAllProperties", "(", "Class", "clazz", ")", "throws", "IntrospectionException", "{", "synchronized", "(", "cPropertiesCache", ")", "{", "Map", "properties", ";", "Reference", "ref", "=", "(", "Reference", ")", "cPropertiesCache", ".", "get", "(", "clazz", ")", ";", "if", "(", "ref", "!=", "null", ")", "{", "properties", "=", "(", "Map", ")", "ref", ".", "get", "(", ")", ";", "if", "(", "properties", "!=", "null", ")", "{", "return", "properties", ";", "}", "else", "{", "// Clean up cleared reference.", "cPropertiesCache", ".", "remove", "(", "clazz", ")", ";", "}", "}", "properties", "=", "Collections", ".", "unmodifiableMap", "(", "createProperties", "(", "clazz", ")", ")", ";", "cPropertiesCache", ".", "put", "(", "clazz", ",", "new", "SoftReference", "(", "properties", ")", ")", ";", "return", "properties", ";", "}", "}" ]
A function that returns a Map of all the available properties on a given class including write-only properties. The properties returned is mostly a superset of those returned from the standard JavaBeans Introspector except more properties are made available to interfaces. @return an unmodifiable mapping of property names (Strings) to PropertyDescriptor objects.
[ "A", "function", "that", "returns", "a", "Map", "of", "all", "the", "available", "properties", "on", "a", "given", "class", "including", "write", "-", "only", "properties", ".", "The", "properties", "returned", "is", "mostly", "a", "superset", "of", "those", "returned", "from", "the", "standard", "JavaBeans", "Introspector", "except", "more", "properties", "are", "made", "available", "to", "interfaces", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/CompleteIntrospector.java#L68-L90
24
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/classfile/ConstantLongInfo.java
ConstantLongInfo.make
static ConstantLongInfo make(ConstantPool cp, long value) { ConstantInfo ci = new ConstantLongInfo(value); return (ConstantLongInfo)cp.addConstant(ci); }
java
static ConstantLongInfo make(ConstantPool cp, long value) { ConstantInfo ci = new ConstantLongInfo(value); return (ConstantLongInfo)cp.addConstant(ci); }
[ "static", "ConstantLongInfo", "make", "(", "ConstantPool", "cp", ",", "long", "value", ")", "{", "ConstantInfo", "ci", "=", "new", "ConstantLongInfo", "(", "value", ")", ";", "return", "(", "ConstantLongInfo", ")", "cp", ".", "addConstant", "(", "ci", ")", ";", "}" ]
Will return either a new ConstantLongInfo object or one already in the constant pool. If it is a new ConstantLongInfo, it will be inserted into the pool.
[ "Will", "return", "either", "a", "new", "ConstantLongInfo", "object", "or", "one", "already", "in", "the", "constant", "pool", ".", "If", "it", "is", "a", "new", "ConstantLongInfo", "it", "will", "be", "inserted", "into", "the", "pool", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/ConstantLongInfo.java#L35-L38
25
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Parser.java
Parser.parse
public Template parse() throws IOException { Template t = parseTemplate(); if (t != null) { return t; } return new Template(new SourceInfo(0, 0, 0), null, null, false, null, null); }
java
public Template parse() throws IOException { Template t = parseTemplate(); if (t != null) { return t; } return new Template(new SourceInfo(0, 0, 0), null, null, false, null, null); }
[ "public", "Template", "parse", "(", ")", "throws", "IOException", "{", "Template", "t", "=", "parseTemplate", "(", ")", ";", "if", "(", "t", "!=", "null", ")", "{", "return", "t", ";", "}", "return", "new", "Template", "(", "new", "SourceInfo", "(", "0", ",", "0", ",", "0", ")", ",", "null", ",", "null", ",", "false", ",", "null", ",", "null", ")", ";", "}" ]
Returns a parse tree by its root node. The parse tree is generated from tokens read from the scanner. Any errors encountered while parsing are delivered by dispatching an event. Add a compile listener in order to capture parse errors. @return Non-null template node, even if there were errors during parsing. @see Parser#addErrorListener
[ "Returns", "a", "parse", "tree", "by", "its", "root", "node", ".", "The", "parse", "tree", "is", "generated", "from", "tokens", "read", "from", "the", "scanner", ".", "Any", "errors", "encountered", "while", "parsing", "are", "delivered", "by", "dispatching", "an", "event", ".", "Add", "a", "compile", "listener", "in", "order", "to", "capture", "parse", "errors", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Parser.java#L166-L174
26
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Parser.java
Parser.parseIfStatement
private IfStatement parseIfStatement(Token token) throws IOException { SourceInfo info = token.getSourceInfo(); Expression condition = parseExpression(); if (!(condition instanceof ParenExpression)) { error("if.condition", condition.getSourceInfo()); } Block thenPart = parseBlock(); Block elsePart = null; token = peek(); if (token.getID() != Token.ELSE) { info = info.setEndPosition(thenPart.getSourceInfo()); } else { read(); // read the else keyword token = peek(); if (token.getID() == Token.IF) { elsePart = new Block(parseIfStatement(read())); } else { elsePart = parseBlock(); } info = info.setEndPosition(elsePart.getSourceInfo()); } return new IfStatement(info, condition, thenPart, elsePart); }
java
private IfStatement parseIfStatement(Token token) throws IOException { SourceInfo info = token.getSourceInfo(); Expression condition = parseExpression(); if (!(condition instanceof ParenExpression)) { error("if.condition", condition.getSourceInfo()); } Block thenPart = parseBlock(); Block elsePart = null; token = peek(); if (token.getID() != Token.ELSE) { info = info.setEndPosition(thenPart.getSourceInfo()); } else { read(); // read the else keyword token = peek(); if (token.getID() == Token.IF) { elsePart = new Block(parseIfStatement(read())); } else { elsePart = parseBlock(); } info = info.setEndPosition(elsePart.getSourceInfo()); } return new IfStatement(info, condition, thenPart, elsePart); }
[ "private", "IfStatement", "parseIfStatement", "(", "Token", "token", ")", "throws", "IOException", "{", "SourceInfo", "info", "=", "token", ".", "getSourceInfo", "(", ")", ";", "Expression", "condition", "=", "parseExpression", "(", ")", ";", "if", "(", "!", "(", "condition", "instanceof", "ParenExpression", ")", ")", "{", "error", "(", "\"if.condition\"", ",", "condition", ".", "getSourceInfo", "(", ")", ")", ";", "}", "Block", "thenPart", "=", "parseBlock", "(", ")", ";", "Block", "elsePart", "=", "null", ";", "token", "=", "peek", "(", ")", ";", "if", "(", "token", ".", "getID", "(", ")", "!=", "Token", ".", "ELSE", ")", "{", "info", "=", "info", ".", "setEndPosition", "(", "thenPart", ".", "getSourceInfo", "(", ")", ")", ";", "}", "else", "{", "read", "(", ")", ";", "// read the else keyword", "token", "=", "peek", "(", ")", ";", "if", "(", "token", ".", "getID", "(", ")", "==", "Token", ".", "IF", ")", "{", "elsePart", "=", "new", "Block", "(", "parseIfStatement", "(", "read", "(", ")", ")", ")", ";", "}", "else", "{", "elsePart", "=", "parseBlock", "(", ")", ";", "}", "info", "=", "info", ".", "setEndPosition", "(", "elsePart", ".", "getSourceInfo", "(", ")", ")", ";", "}", "return", "new", "IfStatement", "(", "info", ",", "condition", ",", "thenPart", ",", "elsePart", ")", ";", "}" ]
When this is called, the keyword "if" has already been read.
[ "When", "this", "is", "called", "the", "keyword", "if", "has", "already", "been", "read", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Parser.java#L624-L654
27
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Parser.java
Parser.parseForeachStatement
private ForeachStatement parseForeachStatement(Token token) throws IOException { SourceInfo info = token.getSourceInfo(); token = peek(); if (token.getID() == Token.LPAREN) { read(); } else { error("foreach.lparen.expected", token); } VariableRef loopVar = parseLValue(); // mod for declarative typing boolean foundASToken = false; Token asToken = peek(); if (asToken.getID() == Token.AS) { foundASToken = true; read(); TypeName typeName = parseTypeName(); SourceInfo info2 = peek().getSourceInfo(); loopVar.setVariable(new Variable(info2, loopVar.getName(), typeName, true)); } // end mod token = peek(); if (token.getID() == Token.IN) { read(); } else { error("foreach.in.expected", token); } Expression range = parseExpression(); Expression endRange = null; token = peek(); if (token.getID() == Token.DOTDOT) { read(); endRange = parseExpression(); token = peek(); } if (endRange != null && foundASToken) error("foreach.as.not.allowed", asToken); boolean reverse = false; if (token.getID() == Token.REVERSE) { read(); reverse = true; token = peek(); } if (token.getID() == Token.RPAREN) { read(); } else { error("foreach.rparen.expected", token); } Block body = parseBlock(); info = info.setEndPosition(body.getSourceInfo()); return new ForeachStatement (info, loopVar, range, endRange, reverse, body); }
java
private ForeachStatement parseForeachStatement(Token token) throws IOException { SourceInfo info = token.getSourceInfo(); token = peek(); if (token.getID() == Token.LPAREN) { read(); } else { error("foreach.lparen.expected", token); } VariableRef loopVar = parseLValue(); // mod for declarative typing boolean foundASToken = false; Token asToken = peek(); if (asToken.getID() == Token.AS) { foundASToken = true; read(); TypeName typeName = parseTypeName(); SourceInfo info2 = peek().getSourceInfo(); loopVar.setVariable(new Variable(info2, loopVar.getName(), typeName, true)); } // end mod token = peek(); if (token.getID() == Token.IN) { read(); } else { error("foreach.in.expected", token); } Expression range = parseExpression(); Expression endRange = null; token = peek(); if (token.getID() == Token.DOTDOT) { read(); endRange = parseExpression(); token = peek(); } if (endRange != null && foundASToken) error("foreach.as.not.allowed", asToken); boolean reverse = false; if (token.getID() == Token.REVERSE) { read(); reverse = true; token = peek(); } if (token.getID() == Token.RPAREN) { read(); } else { error("foreach.rparen.expected", token); } Block body = parseBlock(); info = info.setEndPosition(body.getSourceInfo()); return new ForeachStatement (info, loopVar, range, endRange, reverse, body); }
[ "private", "ForeachStatement", "parseForeachStatement", "(", "Token", "token", ")", "throws", "IOException", "{", "SourceInfo", "info", "=", "token", ".", "getSourceInfo", "(", ")", ";", "token", "=", "peek", "(", ")", ";", "if", "(", "token", ".", "getID", "(", ")", "==", "Token", ".", "LPAREN", ")", "{", "read", "(", ")", ";", "}", "else", "{", "error", "(", "\"foreach.lparen.expected\"", ",", "token", ")", ";", "}", "VariableRef", "loopVar", "=", "parseLValue", "(", ")", ";", "// mod for declarative typing", "boolean", "foundASToken", "=", "false", ";", "Token", "asToken", "=", "peek", "(", ")", ";", "if", "(", "asToken", ".", "getID", "(", ")", "==", "Token", ".", "AS", ")", "{", "foundASToken", "=", "true", ";", "read", "(", ")", ";", "TypeName", "typeName", "=", "parseTypeName", "(", ")", ";", "SourceInfo", "info2", "=", "peek", "(", ")", ".", "getSourceInfo", "(", ")", ";", "loopVar", ".", "setVariable", "(", "new", "Variable", "(", "info2", ",", "loopVar", ".", "getName", "(", ")", ",", "typeName", ",", "true", ")", ")", ";", "}", "// end mod", "token", "=", "peek", "(", ")", ";", "if", "(", "token", ".", "getID", "(", ")", "==", "Token", ".", "IN", ")", "{", "read", "(", ")", ";", "}", "else", "{", "error", "(", "\"foreach.in.expected\"", ",", "token", ")", ";", "}", "Expression", "range", "=", "parseExpression", "(", ")", ";", "Expression", "endRange", "=", "null", ";", "token", "=", "peek", "(", ")", ";", "if", "(", "token", ".", "getID", "(", ")", "==", "Token", ".", "DOTDOT", ")", "{", "read", "(", ")", ";", "endRange", "=", "parseExpression", "(", ")", ";", "token", "=", "peek", "(", ")", ";", "}", "if", "(", "endRange", "!=", "null", "&&", "foundASToken", ")", "error", "(", "\"foreach.as.not.allowed\"", ",", "asToken", ")", ";", "boolean", "reverse", "=", "false", ";", "if", "(", "token", ".", "getID", "(", ")", "==", "Token", ".", "REVERSE", ")", "{", "read", "(", ")", ";", "reverse", "=", "true", ";", "token", "=", "peek", "(", ")", ";", "}", "if", "(", "token", ".", "getID", "(", ")", "==", "Token", ".", "RPAREN", ")", "{", "read", "(", ")", ";", "}", "else", "{", "error", "(", "\"foreach.rparen.expected\"", ",", "token", ")", ";", "}", "Block", "body", "=", "parseBlock", "(", ")", ";", "info", "=", "info", ".", "setEndPosition", "(", "body", ".", "getSourceInfo", "(", ")", ")", ";", "return", "new", "ForeachStatement", "(", "info", ",", "loopVar", ",", "range", ",", "endRange", ",", "reverse", ",", "body", ")", ";", "}" ]
When this is called, the keyword "foreach" has already been read.
[ "When", "this", "is", "called", "the", "keyword", "foreach", "has", "already", "been", "read", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Parser.java#L657-L725
28
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Parser.java
Parser.parseAssignmentStatement
private AssignmentStatement parseAssignmentStatement(Token token) throws IOException { // TODO: allow lvalue to support dot notations // ie: field = x (store local variable) // obj.field = x (obj.setField) // obj.field.field = x (obj.getField().setField) // array[idx] = x (array[idx]) // list[idx] = x (list.set(idx, x)) // map[key] = x (map.put(key, x)) // map[obj.name] = x (map.put(obj.getName(), x) SourceInfo info = token.getSourceInfo(); VariableRef lvalue = parseLValue(token); if (peek().getID() == Token.ASSIGN) { read(); } else { error("assignment.equals.expected", peek()); } Expression rvalue = parseExpression(); info = info.setEndPosition(rvalue.getSourceInfo()); // Start mod for 'as' keyword for declarative typing if (peek().getID() == Token.AS) { read(); TypeName typeName = parseTypeName(); SourceInfo info2 = peek().getSourceInfo(); lvalue.setVariable(new Variable(info2, lvalue.getName(), typeName, true)); } // End mod return new AssignmentStatement(info, lvalue, rvalue); }
java
private AssignmentStatement parseAssignmentStatement(Token token) throws IOException { // TODO: allow lvalue to support dot notations // ie: field = x (store local variable) // obj.field = x (obj.setField) // obj.field.field = x (obj.getField().setField) // array[idx] = x (array[idx]) // list[idx] = x (list.set(idx, x)) // map[key] = x (map.put(key, x)) // map[obj.name] = x (map.put(obj.getName(), x) SourceInfo info = token.getSourceInfo(); VariableRef lvalue = parseLValue(token); if (peek().getID() == Token.ASSIGN) { read(); } else { error("assignment.equals.expected", peek()); } Expression rvalue = parseExpression(); info = info.setEndPosition(rvalue.getSourceInfo()); // Start mod for 'as' keyword for declarative typing if (peek().getID() == Token.AS) { read(); TypeName typeName = parseTypeName(); SourceInfo info2 = peek().getSourceInfo(); lvalue.setVariable(new Variable(info2, lvalue.getName(), typeName, true)); } // End mod return new AssignmentStatement(info, lvalue, rvalue); }
[ "private", "AssignmentStatement", "parseAssignmentStatement", "(", "Token", "token", ")", "throws", "IOException", "{", "// TODO: allow lvalue to support dot notations", "// ie: field = x (store local variable)", "// obj.field = x (obj.setField)", "// obj.field.field = x (obj.getField().setField)", "// array[idx] = x (array[idx])", "// list[idx] = x (list.set(idx, x))", "// map[key] = x (map.put(key, x))", "// map[obj.name] = x (map.put(obj.getName(), x)", "SourceInfo", "info", "=", "token", ".", "getSourceInfo", "(", ")", ";", "VariableRef", "lvalue", "=", "parseLValue", "(", "token", ")", ";", "if", "(", "peek", "(", ")", ".", "getID", "(", ")", "==", "Token", ".", "ASSIGN", ")", "{", "read", "(", ")", ";", "}", "else", "{", "error", "(", "\"assignment.equals.expected\"", ",", "peek", "(", ")", ")", ";", "}", "Expression", "rvalue", "=", "parseExpression", "(", ")", ";", "info", "=", "info", ".", "setEndPosition", "(", "rvalue", ".", "getSourceInfo", "(", ")", ")", ";", "// Start mod for 'as' keyword for declarative typing", "if", "(", "peek", "(", ")", ".", "getID", "(", ")", "==", "Token", ".", "AS", ")", "{", "read", "(", ")", ";", "TypeName", "typeName", "=", "parseTypeName", "(", ")", ";", "SourceInfo", "info2", "=", "peek", "(", ")", ".", "getSourceInfo", "(", ")", ";", "lvalue", ".", "setVariable", "(", "new", "Variable", "(", "info2", ",", "lvalue", ".", "getName", "(", ")", ",", "typeName", ",", "true", ")", ")", ";", "}", "// End mod", "return", "new", "AssignmentStatement", "(", "info", ",", "lvalue", ",", "rvalue", ")", ";", "}" ]
When this is called, the identifier token has already been read.
[ "When", "this", "is", "called", "the", "identifier", "token", "has", "already", "been", "read", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Parser.java#L728-L763
29
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Parser.java
Parser.parseFunctionCallExpression
private FunctionCallExpression parseFunctionCallExpression(Token token) throws IOException { Token next = peek(); if (next.getID() != Token.LPAREN) { return null; } SourceInfo info = token.getSourceInfo(); Name target = new Name(info, token.getStringValue()); // parse remainder of call expression return parseCallExpression(FunctionCallExpression.class, null, target, info); }
java
private FunctionCallExpression parseFunctionCallExpression(Token token) throws IOException { Token next = peek(); if (next.getID() != Token.LPAREN) { return null; } SourceInfo info = token.getSourceInfo(); Name target = new Name(info, token.getStringValue()); // parse remainder of call expression return parseCallExpression(FunctionCallExpression.class, null, target, info); }
[ "private", "FunctionCallExpression", "parseFunctionCallExpression", "(", "Token", "token", ")", "throws", "IOException", "{", "Token", "next", "=", "peek", "(", ")", ";", "if", "(", "next", ".", "getID", "(", ")", "!=", "Token", ".", "LPAREN", ")", "{", "return", "null", ";", "}", "SourceInfo", "info", "=", "token", ".", "getSourceInfo", "(", ")", ";", "Name", "target", "=", "new", "Name", "(", "info", ",", "token", ".", "getStringValue", "(", ")", ")", ";", "// parse remainder of call expression", "return", "parseCallExpression", "(", "FunctionCallExpression", ".", "class", ",", "null", ",", "target", ",", "info", ")", ";", "}" ]
a FunctionCallExpression. Token passed in must be an identifier.
[ "a", "FunctionCallExpression", ".", "Token", "passed", "in", "must", "be", "an", "identifier", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Parser.java#L1424-L1438
30
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/classfile/ConstantPool.java
ConstantPool.getConstant
public ConstantInfo getConstant(int index) { if (mIndexedConstants == null) { throw new ArrayIndexOutOfBoundsException ("Constant pool indexes have not been assigned"); } return (ConstantInfo)mIndexedConstants.get(index); }
java
public ConstantInfo getConstant(int index) { if (mIndexedConstants == null) { throw new ArrayIndexOutOfBoundsException ("Constant pool indexes have not been assigned"); } return (ConstantInfo)mIndexedConstants.get(index); }
[ "public", "ConstantInfo", "getConstant", "(", "int", "index", ")", "{", "if", "(", "mIndexedConstants", "==", "null", ")", "{", "throw", "new", "ArrayIndexOutOfBoundsException", "(", "\"Constant pool indexes have not been assigned\"", ")", ";", "}", "return", "(", "ConstantInfo", ")", "mIndexedConstants", ".", "get", "(", "index", ")", ";", "}" ]
Returns a constant from the pool by index, or throws an exception if not found. If this constant pool has not yet been written or was not created by the read method, indexes are not assigned. @throws ArrayIndexOutOfBoundsException if index is out of range.
[ "Returns", "a", "constant", "from", "the", "pool", "by", "index", "or", "throws", "an", "exception", "if", "not", "found", ".", "If", "this", "constant", "pool", "has", "not", "yet", "been", "written", "or", "was", "not", "created", "by", "the", "read", "method", "indexes", "are", "not", "assigned", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/ConstantPool.java#L72-L79
31
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/classfile/ConstantPool.java
ConstantPool.addConstantConstructor
public ConstantMethodInfo addConstantConstructor(String className, TypeDesc[] params) { return addConstantMethod(className, "<init>", null, params); }
java
public ConstantMethodInfo addConstantConstructor(String className, TypeDesc[] params) { return addConstantMethod(className, "<init>", null, params); }
[ "public", "ConstantMethodInfo", "addConstantConstructor", "(", "String", "className", ",", "TypeDesc", "[", "]", "params", ")", "{", "return", "addConstantMethod", "(", "className", ",", "\"<init>\"", ",", "null", ",", "params", ")", ";", "}" ]
Get or create a constant from the constant pool representing a constructor in any class.
[ "Get", "or", "create", "a", "constant", "from", "the", "constant", "pool", "representing", "a", "constructor", "in", "any", "class", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/ConstantPool.java#L171-L174
32
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/classfile/ConstantPool.java
ConstantPool.addConstant
public ConstantInfo addConstant(ConstantInfo constant) { ConstantInfo info = (ConstantInfo)mConstants.get(constant); if (info != null) { return info; } int entryCount = constant.getEntryCount(); if (mIndexedConstants != null && mPreserveOrder) { int size = mIndexedConstants.size(); mIndexedConstants.setSize(size + entryCount); mIndexedConstants.set(size, constant); } mConstants.put(constant, constant); mEntries += entryCount; return constant; }
java
public ConstantInfo addConstant(ConstantInfo constant) { ConstantInfo info = (ConstantInfo)mConstants.get(constant); if (info != null) { return info; } int entryCount = constant.getEntryCount(); if (mIndexedConstants != null && mPreserveOrder) { int size = mIndexedConstants.size(); mIndexedConstants.setSize(size + entryCount); mIndexedConstants.set(size, constant); } mConstants.put(constant, constant); mEntries += entryCount; return constant; }
[ "public", "ConstantInfo", "addConstant", "(", "ConstantInfo", "constant", ")", "{", "ConstantInfo", "info", "=", "(", "ConstantInfo", ")", "mConstants", ".", "get", "(", "constant", ")", ";", "if", "(", "info", "!=", "null", ")", "{", "return", "info", ";", "}", "int", "entryCount", "=", "constant", ".", "getEntryCount", "(", ")", ";", "if", "(", "mIndexedConstants", "!=", "null", "&&", "mPreserveOrder", ")", "{", "int", "size", "=", "mIndexedConstants", ".", "size", "(", ")", ";", "mIndexedConstants", ".", "setSize", "(", "size", "+", "entryCount", ")", ";", "mIndexedConstants", ".", "set", "(", "size", ",", "constant", ")", ";", "}", "mConstants", ".", "put", "(", "constant", ",", "constant", ")", ";", "mEntries", "+=", "entryCount", ";", "return", "constant", ";", "}" ]
Will only insert into the pool if the constant is not already in the pool. @return The actual constant in the pool.
[ "Will", "only", "insert", "into", "the", "pool", "if", "the", "constant", "is", "not", "already", "in", "the", "pool", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/ConstantPool.java#L232-L250
33
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/HttpContext.java
HttpContext.doGet
public String doGet(String host, String path, int port, Map<String, String> headers, int timeout) throws UnknownHostException, ConnectException, IOException { return doHttpCall(host, path, null, port, headers, timeout, false); }
java
public String doGet(String host, String path, int port, Map<String, String> headers, int timeout) throws UnknownHostException, ConnectException, IOException { return doHttpCall(host, path, null, port, headers, timeout, false); }
[ "public", "String", "doGet", "(", "String", "host", ",", "String", "path", ",", "int", "port", ",", "Map", "<", "String", ",", "String", ">", "headers", ",", "int", "timeout", ")", "throws", "UnknownHostException", ",", "ConnectException", ",", "IOException", "{", "return", "doHttpCall", "(", "host", ",", "path", ",", "null", ",", "port", ",", "headers", ",", "timeout", ",", "false", ")", ";", "}" ]
Perform an HTTP GET at the given path returning the results of the response. @param host The hostname of the request @param path The path of the request @param port The port of the request @param headers The headers to pass in the request @param timeout The timeout of the request in milliseconds @return The data of the resposne @throws UnknownHostException if the host cannot be found @throws ConnectException if the HTTP server does not respond @throws IOException if an I/O error occurs processing the request
[ "Perform", "an", "HTTP", "GET", "at", "the", "given", "path", "returning", "the", "results", "of", "the", "response", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/HttpContext.java#L60-L65
34
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/HttpContext.java
HttpContext.doSecureGet
public String doSecureGet(String host, String path, int port, Map<String, String> headers, int timeout) throws UnknownHostException, ConnectException, IOException { return doHttpCall(host, path, null, port, headers, timeout, true); }
java
public String doSecureGet(String host, String path, int port, Map<String, String> headers, int timeout) throws UnknownHostException, ConnectException, IOException { return doHttpCall(host, path, null, port, headers, timeout, true); }
[ "public", "String", "doSecureGet", "(", "String", "host", ",", "String", "path", ",", "int", "port", ",", "Map", "<", "String", ",", "String", ">", "headers", ",", "int", "timeout", ")", "throws", "UnknownHostException", ",", "ConnectException", ",", "IOException", "{", "return", "doHttpCall", "(", "host", ",", "path", ",", "null", ",", "port", ",", "headers", ",", "timeout", ",", "true", ")", ";", "}" ]
Perform a secure HTTPS GET at the given path returning the results of the response. @param host The hostname of the request @param path The path of the request @param port The port of the request @param headers The headers to pass in the request @param timeout The timeout of the request in milliseconds @return The data of the resposne @throws UnknownHostException if the host cannot be found @throws ConnectException if the HTTP server does not respond @throws IOException if an I/O error occurs processing the request
[ "Perform", "a", "secure", "HTTPS", "GET", "at", "the", "given", "path", "returning", "the", "results", "of", "the", "response", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/HttpContext.java#L83-L89
35
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/HttpContext.java
HttpContext.doPost
public String doPost(String host, String path, String postData, int port, Map<String, String> headers, int timeout) throws UnknownHostException, ConnectException, IOException { return doHttpCall(host, path, postData, port, headers, timeout, false); }
java
public String doPost(String host, String path, String postData, int port, Map<String, String> headers, int timeout) throws UnknownHostException, ConnectException, IOException { return doHttpCall(host, path, postData, port, headers, timeout, false); }
[ "public", "String", "doPost", "(", "String", "host", ",", "String", "path", ",", "String", "postData", ",", "int", "port", ",", "Map", "<", "String", ",", "String", ">", "headers", ",", "int", "timeout", ")", "throws", "UnknownHostException", ",", "ConnectException", ",", "IOException", "{", "return", "doHttpCall", "(", "host", ",", "path", ",", "postData", ",", "port", ",", "headers", ",", "timeout", ",", "false", ")", ";", "}" ]
Perform an HTTP POST at the given path sending in the given post data returning the results of the response. @param host The hostname of the request @param path The path of the request @param postData The POST data to send in the request @param port The port of the request @param headers The headers to pass in the request @param timeout The timeout of the request in milliseconds @return The data of the resposne @throws UnknownHostException if the host cannot be found @throws ConnectException if the HTTP server does not respond @throws IOException if an I/O error occurs processing the request
[ "Perform", "an", "HTTP", "POST", "at", "the", "given", "path", "sending", "in", "the", "given", "post", "data", "returning", "the", "results", "of", "the", "response", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/HttpContext.java#L108-L113
36
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/HttpContext.java
HttpContext.doSecurePost
public String doSecurePost(String host, String path, String postData, int port, Map<String, String> headers, int timeout) throws UnknownHostException, ConnectException, IOException { return doHttpCall(host, path, postData, port, headers, timeout, true); }
java
public String doSecurePost(String host, String path, String postData, int port, Map<String, String> headers, int timeout) throws UnknownHostException, ConnectException, IOException { return doHttpCall(host, path, postData, port, headers, timeout, true); }
[ "public", "String", "doSecurePost", "(", "String", "host", ",", "String", "path", ",", "String", "postData", ",", "int", "port", ",", "Map", "<", "String", ",", "String", ">", "headers", ",", "int", "timeout", ")", "throws", "UnknownHostException", ",", "ConnectException", ",", "IOException", "{", "return", "doHttpCall", "(", "host", ",", "path", ",", "postData", ",", "port", ",", "headers", ",", "timeout", ",", "true", ")", ";", "}" ]
Perform a secure HTTPS POST at the given path sending in the given post data returning the results of the response. @param host The hostname of the request @param path The path of the request @param postData The POST data to send in the request @param port The port of the request @param headers The headers to pass in the request @param timeout The timeout of the request in milliseconds @return The data of the resposne @throws UnknownHostException if the host cannot be found @throws ConnectException if the HTTP server does not respond @throws IOException if an I/O error occurs processing the request
[ "Perform", "a", "secure", "HTTPS", "POST", "at", "the", "given", "path", "sending", "in", "the", "given", "post", "data", "returning", "the", "results", "of", "the", "response", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/HttpContext.java#L132-L138
37
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teatools/TypeDescription.java
TypeDescription.getArrayType
public TypeDescription getArrayType() { Class<?> c = getTeaToolsUtils().getArrayType(mType); if (mType == c) { return this; } return getTeaToolsUtils().createTypeDescription(c); }
java
public TypeDescription getArrayType() { Class<?> c = getTeaToolsUtils().getArrayType(mType); if (mType == c) { return this; } return getTeaToolsUtils().createTypeDescription(c); }
[ "public", "TypeDescription", "getArrayType", "(", ")", "{", "Class", "<", "?", ">", "c", "=", "getTeaToolsUtils", "(", ")", ".", "getArrayType", "(", "mType", ")", ";", "if", "(", "mType", "==", "c", ")", "{", "return", "this", ";", "}", "return", "getTeaToolsUtils", "(", ")", ".", "createTypeDescription", "(", "c", ")", ";", "}" ]
Returns the array type. Returns this if it is not an array type.
[ "Returns", "the", "array", "type", ".", "Returns", "this", "if", "it", "is", "not", "an", "array", "type", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teatools/TypeDescription.java#L129-L137
38
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teatools/TypeDescription.java
TypeDescription.getBeanInfo
public BeanInfo getBeanInfo() { if (mBeanInfo == null) { try { mBeanInfo = getTeaToolsUtils().getBeanInfo(mType); } catch (Exception e) { return null; } } return mBeanInfo; }
java
public BeanInfo getBeanInfo() { if (mBeanInfo == null) { try { mBeanInfo = getTeaToolsUtils().getBeanInfo(mType); } catch (Exception e) { return null; } } return mBeanInfo; }
[ "public", "BeanInfo", "getBeanInfo", "(", ")", "{", "if", "(", "mBeanInfo", "==", "null", ")", "{", "try", "{", "mBeanInfo", "=", "getTeaToolsUtils", "(", ")", ".", "getBeanInfo", "(", "mType", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "null", ";", "}", "}", "return", "mBeanInfo", ";", "}" ]
Introspects a Java bean to learn about all its properties, exposed methods, and events. Returns null if the BeanInfo could not be created.
[ "Introspects", "a", "Java", "bean", "to", "learn", "about", "all", "its", "properties", "exposed", "methods", "and", "events", ".", "Returns", "null", "if", "the", "BeanInfo", "could", "not", "be", "created", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teatools/TypeDescription.java#L161-L172
39
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teatools/TypeDescription.java
TypeDescription.getPropertyDescriptors
public PropertyDescriptor[] getPropertyDescriptors() { BeanInfo info = getBeanInfo(); if (info == null) { return null; } PropertyDescriptor[] pds = info.getPropertyDescriptors(); getTeaToolsUtils().sortPropertyDescriptors(pds); return pds; }
java
public PropertyDescriptor[] getPropertyDescriptors() { BeanInfo info = getBeanInfo(); if (info == null) { return null; } PropertyDescriptor[] pds = info.getPropertyDescriptors(); getTeaToolsUtils().sortPropertyDescriptors(pds); return pds; }
[ "public", "PropertyDescriptor", "[", "]", "getPropertyDescriptors", "(", ")", "{", "BeanInfo", "info", "=", "getBeanInfo", "(", ")", ";", "if", "(", "info", "==", "null", ")", "{", "return", "null", ";", "}", "PropertyDescriptor", "[", "]", "pds", "=", "info", ".", "getPropertyDescriptors", "(", ")", ";", "getTeaToolsUtils", "(", ")", ".", "sortPropertyDescriptors", "(", "pds", ")", ";", "return", "pds", ";", "}" ]
Returns the type's PropertyDescriptors.
[ "Returns", "the", "type", "s", "PropertyDescriptors", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teatools/TypeDescription.java#L191-L200
40
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teatools/TypeDescription.java
TypeDescription.getMethodDescriptors
public MethodDescriptor[] getMethodDescriptors() { BeanInfo info = getBeanInfo(); if (info == null) { return null; } MethodDescriptor[] mds = info.getMethodDescriptors(); getTeaToolsUtils().sortMethodDescriptors(mds); return mds; }
java
public MethodDescriptor[] getMethodDescriptors() { BeanInfo info = getBeanInfo(); if (info == null) { return null; } MethodDescriptor[] mds = info.getMethodDescriptors(); getTeaToolsUtils().sortMethodDescriptors(mds); return mds; }
[ "public", "MethodDescriptor", "[", "]", "getMethodDescriptors", "(", ")", "{", "BeanInfo", "info", "=", "getBeanInfo", "(", ")", ";", "if", "(", "info", "==", "null", ")", "{", "return", "null", ";", "}", "MethodDescriptor", "[", "]", "mds", "=", "info", ".", "getMethodDescriptors", "(", ")", ";", "getTeaToolsUtils", "(", ")", ".", "sortMethodDescriptors", "(", "mds", ")", ";", "return", "mds", ";", "}" ]
Returns the type's MethodDescriptors.
[ "Returns", "the", "type", "s", "MethodDescriptors", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teatools/TypeDescription.java#L229-L238
41
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/classfile/Opcode.java
Opcode.reverseIfOpcode
public final static byte reverseIfOpcode(byte opcode) { // Actually, because the numbers assigned to the "if" opcodes // were so cleverly chosen, all I really need to do is toggle // bit 0. I'm not going to do that because I still need to check if // an invalid opcode was passed in. switch (opcode) { case IF_ACMPEQ: return IF_ACMPNE; case IF_ACMPNE: return IF_ACMPEQ; case IF_ICMPEQ: return IF_ICMPNE; case IF_ICMPNE: return IF_ICMPEQ; case IF_ICMPLT: return IF_ICMPGE; case IF_ICMPGE: return IF_ICMPLT; case IF_ICMPGT: return IF_ICMPLE; case IF_ICMPLE: return IF_ICMPGT; case IFEQ: return IFNE; case IFNE: return IFEQ; case IFLT: return IFGE; case IFGE: return IFLT; case IFGT: return IFLE; case IFLE: return IFGT; case IFNONNULL: return IFNULL; case IFNULL: return IFNONNULL; default: throw new IllegalArgumentException ("Opcode not an if instruction: " + getMnemonic(opcode)); } }
java
public final static byte reverseIfOpcode(byte opcode) { // Actually, because the numbers assigned to the "if" opcodes // were so cleverly chosen, all I really need to do is toggle // bit 0. I'm not going to do that because I still need to check if // an invalid opcode was passed in. switch (opcode) { case IF_ACMPEQ: return IF_ACMPNE; case IF_ACMPNE: return IF_ACMPEQ; case IF_ICMPEQ: return IF_ICMPNE; case IF_ICMPNE: return IF_ICMPEQ; case IF_ICMPLT: return IF_ICMPGE; case IF_ICMPGE: return IF_ICMPLT; case IF_ICMPGT: return IF_ICMPLE; case IF_ICMPLE: return IF_ICMPGT; case IFEQ: return IFNE; case IFNE: return IFEQ; case IFLT: return IFGE; case IFGE: return IFLT; case IFGT: return IFLE; case IFLE: return IFGT; case IFNONNULL: return IFNULL; case IFNULL: return IFNONNULL; default: throw new IllegalArgumentException ("Opcode not an if instruction: " + getMnemonic(opcode)); } }
[ "public", "final", "static", "byte", "reverseIfOpcode", "(", "byte", "opcode", ")", "{", "// Actually, because the numbers assigned to the \"if\" opcodes", "// were so cleverly chosen, all I really need to do is toggle", "// bit 0. I'm not going to do that because I still need to check if ", "// an invalid opcode was passed in.", "switch", "(", "opcode", ")", "{", "case", "IF_ACMPEQ", ":", "return", "IF_ACMPNE", ";", "case", "IF_ACMPNE", ":", "return", "IF_ACMPEQ", ";", "case", "IF_ICMPEQ", ":", "return", "IF_ICMPNE", ";", "case", "IF_ICMPNE", ":", "return", "IF_ICMPEQ", ";", "case", "IF_ICMPLT", ":", "return", "IF_ICMPGE", ";", "case", "IF_ICMPGE", ":", "return", "IF_ICMPLT", ";", "case", "IF_ICMPGT", ":", "return", "IF_ICMPLE", ";", "case", "IF_ICMPLE", ":", "return", "IF_ICMPGT", ";", "case", "IFEQ", ":", "return", "IFNE", ";", "case", "IFNE", ":", "return", "IFEQ", ";", "case", "IFLT", ":", "return", "IFGE", ";", "case", "IFGE", ":", "return", "IFLT", ";", "case", "IFGT", ":", "return", "IFLE", ";", "case", "IFLE", ":", "return", "IFGT", ";", "case", "IFNONNULL", ":", "return", "IFNULL", ";", "case", "IFNULL", ":", "return", "IFNONNULL", ";", "default", ":", "throw", "new", "IllegalArgumentException", "(", "\"Opcode not an if instruction: \"", "+", "getMnemonic", "(", "opcode", ")", ")", ";", "}", "}" ]
Reverses the condition for an "if" opcode. i.e. IFEQ is changed to IFNE.
[ "Reverses", "the", "condition", "for", "an", "if", "opcode", ".", "i", ".", "e", ".", "IFEQ", "is", "changed", "to", "IFNE", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/Opcode.java#L250-L293
42
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/TeaServletAdmin.java
TeaServletAdmin.getFunctions
public FunctionInfo[] getFunctions() { // TODO: make this a little more useful by showing more function // details. ApplicationInfo[] AppInf = getApplications(); FunctionInfo[] funcArray = null; try { MethodDescriptor[] methods = Introspector .getBeanInfo(HttpContext.class) .getMethodDescriptors(); List<FunctionInfo> funcList = new Vector<FunctionInfo>(50); for (int i = 0; i < methods.length; i++) { MethodDescriptor m = methods[i]; if (m.getMethod().getDeclaringClass() != Object.class && !m.getMethod().getName().equals("print") && !m.getMethod().getName().equals("toString")) { funcList.add(new FunctionInfo(m, null)); } } for (int i = 0; i < AppInf.length; i++) { FunctionInfo[] ctxFunctions = AppInf[i].getContextFunctions(); for (int j = 0; j < ctxFunctions.length; j++) { funcList.add(ctxFunctions[j]); } } funcArray = funcList.toArray (new FunctionInfo[funcList.size()]); Arrays.sort(funcArray); } catch (Exception ie) { ie.printStackTrace(); } return funcArray; }
java
public FunctionInfo[] getFunctions() { // TODO: make this a little more useful by showing more function // details. ApplicationInfo[] AppInf = getApplications(); FunctionInfo[] funcArray = null; try { MethodDescriptor[] methods = Introspector .getBeanInfo(HttpContext.class) .getMethodDescriptors(); List<FunctionInfo> funcList = new Vector<FunctionInfo>(50); for (int i = 0; i < methods.length; i++) { MethodDescriptor m = methods[i]; if (m.getMethod().getDeclaringClass() != Object.class && !m.getMethod().getName().equals("print") && !m.getMethod().getName().equals("toString")) { funcList.add(new FunctionInfo(m, null)); } } for (int i = 0; i < AppInf.length; i++) { FunctionInfo[] ctxFunctions = AppInf[i].getContextFunctions(); for (int j = 0; j < ctxFunctions.length; j++) { funcList.add(ctxFunctions[j]); } } funcArray = funcList.toArray (new FunctionInfo[funcList.size()]); Arrays.sort(funcArray); } catch (Exception ie) { ie.printStackTrace(); } return funcArray; }
[ "public", "FunctionInfo", "[", "]", "getFunctions", "(", ")", "{", "// TODO: make this a little more useful by showing more function", "// details.", "ApplicationInfo", "[", "]", "AppInf", "=", "getApplications", "(", ")", ";", "FunctionInfo", "[", "]", "funcArray", "=", "null", ";", "try", "{", "MethodDescriptor", "[", "]", "methods", "=", "Introspector", ".", "getBeanInfo", "(", "HttpContext", ".", "class", ")", ".", "getMethodDescriptors", "(", ")", ";", "List", "<", "FunctionInfo", ">", "funcList", "=", "new", "Vector", "<", "FunctionInfo", ">", "(", "50", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "methods", ".", "length", ";", "i", "++", ")", "{", "MethodDescriptor", "m", "=", "methods", "[", "i", "]", ";", "if", "(", "m", ".", "getMethod", "(", ")", ".", "getDeclaringClass", "(", ")", "!=", "Object", ".", "class", "&&", "!", "m", ".", "getMethod", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "\"print\"", ")", "&&", "!", "m", ".", "getMethod", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "\"toString\"", ")", ")", "{", "funcList", ".", "add", "(", "new", "FunctionInfo", "(", "m", ",", "null", ")", ")", ";", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "AppInf", ".", "length", ";", "i", "++", ")", "{", "FunctionInfo", "[", "]", "ctxFunctions", "=", "AppInf", "[", "i", "]", ".", "getContextFunctions", "(", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "ctxFunctions", ".", "length", ";", "j", "++", ")", "{", "funcList", ".", "add", "(", "ctxFunctions", "[", "j", "]", ")", ";", "}", "}", "funcArray", "=", "funcList", ".", "toArray", "(", "new", "FunctionInfo", "[", "funcList", ".", "size", "(", ")", "]", ")", ";", "Arrays", ".", "sort", "(", "funcArray", ")", ";", "}", "catch", "(", "Exception", "ie", ")", "{", "ie", ".", "printStackTrace", "(", ")", ";", "}", "return", "funcArray", ";", "}" ]
Returns information about all functions available to the templates.
[ "Returns", "information", "about", "all", "functions", "available", "to", "the", "templates", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/TeaServletAdmin.java#L240-L280
43
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/TeaServletAdmin.java
TeaServletAdmin.getKnownTemplates
@SuppressWarnings("unchecked") public TemplateWrapper[] getKnownTemplates() { if (mTemplateOrdering == null) { setTemplateOrdering("name"); } Comparator<TemplateWrapper> comparator = BeanComparator.forClass(TemplateWrapper.class).orderBy("name"); Set<TemplateWrapper> known = new TreeSet<TemplateWrapper>(comparator); TemplateLoader.Template[] loaded = mTeaServletEngine .getTemplateSource().getLoadedTemplates(); if (loaded != null) { for (int j = 0; j < loaded.length; j++) { TeaServletAdmin.TemplateWrapper wrapper = new TemplateWrapper(loaded[j], TeaServletInvocationStats.getInstance() .getStatistics(loaded[j].getName(), null), TeaServletInvocationStats.getInstance() .getStatistics(loaded[j].getName(), "__substitution"), TeaServletRequestStats.getInstance().getStats(loaded[j].getName())); try { known.add(wrapper); } catch (ClassCastException cce) { mTeaServletEngine.getLog().warn(cce); } } } String[] allNames = mTeaServletEngine.getTemplateSource() .getKnownTemplateNames(); if (allNames != null) { for (int j = 0; j < allNames.length; j++) { TeaServletAdmin.TemplateWrapper wrapper = new TemplateWrapper(allNames[j], TeaServletInvocationStats.getInstance() .getStatistics(allNames[j], null), TeaServletInvocationStats.getInstance() .getStatistics(allNames[j], "__substitution"), TeaServletRequestStats.getInstance().getStats(allNames[j])); try { known.add(wrapper); } catch (ClassCastException cce) { mTeaServletEngine.getLog().warn(cce); } } } List<TemplateWrapper> v = new ArrayList<TemplateWrapper>(known); Collections.sort(v, mTemplateOrdering); // return (TeaServletAdmin.TemplateWrapper[])known.toArray(new TemplateWrapper[known.size()]); return v.toArray(new TemplateWrapper[v.size()]); }
java
@SuppressWarnings("unchecked") public TemplateWrapper[] getKnownTemplates() { if (mTemplateOrdering == null) { setTemplateOrdering("name"); } Comparator<TemplateWrapper> comparator = BeanComparator.forClass(TemplateWrapper.class).orderBy("name"); Set<TemplateWrapper> known = new TreeSet<TemplateWrapper>(comparator); TemplateLoader.Template[] loaded = mTeaServletEngine .getTemplateSource().getLoadedTemplates(); if (loaded != null) { for (int j = 0; j < loaded.length; j++) { TeaServletAdmin.TemplateWrapper wrapper = new TemplateWrapper(loaded[j], TeaServletInvocationStats.getInstance() .getStatistics(loaded[j].getName(), null), TeaServletInvocationStats.getInstance() .getStatistics(loaded[j].getName(), "__substitution"), TeaServletRequestStats.getInstance().getStats(loaded[j].getName())); try { known.add(wrapper); } catch (ClassCastException cce) { mTeaServletEngine.getLog().warn(cce); } } } String[] allNames = mTeaServletEngine.getTemplateSource() .getKnownTemplateNames(); if (allNames != null) { for (int j = 0; j < allNames.length; j++) { TeaServletAdmin.TemplateWrapper wrapper = new TemplateWrapper(allNames[j], TeaServletInvocationStats.getInstance() .getStatistics(allNames[j], null), TeaServletInvocationStats.getInstance() .getStatistics(allNames[j], "__substitution"), TeaServletRequestStats.getInstance().getStats(allNames[j])); try { known.add(wrapper); } catch (ClassCastException cce) { mTeaServletEngine.getLog().warn(cce); } } } List<TemplateWrapper> v = new ArrayList<TemplateWrapper>(known); Collections.sort(v, mTemplateOrdering); // return (TeaServletAdmin.TemplateWrapper[])known.toArray(new TemplateWrapper[known.size()]); return v.toArray(new TemplateWrapper[v.size()]); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "TemplateWrapper", "[", "]", "getKnownTemplates", "(", ")", "{", "if", "(", "mTemplateOrdering", "==", "null", ")", "{", "setTemplateOrdering", "(", "\"name\"", ")", ";", "}", "Comparator", "<", "TemplateWrapper", ">", "comparator", "=", "BeanComparator", ".", "forClass", "(", "TemplateWrapper", ".", "class", ")", ".", "orderBy", "(", "\"name\"", ")", ";", "Set", "<", "TemplateWrapper", ">", "known", "=", "new", "TreeSet", "<", "TemplateWrapper", ">", "(", "comparator", ")", ";", "TemplateLoader", ".", "Template", "[", "]", "loaded", "=", "mTeaServletEngine", ".", "getTemplateSource", "(", ")", ".", "getLoadedTemplates", "(", ")", ";", "if", "(", "loaded", "!=", "null", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "loaded", ".", "length", ";", "j", "++", ")", "{", "TeaServletAdmin", ".", "TemplateWrapper", "wrapper", "=", "new", "TemplateWrapper", "(", "loaded", "[", "j", "]", ",", "TeaServletInvocationStats", ".", "getInstance", "(", ")", ".", "getStatistics", "(", "loaded", "[", "j", "]", ".", "getName", "(", ")", ",", "null", ")", ",", "TeaServletInvocationStats", ".", "getInstance", "(", ")", ".", "getStatistics", "(", "loaded", "[", "j", "]", ".", "getName", "(", ")", ",", "\"__substitution\"", ")", ",", "TeaServletRequestStats", ".", "getInstance", "(", ")", ".", "getStats", "(", "loaded", "[", "j", "]", ".", "getName", "(", ")", ")", ")", ";", "try", "{", "known", ".", "add", "(", "wrapper", ")", ";", "}", "catch", "(", "ClassCastException", "cce", ")", "{", "mTeaServletEngine", ".", "getLog", "(", ")", ".", "warn", "(", "cce", ")", ";", "}", "}", "}", "String", "[", "]", "allNames", "=", "mTeaServletEngine", ".", "getTemplateSource", "(", ")", ".", "getKnownTemplateNames", "(", ")", ";", "if", "(", "allNames", "!=", "null", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "allNames", ".", "length", ";", "j", "++", ")", "{", "TeaServletAdmin", ".", "TemplateWrapper", "wrapper", "=", "new", "TemplateWrapper", "(", "allNames", "[", "j", "]", ",", "TeaServletInvocationStats", ".", "getInstance", "(", ")", ".", "getStatistics", "(", "allNames", "[", "j", "]", ",", "null", ")", ",", "TeaServletInvocationStats", ".", "getInstance", "(", ")", ".", "getStatistics", "(", "allNames", "[", "j", "]", ",", "\"__substitution\"", ")", ",", "TeaServletRequestStats", ".", "getInstance", "(", ")", ".", "getStats", "(", "allNames", "[", "j", "]", ")", ")", ";", "try", "{", "known", ".", "add", "(", "wrapper", ")", ";", "}", "catch", "(", "ClassCastException", "cce", ")", "{", "mTeaServletEngine", ".", "getLog", "(", ")", ".", "warn", "(", "cce", ")", ";", "}", "}", "}", "List", "<", "TemplateWrapper", ">", "v", "=", "new", "ArrayList", "<", "TemplateWrapper", ">", "(", "known", ")", ";", "Collections", ".", "sort", "(", "v", ",", "mTemplateOrdering", ")", ";", "// return (TeaServletAdmin.TemplateWrapper[])known.toArray(new TemplateWrapper[known.size()]);", "return", "v", ".", "toArray", "(", "new", "TemplateWrapper", "[", "v", ".", "size", "(", ")", "]", ")", ";", "}" ]
Provides an ordered array of available templates using a handy wrapper class.
[ "Provides", "an", "ordered", "array", "of", "available", "templates", "using", "a", "handy", "wrapper", "class", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/TeaServletAdmin.java#L337-L389
44
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/TeaServletAdmin.java
TeaServletAdmin.getTemplateServerClient
private HttpClient getTemplateServerClient(String remoteSource) throws IOException { // TODO: this was copied from the RemoteCompiler class. This needs // to be moved into a location where both can access it! int port = 80; String host = remoteSource.substring(RemoteCompilationProvider.TEMPLATE_LOAD_PROTOCOL.length()); int portIndex = host.indexOf("/"); if (portIndex >= 0) { host = host.substring(0,portIndex); } portIndex = host.indexOf(":"); if (portIndex >= 0) { try { port = Integer.parseInt(host.substring(portIndex+1)); } catch (NumberFormatException nfe) { System.out.println("Invalid port number specified"); } host = host.substring(0,portIndex); } // TODO: remove the hardcoded 15 second timeout! SocketFactory factory = new PooledSocketFactory (new PlainSocketFactory(InetAddress.getByName(host), port, 15000)); return new HttpClient(factory); }
java
private HttpClient getTemplateServerClient(String remoteSource) throws IOException { // TODO: this was copied from the RemoteCompiler class. This needs // to be moved into a location where both can access it! int port = 80; String host = remoteSource.substring(RemoteCompilationProvider.TEMPLATE_LOAD_PROTOCOL.length()); int portIndex = host.indexOf("/"); if (portIndex >= 0) { host = host.substring(0,portIndex); } portIndex = host.indexOf(":"); if (portIndex >= 0) { try { port = Integer.parseInt(host.substring(portIndex+1)); } catch (NumberFormatException nfe) { System.out.println("Invalid port number specified"); } host = host.substring(0,portIndex); } // TODO: remove the hardcoded 15 second timeout! SocketFactory factory = new PooledSocketFactory (new PlainSocketFactory(InetAddress.getByName(host), port, 15000)); return new HttpClient(factory); }
[ "private", "HttpClient", "getTemplateServerClient", "(", "String", "remoteSource", ")", "throws", "IOException", "{", "// TODO: this was copied from the RemoteCompiler class. This needs", "// to be moved into a location where both can access it!", "int", "port", "=", "80", ";", "String", "host", "=", "remoteSource", ".", "substring", "(", "RemoteCompilationProvider", ".", "TEMPLATE_LOAD_PROTOCOL", ".", "length", "(", ")", ")", ";", "int", "portIndex", "=", "host", ".", "indexOf", "(", "\"/\"", ")", ";", "if", "(", "portIndex", ">=", "0", ")", "{", "host", "=", "host", ".", "substring", "(", "0", ",", "portIndex", ")", ";", "}", "portIndex", "=", "host", ".", "indexOf", "(", "\":\"", ")", ";", "if", "(", "portIndex", ">=", "0", ")", "{", "try", "{", "port", "=", "Integer", ".", "parseInt", "(", "host", ".", "substring", "(", "portIndex", "+", "1", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "nfe", ")", "{", "System", ".", "out", ".", "println", "(", "\"Invalid port number specified\"", ")", ";", "}", "host", "=", "host", ".", "substring", "(", "0", ",", "portIndex", ")", ";", "}", "// TODO: remove the hardcoded 15 second timeout!", "SocketFactory", "factory", "=", "new", "PooledSocketFactory", "(", "new", "PlainSocketFactory", "(", "InetAddress", ".", "getByName", "(", "host", ")", ",", "port", ",", "15000", ")", ")", ";", "return", "new", "HttpClient", "(", "factory", ")", ";", "}" ]
returns a socket connected to a host running the TemplateServerServlet
[ "returns", "a", "socket", "connected", "to", "a", "host", "running", "the", "TemplateServerServlet" ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/TeaServletAdmin.java#L491-L518
45
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/net/LocalNetResolver.java
LocalNetResolver.getAllLocalInetAddresses
private static InetAddress[] getAllLocalInetAddresses(final Log log) throws SocketException { final List addresses = new ArrayList(); // get the network adapters final Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces(); while (netInterfaces.hasMoreElements()) { final NetworkInterface ni = (NetworkInterface)netInterfaces.nextElement(); if (log != null) { log.debug("Found interface: " + ni.getName()); } // get the IPs for this network interface final Enumeration ips = ni.getInetAddresses(); while (ips.hasMoreElements()) { final InetAddress ip = (InetAddress)ips.nextElement(); if (log != null) { log.debug("Found ip: " + ip.getHostName() + "/" + ip.getHostAddress() + " on interface: " + ni.getName()); } // ignore the local loopback address: 127.0.0.1 if (!ip.isLoopbackAddress()) { if (log != null) { log.debug("Let's add this IP: " + ip.getCanonicalHostName()); } addresses.add(ip); } } } return (InetAddress[])addresses.toArray(new InetAddress[addresses.size()]); }
java
private static InetAddress[] getAllLocalInetAddresses(final Log log) throws SocketException { final List addresses = new ArrayList(); // get the network adapters final Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces(); while (netInterfaces.hasMoreElements()) { final NetworkInterface ni = (NetworkInterface)netInterfaces.nextElement(); if (log != null) { log.debug("Found interface: " + ni.getName()); } // get the IPs for this network interface final Enumeration ips = ni.getInetAddresses(); while (ips.hasMoreElements()) { final InetAddress ip = (InetAddress)ips.nextElement(); if (log != null) { log.debug("Found ip: " + ip.getHostName() + "/" + ip.getHostAddress() + " on interface: " + ni.getName()); } // ignore the local loopback address: 127.0.0.1 if (!ip.isLoopbackAddress()) { if (log != null) { log.debug("Let's add this IP: " + ip.getCanonicalHostName()); } addresses.add(ip); } } } return (InetAddress[])addresses.toArray(new InetAddress[addresses.size()]); }
[ "private", "static", "InetAddress", "[", "]", "getAllLocalInetAddresses", "(", "final", "Log", "log", ")", "throws", "SocketException", "{", "final", "List", "addresses", "=", "new", "ArrayList", "(", ")", ";", "// get the network adapters", "final", "Enumeration", "netInterfaces", "=", "NetworkInterface", ".", "getNetworkInterfaces", "(", ")", ";", "while", "(", "netInterfaces", ".", "hasMoreElements", "(", ")", ")", "{", "final", "NetworkInterface", "ni", "=", "(", "NetworkInterface", ")", "netInterfaces", ".", "nextElement", "(", ")", ";", "if", "(", "log", "!=", "null", ")", "{", "log", ".", "debug", "(", "\"Found interface: \"", "+", "ni", ".", "getName", "(", ")", ")", ";", "}", "// get the IPs for this network interface", "final", "Enumeration", "ips", "=", "ni", ".", "getInetAddresses", "(", ")", ";", "while", "(", "ips", ".", "hasMoreElements", "(", ")", ")", "{", "final", "InetAddress", "ip", "=", "(", "InetAddress", ")", "ips", ".", "nextElement", "(", ")", ";", "if", "(", "log", "!=", "null", ")", "{", "log", ".", "debug", "(", "\"Found ip: \"", "+", "ip", ".", "getHostName", "(", ")", "+", "\"/\"", "+", "ip", ".", "getHostAddress", "(", ")", "+", "\" on interface: \"", "+", "ni", ".", "getName", "(", ")", ")", ";", "}", "// ignore the local loopback address: 127.0.0.1", "if", "(", "!", "ip", ".", "isLoopbackAddress", "(", ")", ")", "{", "if", "(", "log", "!=", "null", ")", "{", "log", ".", "debug", "(", "\"Let's add this IP: \"", "+", "ip", ".", "getCanonicalHostName", "(", ")", ")", ";", "}", "addresses", ".", "add", "(", "ip", ")", ";", "}", "}", "}", "return", "(", "InetAddress", "[", "]", ")", "addresses", ".", "toArray", "(", "new", "InetAddress", "[", "addresses", ".", "size", "(", ")", "]", ")", ";", "}" ]
calling getHostName returns the IP. how do we get the host?
[ "calling", "getHostName", "returns", "the", "IP", ".", "how", "do", "we", "get", "the", "host?" ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/net/LocalNetResolver.java#L157-L190
46
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/TeaServletEngineImpl.java
TeaServletEngineImpl.getLogEvents
public LogEvent[] getLogEvents() { if (mLogEvents == null) { return new LogEvent[0]; } else { LogEvent[] events = new LogEvent[mLogEvents.size()]; return (LogEvent[])mLogEvents.toArray(events); } }
java
public LogEvent[] getLogEvents() { if (mLogEvents == null) { return new LogEvent[0]; } else { LogEvent[] events = new LogEvent[mLogEvents.size()]; return (LogEvent[])mLogEvents.toArray(events); } }
[ "public", "LogEvent", "[", "]", "getLogEvents", "(", ")", "{", "if", "(", "mLogEvents", "==", "null", ")", "{", "return", "new", "LogEvent", "[", "0", "]", ";", "}", "else", "{", "LogEvent", "[", "]", "events", "=", "new", "LogEvent", "[", "mLogEvents", ".", "size", "(", ")", "]", ";", "return", "(", "LogEvent", "[", "]", ")", "mLogEvents", ".", "toArray", "(", "events", ")", ";", "}", "}" ]
Returns the lines that have been written to the log file. This is used by the admin functions.
[ "Returns", "the", "lines", "that", "have", "been", "written", "to", "the", "log", "file", ".", "This", "is", "used", "by", "the", "admin", "functions", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/TeaServletEngineImpl.java#L427-L435
47
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/TeaServletEngineImpl.java
TeaServletEngineImpl.findTemplate
public Template findTemplate(String uri, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { return findTemplate(uri, request, response, getTemplateSource()); }
java
public Template findTemplate(String uri, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { return findTemplate(uri, request, response, getTemplateSource()); }
[ "public", "Template", "findTemplate", "(", "String", "uri", ",", "HttpServletRequest", "request", ",", "HttpServletResponse", "response", ")", "throws", "ServletException", ",", "IOException", "{", "return", "findTemplate", "(", "uri", ",", "request", ",", "response", ",", "getTemplateSource", "(", ")", ")", ";", "}" ]
Finds a template based on the given URI. If path ends in a slash, revert to loading default template. If default not found or not specified, return null. @param uri the URI of the template to find @return the template that maps to the URI or null if no template maps to the URI
[ "Finds", "a", "template", "based", "on", "the", "given", "URI", ".", "If", "path", "ends", "in", "a", "slash", "revert", "to", "loading", "default", "template", ".", "If", "default", "not", "found", "or", "not", "specified", "return", "null", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/TeaServletEngineImpl.java#L463-L469
48
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/TeaServletEngineImpl.java
TeaServletEngineImpl.createHttpContext
public HttpContext createHttpContext(ApplicationRequest req, ApplicationResponse resp) throws Exception { Template template = (Template) req.getTemplate(); return createHttpContext(req, resp, template.getTemplateSource().getContextSource()); }
java
public HttpContext createHttpContext(ApplicationRequest req, ApplicationResponse resp) throws Exception { Template template = (Template) req.getTemplate(); return createHttpContext(req, resp, template.getTemplateSource().getContextSource()); }
[ "public", "HttpContext", "createHttpContext", "(", "ApplicationRequest", "req", ",", "ApplicationResponse", "resp", ")", "throws", "Exception", "{", "Template", "template", "=", "(", "Template", ")", "req", ".", "getTemplate", "(", ")", ";", "return", "createHttpContext", "(", "req", ",", "resp", ",", "template", ".", "getTemplateSource", "(", ")", ".", "getContextSource", "(", ")", ")", ";", "}" ]
Lets external classes use the HttpContext for their own, possibly malicious purposes.
[ "Lets", "external", "classes", "use", "the", "HttpContext", "for", "their", "own", "possibly", "malicious", "purposes", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/TeaServletEngineImpl.java#L572-L580
49
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/TeaServletEngineImpl.java
TeaServletEngineImpl.createTemplateSource
private TeaServletTemplateSource createTemplateSource( ContextSource contextSource) { return TeaServletTemplateSource.createTemplateSource( getServletContext(), (TeaServletContextSource) contextSource, getProperties().subMap("template"), getLog()); }
java
private TeaServletTemplateSource createTemplateSource( ContextSource contextSource) { return TeaServletTemplateSource.createTemplateSource( getServletContext(), (TeaServletContextSource) contextSource, getProperties().subMap("template"), getLog()); }
[ "private", "TeaServletTemplateSource", "createTemplateSource", "(", "ContextSource", "contextSource", ")", "{", "return", "TeaServletTemplateSource", ".", "createTemplateSource", "(", "getServletContext", "(", ")", ",", "(", "TeaServletContextSource", ")", "contextSource", ",", "getProperties", "(", ")", ".", "subMap", "(", "\"template\"", ")", ",", "getLog", "(", ")", ")", ";", "}" ]
Create a template source using the composite context passed to the method. @param contextSource The composite context source for all the applications in the ApplicationDepot. @return A newly created template source.
[ "Create", "a", "template", "source", "using", "the", "composite", "context", "passed", "to", "the", "method", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/TeaServletEngineImpl.java#L600-L607
50
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/util/FlyweightSet.java
FlyweightSet.put
public synchronized Object put(Object obj) { // This implementation is based on the IdentityMap.put method. if (obj == null) { return null; } Entry tab[] = mTable; int hash = hashCode(obj); int index = (hash & 0x7FFFFFFF) % tab.length; for (Entry e = tab[index], prev = null; e != null; e = e.mNext) { Object iobj = e.get(); if (iobj == null) { // Clean up after a cleared Reference. if (prev != null) { prev.mNext = e.mNext; } else { tab[index] = e.mNext; } mCount--; } else if (e.mHash == hash && obj.getClass() == iobj.getClass() && equals(obj, iobj)) { // Found flyweight instance. return iobj; } else { prev = e; } } if (mCount >= mThreshold) { // Cleanup the table if the threshold is exceeded. cleanup(); } if (mCount >= mThreshold) { // Rehash the table if the threshold is still exceeded. rehash(); tab = mTable; index = (hash & 0x7FFFFFFF) % tab.length; } // Create a new entry. tab[index] = new Entry(obj, hash, tab[index]); mCount++; return obj; }
java
public synchronized Object put(Object obj) { // This implementation is based on the IdentityMap.put method. if (obj == null) { return null; } Entry tab[] = mTable; int hash = hashCode(obj); int index = (hash & 0x7FFFFFFF) % tab.length; for (Entry e = tab[index], prev = null; e != null; e = e.mNext) { Object iobj = e.get(); if (iobj == null) { // Clean up after a cleared Reference. if (prev != null) { prev.mNext = e.mNext; } else { tab[index] = e.mNext; } mCount--; } else if (e.mHash == hash && obj.getClass() == iobj.getClass() && equals(obj, iobj)) { // Found flyweight instance. return iobj; } else { prev = e; } } if (mCount >= mThreshold) { // Cleanup the table if the threshold is exceeded. cleanup(); } if (mCount >= mThreshold) { // Rehash the table if the threshold is still exceeded. rehash(); tab = mTable; index = (hash & 0x7FFFFFFF) % tab.length; } // Create a new entry. tab[index] = new Entry(obj, hash, tab[index]); mCount++; return obj; }
[ "public", "synchronized", "Object", "put", "(", "Object", "obj", ")", "{", "// This implementation is based on the IdentityMap.put method.", "if", "(", "obj", "==", "null", ")", "{", "return", "null", ";", "}", "Entry", "tab", "[", "]", "=", "mTable", ";", "int", "hash", "=", "hashCode", "(", "obj", ")", ";", "int", "index", "=", "(", "hash", "&", "0x7FFFFFFF", ")", "%", "tab", ".", "length", ";", "for", "(", "Entry", "e", "=", "tab", "[", "index", "]", ",", "prev", "=", "null", ";", "e", "!=", "null", ";", "e", "=", "e", ".", "mNext", ")", "{", "Object", "iobj", "=", "e", ".", "get", "(", ")", ";", "if", "(", "iobj", "==", "null", ")", "{", "// Clean up after a cleared Reference.", "if", "(", "prev", "!=", "null", ")", "{", "prev", ".", "mNext", "=", "e", ".", "mNext", ";", "}", "else", "{", "tab", "[", "index", "]", "=", "e", ".", "mNext", ";", "}", "mCount", "--", ";", "}", "else", "if", "(", "e", ".", "mHash", "==", "hash", "&&", "obj", ".", "getClass", "(", ")", "==", "iobj", ".", "getClass", "(", ")", "&&", "equals", "(", "obj", ",", "iobj", ")", ")", "{", "// Found flyweight instance.", "return", "iobj", ";", "}", "else", "{", "prev", "=", "e", ";", "}", "}", "if", "(", "mCount", ">=", "mThreshold", ")", "{", "// Cleanup the table if the threshold is exceeded.", "cleanup", "(", ")", ";", "}", "if", "(", "mCount", ">=", "mThreshold", ")", "{", "// Rehash the table if the threshold is still exceeded.", "rehash", "(", ")", ";", "tab", "=", "mTable", ";", "index", "=", "(", "hash", "&", "0x7FFFFFFF", ")", "%", "tab", ".", "length", ";", "}", "// Create a new entry.", "tab", "[", "index", "]", "=", "new", "Entry", "(", "obj", ",", "hash", ",", "tab", "[", "index", "]", ")", ";", "mCount", "++", ";", "return", "obj", ";", "}" ]
Pass in a candidate flyweight object and get a unique instance from this set. The returned object will always be of the same type as that passed in. If the object passed in does not equal any object currently in the set, it will be added to the set, becoming a flyweight. @param obj candidate flyweight; null is also accepted
[ "Pass", "in", "a", "candidate", "flyweight", "object", "and", "get", "a", "unique", "instance", "from", "this", "set", ".", "The", "returned", "object", "will", "always", "be", "of", "the", "same", "type", "as", "that", "passed", "in", ".", "If", "the", "object", "passed", "in", "does", "not", "equal", "any", "object", "currently", "in", "the", "set", "it", "will", "be", "added", "to", "the", "set", "becoming", "a", "flyweight", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/FlyweightSet.java#L61-L111
51
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/log/TeaLog.java
TeaLog.printTeaStackTraceLines
private String printTeaStackTraceLines(TeaStackTraceLine[] lines) { String result = ""; for (int line = 0; line < lines.length; line++) { if (line > 0) { result += '\n'; } result += lines[line].toString(); } return result; }
java
private String printTeaStackTraceLines(TeaStackTraceLine[] lines) { String result = ""; for (int line = 0; line < lines.length; line++) { if (line > 0) { result += '\n'; } result += lines[line].toString(); } return result; }
[ "private", "String", "printTeaStackTraceLines", "(", "TeaStackTraceLine", "[", "]", "lines", ")", "{", "String", "result", "=", "\"\"", ";", "for", "(", "int", "line", "=", "0", ";", "line", "<", "lines", ".", "length", ";", "line", "++", ")", "{", "if", "(", "line", ">", "0", ")", "{", "result", "+=", "'", "'", ";", "}", "result", "+=", "lines", "[", "line", "]", ".", "toString", "(", ")", ";", "}", "return", "result", ";", "}" ]
Prints the stack trace lines to a String. @param lines @return the output of the stack trace lines as a string
[ "Prints", "the", "stack", "trace", "lines", "to", "a", "String", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/log/TeaLog.java#L160-L171
52
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/log/TeaLog.java
TeaLog.getTeaStackTraceLines
private TeaStackTraceLine[] getTeaStackTraceLines(Throwable t) { // grab the existing stack trace StringWriter stackTraceGrabber = new StringWriter(); t.printStackTrace(new PrintWriter(stackTraceGrabber)); String stackTrace = stackTraceGrabber.toString(); int extensionIndex = stackTrace.lastIndexOf(TEA_EXCEPTION); boolean isTeaException = extensionIndex != -1; if (isTeaException) { // trim off all lines after the last template exception int endIndex = stackTrace.indexOf('\n', extensionIndex); int endRIndex = stackTrace.indexOf('\r', extensionIndex); if(endRIndex>-1 && endRIndex<endIndex) endIndex=endRIndex; if (endIndex <= 0) { endIndex = stackTrace.length(); } stackTrace = stackTrace.substring(0, endIndex); // parse each line List<TeaStackTraceLine> teaStackTraceLines = new ArrayList<TeaStackTraceLine>(); StringTokenizer tokenizer = new StringTokenizer(stackTrace, "\n"); while (tokenizer.hasMoreElements()) { String line = (String)tokenizer.nextElement(); if (line.indexOf(TEA_EXCEPTION) != -1) { /* TODO: make sure this works for lines that don't have line numbers. Look in ESPN logs for examples. at org.teatrove.teaservlet.template.schedule.substitute(schedule.tea:78) at org.teatrove.teaservlet.template.shell.story.frame.substitute(shell/story/frame.tea) */ String tempLine = line; int bracket = tempLine.indexOf('('); tempLine = tempLine.substring(bracket + 1); bracket = tempLine.indexOf(')'); tempLine = tempLine.substring(0, bracket); int colonIndex = tempLine.indexOf(':'); String templateName = null; Integer lineNumber = null; if (colonIndex >= 0) { templateName = tempLine.substring(0, colonIndex); try { lineNumber = new Integer(tempLine.substring(colonIndex + 1)); } catch (NumberFormatException nfe) { lineNumber = null; } } else { templateName = tempLine; lineNumber = null; } teaStackTraceLines.add(new TeaStackTraceLine(templateName, lineNumber, line)); } else { teaStackTraceLines.add(new TeaStackTraceLine(null, null, line)); } } return (TeaStackTraceLine[]) teaStackTraceLines.toArray( new TeaStackTraceLine[teaStackTraceLines.size()]); } else { return null; } }
java
private TeaStackTraceLine[] getTeaStackTraceLines(Throwable t) { // grab the existing stack trace StringWriter stackTraceGrabber = new StringWriter(); t.printStackTrace(new PrintWriter(stackTraceGrabber)); String stackTrace = stackTraceGrabber.toString(); int extensionIndex = stackTrace.lastIndexOf(TEA_EXCEPTION); boolean isTeaException = extensionIndex != -1; if (isTeaException) { // trim off all lines after the last template exception int endIndex = stackTrace.indexOf('\n', extensionIndex); int endRIndex = stackTrace.indexOf('\r', extensionIndex); if(endRIndex>-1 && endRIndex<endIndex) endIndex=endRIndex; if (endIndex <= 0) { endIndex = stackTrace.length(); } stackTrace = stackTrace.substring(0, endIndex); // parse each line List<TeaStackTraceLine> teaStackTraceLines = new ArrayList<TeaStackTraceLine>(); StringTokenizer tokenizer = new StringTokenizer(stackTrace, "\n"); while (tokenizer.hasMoreElements()) { String line = (String)tokenizer.nextElement(); if (line.indexOf(TEA_EXCEPTION) != -1) { /* TODO: make sure this works for lines that don't have line numbers. Look in ESPN logs for examples. at org.teatrove.teaservlet.template.schedule.substitute(schedule.tea:78) at org.teatrove.teaservlet.template.shell.story.frame.substitute(shell/story/frame.tea) */ String tempLine = line; int bracket = tempLine.indexOf('('); tempLine = tempLine.substring(bracket + 1); bracket = tempLine.indexOf(')'); tempLine = tempLine.substring(0, bracket); int colonIndex = tempLine.indexOf(':'); String templateName = null; Integer lineNumber = null; if (colonIndex >= 0) { templateName = tempLine.substring(0, colonIndex); try { lineNumber = new Integer(tempLine.substring(colonIndex + 1)); } catch (NumberFormatException nfe) { lineNumber = null; } } else { templateName = tempLine; lineNumber = null; } teaStackTraceLines.add(new TeaStackTraceLine(templateName, lineNumber, line)); } else { teaStackTraceLines.add(new TeaStackTraceLine(null, null, line)); } } return (TeaStackTraceLine[]) teaStackTraceLines.toArray( new TeaStackTraceLine[teaStackTraceLines.size()]); } else { return null; } }
[ "private", "TeaStackTraceLine", "[", "]", "getTeaStackTraceLines", "(", "Throwable", "t", ")", "{", "// grab the existing stack trace", "StringWriter", "stackTraceGrabber", "=", "new", "StringWriter", "(", ")", ";", "t", ".", "printStackTrace", "(", "new", "PrintWriter", "(", "stackTraceGrabber", ")", ")", ";", "String", "stackTrace", "=", "stackTraceGrabber", ".", "toString", "(", ")", ";", "int", "extensionIndex", "=", "stackTrace", ".", "lastIndexOf", "(", "TEA_EXCEPTION", ")", ";", "boolean", "isTeaException", "=", "extensionIndex", "!=", "-", "1", ";", "if", "(", "isTeaException", ")", "{", "// trim off all lines after the last template exception", "int", "endIndex", "=", "stackTrace", ".", "indexOf", "(", "'", "'", ",", "extensionIndex", ")", ";", "int", "endRIndex", "=", "stackTrace", ".", "indexOf", "(", "'", "'", ",", "extensionIndex", ")", ";", "if", "(", "endRIndex", ">", "-", "1", "&&", "endRIndex", "<", "endIndex", ")", "endIndex", "=", "endRIndex", ";", "if", "(", "endIndex", "<=", "0", ")", "{", "endIndex", "=", "stackTrace", ".", "length", "(", ")", ";", "}", "stackTrace", "=", "stackTrace", ".", "substring", "(", "0", ",", "endIndex", ")", ";", "// parse each line", "List", "<", "TeaStackTraceLine", ">", "teaStackTraceLines", "=", "new", "ArrayList", "<", "TeaStackTraceLine", ">", "(", ")", ";", "StringTokenizer", "tokenizer", "=", "new", "StringTokenizer", "(", "stackTrace", ",", "\"\\n\"", ")", ";", "while", "(", "tokenizer", ".", "hasMoreElements", "(", ")", ")", "{", "String", "line", "=", "(", "String", ")", "tokenizer", ".", "nextElement", "(", ")", ";", "if", "(", "line", ".", "indexOf", "(", "TEA_EXCEPTION", ")", "!=", "-", "1", ")", "{", "/*\n TODO: make sure this works for lines that don't have\n line numbers. Look in ESPN logs for examples.\n at org.teatrove.teaservlet.template.schedule.substitute(schedule.tea:78)\n at org.teatrove.teaservlet.template.shell.story.frame.substitute(shell/story/frame.tea)\n */", "String", "tempLine", "=", "line", ";", "int", "bracket", "=", "tempLine", ".", "indexOf", "(", "'", "'", ")", ";", "tempLine", "=", "tempLine", ".", "substring", "(", "bracket", "+", "1", ")", ";", "bracket", "=", "tempLine", ".", "indexOf", "(", "'", "'", ")", ";", "tempLine", "=", "tempLine", ".", "substring", "(", "0", ",", "bracket", ")", ";", "int", "colonIndex", "=", "tempLine", ".", "indexOf", "(", "'", "'", ")", ";", "String", "templateName", "=", "null", ";", "Integer", "lineNumber", "=", "null", ";", "if", "(", "colonIndex", ">=", "0", ")", "{", "templateName", "=", "tempLine", ".", "substring", "(", "0", ",", "colonIndex", ")", ";", "try", "{", "lineNumber", "=", "new", "Integer", "(", "tempLine", ".", "substring", "(", "colonIndex", "+", "1", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "nfe", ")", "{", "lineNumber", "=", "null", ";", "}", "}", "else", "{", "templateName", "=", "tempLine", ";", "lineNumber", "=", "null", ";", "}", "teaStackTraceLines", ".", "add", "(", "new", "TeaStackTraceLine", "(", "templateName", ",", "lineNumber", ",", "line", ")", ")", ";", "}", "else", "{", "teaStackTraceLines", ".", "add", "(", "new", "TeaStackTraceLine", "(", "null", ",", "null", ",", "line", ")", ")", ";", "}", "}", "return", "(", "TeaStackTraceLine", "[", "]", ")", "teaStackTraceLines", ".", "toArray", "(", "new", "TeaStackTraceLine", "[", "teaStackTraceLines", ".", "size", "(", ")", "]", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Splits the stack trace into separate lines and extracts the template name and line number. @param t @return the separated stack trace lines
[ "Splits", "the", "stack", "trace", "into", "separate", "lines", "and", "extracts", "the", "template", "name", "and", "line", "number", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/log/TeaLog.java#L180-L251
53
teatrove/teatrove
build-tools/teatools/src/main/java/org/teatrove/teatools/ParameterDescription.java
ParameterDescription.getName
public String getName() { String name = super.getName(); if (name != null) { if (name.equals(getParameterDescriptor().getDisplayName()) || name.length() == 0) { name = null; } } return name; }
java
public String getName() { String name = super.getName(); if (name != null) { if (name.equals(getParameterDescriptor().getDisplayName()) || name.length() == 0) { name = null; } } return name; }
[ "public", "String", "getName", "(", ")", "{", "String", "name", "=", "super", ".", "getName", "(", ")", ";", "if", "(", "name", "!=", "null", ")", "{", "if", "(", "name", ".", "equals", "(", "getParameterDescriptor", "(", ")", ".", "getDisplayName", "(", ")", ")", "||", "name", ".", "length", "(", ")", "==", "0", ")", "{", "name", "=", "null", ";", "}", "}", "return", "name", ";", "}" ]
Returns the formal param name, or null if the formal name is not available.
[ "Returns", "the", "formal", "param", "name", "or", "null", "if", "the", "formal", "name", "is", "not", "available", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/teatools/src/main/java/org/teatrove/teatools/ParameterDescription.java#L61-L71
54
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/classfile/ConstantNameAndTypeInfo.java
ConstantNameAndTypeInfo.make
static ConstantNameAndTypeInfo make(ConstantPool cp, String name, Descriptor type) { ConstantInfo ci = new ConstantNameAndTypeInfo(cp, name, type); return (ConstantNameAndTypeInfo)cp.addConstant(ci); }
java
static ConstantNameAndTypeInfo make(ConstantPool cp, String name, Descriptor type) { ConstantInfo ci = new ConstantNameAndTypeInfo(cp, name, type); return (ConstantNameAndTypeInfo)cp.addConstant(ci); }
[ "static", "ConstantNameAndTypeInfo", "make", "(", "ConstantPool", "cp", ",", "String", "name", ",", "Descriptor", "type", ")", "{", "ConstantInfo", "ci", "=", "new", "ConstantNameAndTypeInfo", "(", "cp", ",", "name", ",", "type", ")", ";", "return", "(", "ConstantNameAndTypeInfo", ")", "cp", ".", "addConstant", "(", "ci", ")", ";", "}" ]
Will return either a new ConstantNameAndTypeInfo object or one already in the constant pool. If it is a new ConstantNameAndTypeInfo, it will be inserted into the pool.
[ "Will", "return", "either", "a", "new", "ConstantNameAndTypeInfo", "object", "or", "one", "already", "in", "the", "constant", "pool", ".", "If", "it", "is", "a", "new", "ConstantNameAndTypeInfo", "it", "will", "be", "inserted", "into", "the", "pool", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/ConstantNameAndTypeInfo.java#L40-L45
55
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teatools/MethodDescription.java
MethodDescription.getReturnType
public TypeDescription getReturnType() { if (mReturnType == null) { mReturnType = getTeaToolsUtils().createTypeDescription( getMethod().getReturnType()); } return mReturnType; }
java
public TypeDescription getReturnType() { if (mReturnType == null) { mReturnType = getTeaToolsUtils().createTypeDescription( getMethod().getReturnType()); } return mReturnType; }
[ "public", "TypeDescription", "getReturnType", "(", ")", "{", "if", "(", "mReturnType", "==", "null", ")", "{", "mReturnType", "=", "getTeaToolsUtils", "(", ")", ".", "createTypeDescription", "(", "getMethod", "(", ")", ".", "getReturnType", "(", ")", ")", ";", "}", "return", "mReturnType", ";", "}" ]
Returns the method's return type
[ "Returns", "the", "method", "s", "return", "type" ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teatools/MethodDescription.java#L81-L89
56
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/ListContext.java
ListContext.add
public <T> void add(List<T> list, int index, T value) { list.add(index, value); }
java
public <T> void add(List<T> list, int index, T value) { list.add(index, value); }
[ "public", "<", "T", ">", "void", "add", "(", "List", "<", "T", ">", "list", ",", "int", "index", ",", "T", "value", ")", "{", "list", ".", "add", "(", "index", ",", "value", ")", ";", "}" ]
Insert the given value to the given list at the given index. This will insert the value at the index shifting the elements accordingly. @param <T> The component type of the list @param list The list to add to @param index The index to add at @param value The value to add @see List#add(int, Object)
[ "Insert", "the", "given", "value", "to", "the", "given", "list", "at", "the", "given", "index", ".", "This", "will", "insert", "the", "value", "at", "the", "index", "shifting", "the", "elements", "accordingly", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/ListContext.java#L61-L63
57
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/ListContext.java
ListContext.addAll
public <T> boolean addAll(List<T> listToAddTo, Collection<? extends T> collectionToAdd) { return listToAddTo.addAll(collectionToAdd); }
java
public <T> boolean addAll(List<T> listToAddTo, Collection<? extends T> collectionToAdd) { return listToAddTo.addAll(collectionToAdd); }
[ "public", "<", "T", ">", "boolean", "addAll", "(", "List", "<", "T", ">", "listToAddTo", ",", "Collection", "<", "?", "extends", "T", ">", "collectionToAdd", ")", "{", "return", "listToAddTo", ".", "addAll", "(", "collectionToAdd", ")", ";", "}" ]
Add all items of the given collection to the given list. @param <T> The component type of the list @param listToAddTo The list to add to @param collectionToAdd The elements to add to the list @return <code>true</code> if all items were added, <code>false</code> otherwise @see List#addAll(Collection)
[ "Add", "all", "items", "of", "the", "given", "collection", "to", "the", "given", "list", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/ListContext.java#L78-L81
58
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/ListContext.java
ListContext.set
public <T> T set(List<T> list, int index, T obj) { return list.set(index, obj); }
java
public <T> T set(List<T> list, int index, T obj) { return list.set(index, obj); }
[ "public", "<", "T", ">", "T", "set", "(", "List", "<", "T", ">", "list", ",", "int", "index", ",", "T", "obj", ")", "{", "return", "list", ".", "set", "(", "index", ",", "obj", ")", ";", "}" ]
Set the value at the given index in the given list. If the value is properly set, the previous value will be returned. @param list The list of set in @param index The index within the list to set at @param obj The object to set in the list @return The previously set value @see List#set(int, Object)
[ "Set", "the", "value", "at", "the", "given", "index", "in", "the", "given", "list", ".", "If", "the", "value", "is", "properly", "set", "the", "previous", "value", "will", "be", "returned", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/ListContext.java#L242-L244
59
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/ListContext.java
ListContext.subList
public <T> List<T> subList(List<T> list, int fromIndex, int toIndex) { return list.subList(fromIndex, toIndex); }
java
public <T> List<T> subList(List<T> list, int fromIndex, int toIndex) { return list.subList(fromIndex, toIndex); }
[ "public", "<", "T", ">", "List", "<", "T", ">", "subList", "(", "List", "<", "T", ">", "list", ",", "int", "fromIndex", ",", "int", "toIndex", ")", "{", "return", "list", ".", "subList", "(", "fromIndex", ",", "toIndex", ")", ";", "}" ]
Get a portion of the given list as a new list. @param list The list to retrieve a portion of @param fromIndex The first index, inclusive, to start from @param toIndex The last index, inclusive, to end at @return A new list containing the given portion of the list @see List#subList(int, int)
[ "Get", "a", "portion", "of", "the", "given", "list", "as", "a", "new", "list", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/ListContext.java#L270-L272
60
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/ListContext.java
ListContext.toArray
public Object[] toArray(List<?> list, Class<?> arrayType) { int[] dims = findArrayDimensions(list, arrayType); Object[] typedArray = (Object[]) Array.newInstance(arrayType, dims); return list.toArray(typedArray); }
java
public Object[] toArray(List<?> list, Class<?> arrayType) { int[] dims = findArrayDimensions(list, arrayType); Object[] typedArray = (Object[]) Array.newInstance(arrayType, dims); return list.toArray(typedArray); }
[ "public", "Object", "[", "]", "toArray", "(", "List", "<", "?", ">", "list", ",", "Class", "<", "?", ">", "arrayType", ")", "{", "int", "[", "]", "dims", "=", "findArrayDimensions", "(", "list", ",", "arrayType", ")", ";", "Object", "[", "]", "typedArray", "=", "(", "Object", "[", "]", ")", "Array", ".", "newInstance", "(", "arrayType", ",", "dims", ")", ";", "return", "list", ".", "toArray", "(", "typedArray", ")", ";", "}" ]
Convert the given list to an array of the given array type. @param list The list to convert @param arrayType The type of array to create @return The array of elements in the list
[ "Convert", "the", "given", "list", "to", "an", "array", "of", "the", "given", "array", "type", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/ListContext.java#L282-L286
61
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/util/plugin/PluginContext.java
PluginContext.addPlugin
public void addPlugin(Plugin plugin) { if (!mPluginMap.containsKey(plugin.getName())) { mPluginMap.put(plugin.getName(), plugin); PluginEvent event = new PluginEvent(this, plugin); firePluginAddedEvent(event); } }
java
public void addPlugin(Plugin plugin) { if (!mPluginMap.containsKey(plugin.getName())) { mPluginMap.put(plugin.getName(), plugin); PluginEvent event = new PluginEvent(this, plugin); firePluginAddedEvent(event); } }
[ "public", "void", "addPlugin", "(", "Plugin", "plugin", ")", "{", "if", "(", "!", "mPluginMap", ".", "containsKey", "(", "plugin", ".", "getName", "(", ")", ")", ")", "{", "mPluginMap", ".", "put", "(", "plugin", ".", "getName", "(", ")", ",", "plugin", ")", ";", "PluginEvent", "event", "=", "new", "PluginEvent", "(", "this", ",", "plugin", ")", ";", "firePluginAddedEvent", "(", "event", ")", ";", "}", "}" ]
Adds a Plugin to the PluginContext. Plugins that want to make themselves available to other Plugins should add themselves to the PluginContext through this method. All PluginListeners will be notified of the new addition. @param plugin the Plugin to be added.
[ "Adds", "a", "Plugin", "to", "the", "PluginContext", ".", "Plugins", "that", "want", "to", "make", "themselves", "available", "to", "other", "Plugins", "should", "add", "themselves", "to", "the", "PluginContext", "through", "this", "method", ".", "All", "PluginListeners", "will", "be", "notified", "of", "the", "new", "addition", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/plugin/PluginContext.java#L86-L92
62
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Token.java
Token.findReservedWordID
public static int findReservedWordID(StringBuilder word) { char c = word.charAt(0); switch (c) { case 'a': if (matches(word, "and")) return AND; if (matches(word, "as")) return AS; break; case 'b': if(matches(word, "break")) return BREAK; break; case 'c': if (matches(word, "call")) return CALL; if (matches(word, "class___")) return CLASS; if (matches(word, "continue")) return CONTINUE; break; case 'd': if (matches(word, "define")) return DEFINE; break; case 'e': if (matches(word, "else")) return ELSE; break; case 'f': if (matches(word, "foreach")) return FOREACH; if (matches(word, "false")) return FALSE; break; case 'i': if (matches(word, "if")) return IF; if (matches(word, "import")) return IMPORT; if (matches(word, "in")) return IN; if (matches(word, "isa")) return ISA; break; case 'n': if (matches(word, "null")) return NULL; if (matches(word, "not")) return NOT; break; case 'o': if (matches(word, "or")) return OR; break; case 'r': if (matches(word, "reverse")) return REVERSE; break; case 't': if (matches(word, "true")) return TRUE; if (matches(word, "template")) return TEMPLATE; break; } return UNKNOWN; }
java
public static int findReservedWordID(StringBuilder word) { char c = word.charAt(0); switch (c) { case 'a': if (matches(word, "and")) return AND; if (matches(word, "as")) return AS; break; case 'b': if(matches(word, "break")) return BREAK; break; case 'c': if (matches(word, "call")) return CALL; if (matches(word, "class___")) return CLASS; if (matches(word, "continue")) return CONTINUE; break; case 'd': if (matches(word, "define")) return DEFINE; break; case 'e': if (matches(word, "else")) return ELSE; break; case 'f': if (matches(word, "foreach")) return FOREACH; if (matches(word, "false")) return FALSE; break; case 'i': if (matches(word, "if")) return IF; if (matches(word, "import")) return IMPORT; if (matches(word, "in")) return IN; if (matches(word, "isa")) return ISA; break; case 'n': if (matches(word, "null")) return NULL; if (matches(word, "not")) return NOT; break; case 'o': if (matches(word, "or")) return OR; break; case 'r': if (matches(word, "reverse")) return REVERSE; break; case 't': if (matches(word, "true")) return TRUE; if (matches(word, "template")) return TEMPLATE; break; } return UNKNOWN; }
[ "public", "static", "int", "findReservedWordID", "(", "StringBuilder", "word", ")", "{", "char", "c", "=", "word", ".", "charAt", "(", "0", ")", ";", "switch", "(", "c", ")", "{", "case", "'", "'", ":", "if", "(", "matches", "(", "word", ",", "\"and\"", ")", ")", "return", "AND", ";", "if", "(", "matches", "(", "word", ",", "\"as\"", ")", ")", "return", "AS", ";", "break", ";", "case", "'", "'", ":", "if", "(", "matches", "(", "word", ",", "\"break\"", ")", ")", "return", "BREAK", ";", "break", ";", "case", "'", "'", ":", "if", "(", "matches", "(", "word", ",", "\"call\"", ")", ")", "return", "CALL", ";", "if", "(", "matches", "(", "word", ",", "\"class___\"", ")", ")", "return", "CLASS", ";", "if", "(", "matches", "(", "word", ",", "\"continue\"", ")", ")", "return", "CONTINUE", ";", "break", ";", "case", "'", "'", ":", "if", "(", "matches", "(", "word", ",", "\"define\"", ")", ")", "return", "DEFINE", ";", "break", ";", "case", "'", "'", ":", "if", "(", "matches", "(", "word", ",", "\"else\"", ")", ")", "return", "ELSE", ";", "break", ";", "case", "'", "'", ":", "if", "(", "matches", "(", "word", ",", "\"foreach\"", ")", ")", "return", "FOREACH", ";", "if", "(", "matches", "(", "word", ",", "\"false\"", ")", ")", "return", "FALSE", ";", "break", ";", "case", "'", "'", ":", "if", "(", "matches", "(", "word", ",", "\"if\"", ")", ")", "return", "IF", ";", "if", "(", "matches", "(", "word", ",", "\"import\"", ")", ")", "return", "IMPORT", ";", "if", "(", "matches", "(", "word", ",", "\"in\"", ")", ")", "return", "IN", ";", "if", "(", "matches", "(", "word", ",", "\"isa\"", ")", ")", "return", "ISA", ";", "break", ";", "case", "'", "'", ":", "if", "(", "matches", "(", "word", ",", "\"null\"", ")", ")", "return", "NULL", ";", "if", "(", "matches", "(", "word", ",", "\"not\"", ")", ")", "return", "NOT", ";", "break", ";", "case", "'", "'", ":", "if", "(", "matches", "(", "word", ",", "\"or\"", ")", ")", "return", "OR", ";", "break", ";", "case", "'", "'", ":", "if", "(", "matches", "(", "word", ",", "\"reverse\"", ")", ")", "return", "REVERSE", ";", "break", ";", "case", "'", "'", ":", "if", "(", "matches", "(", "word", ",", "\"true\"", ")", ")", "return", "TRUE", ";", "if", "(", "matches", "(", "word", ",", "\"template\"", ")", ")", "return", "TEMPLATE", ";", "break", ";", "}", "return", "UNKNOWN", ";", "}" ]
If the given StringBuilder starts with a valid token type, its ID is returned. Otherwise, the token ID UNKNOWN is returned.
[ "If", "the", "given", "StringBuilder", "starts", "with", "a", "valid", "token", "type", "its", "ID", "is", "returned", ".", "Otherwise", "the", "token", "ID", "UNKNOWN", "is", "returned", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Token.java#L296-L345
63
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Token.java
Token.matches
private static boolean matches(StringBuilder word, String val) { int len = word.length(); if (len != val.length()) return false; // Start at index 1, assuming that the first characters have already // been checked to match. for (int index = 1; index < len; index++) { char cw = word.charAt(index); char cv = val.charAt(index); if (cw != cv) { return false; } } return true; }
java
private static boolean matches(StringBuilder word, String val) { int len = word.length(); if (len != val.length()) return false; // Start at index 1, assuming that the first characters have already // been checked to match. for (int index = 1; index < len; index++) { char cw = word.charAt(index); char cv = val.charAt(index); if (cw != cv) { return false; } } return true; }
[ "private", "static", "boolean", "matches", "(", "StringBuilder", "word", ",", "String", "val", ")", "{", "int", "len", "=", "word", ".", "length", "(", ")", ";", "if", "(", "len", "!=", "val", ".", "length", "(", ")", ")", "return", "false", ";", "// Start at index 1, assuming that the first characters have already", "// been checked to match.", "for", "(", "int", "index", "=", "1", ";", "index", "<", "len", ";", "index", "++", ")", "{", "char", "cw", "=", "word", ".", "charAt", "(", "index", ")", ";", "char", "cv", "=", "val", ".", "charAt", "(", "index", ")", ";", "if", "(", "cw", "!=", "cv", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Case sensitive match test. @param val must be lowercase
[ "Case", "sensitive", "match", "test", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Token.java#L351-L367
64
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Token.java
Token.dump
public final void dump(PrintStream out) { out.println("Token [Code: " + getCode() + "] [Image: " + getImage() + "] [Value: " + getStringValue() + "] [Id: " + getID() + "] [start: " + mInfo.getStartPosition() + "] [end " + mInfo.getEndPosition() + "]"); }
java
public final void dump(PrintStream out) { out.println("Token [Code: " + getCode() + "] [Image: " + getImage() + "] [Value: " + getStringValue() + "] [Id: " + getID() + "] [start: " + mInfo.getStartPosition() + "] [end " + mInfo.getEndPosition() + "]"); }
[ "public", "final", "void", "dump", "(", "PrintStream", "out", ")", "{", "out", ".", "println", "(", "\"Token [Code: \"", "+", "getCode", "(", ")", "+", "\"] [Image: \"", "+", "getImage", "(", ")", "+", "\"] [Value: \"", "+", "getStringValue", "(", ")", "+", "\"] [Id: \"", "+", "getID", "(", ")", "+", "\"] [start: \"", "+", "mInfo", ".", "getStartPosition", "(", ")", "+", "\"] [end \"", "+", "mInfo", ".", "getEndPosition", "(", ")", "+", "\"]\"", ")", ";", "}" ]
Dumps the contents of this Token. @param out The PrintStream to write to.
[ "Dumps", "the", "contents", "of", "this", "Token", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Token.java#L380-L386
65
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/CryptoContext.java
CryptoContext.digest
public byte[] digest(String algorithm, byte[] bytes) { try { MessageDigest md = MessageDigest.getInstance(algorithm); return md.digest(bytes); } catch (NoSuchAlgorithmException exception) { throw new IllegalStateException( "unable to access MD5 algorithm", exception ); } }
java
public byte[] digest(String algorithm, byte[] bytes) { try { MessageDigest md = MessageDigest.getInstance(algorithm); return md.digest(bytes); } catch (NoSuchAlgorithmException exception) { throw new IllegalStateException( "unable to access MD5 algorithm", exception ); } }
[ "public", "byte", "[", "]", "digest", "(", "String", "algorithm", ",", "byte", "[", "]", "bytes", ")", "{", "try", "{", "MessageDigest", "md", "=", "MessageDigest", ".", "getInstance", "(", "algorithm", ")", ";", "return", "md", ".", "digest", "(", "bytes", ")", ";", "}", "catch", "(", "NoSuchAlgorithmException", "exception", ")", "{", "throw", "new", "IllegalStateException", "(", "\"unable to access MD5 algorithm\"", ",", "exception", ")", ";", "}", "}" ]
Generates a digest based on the given algorithm. @param algorithm The algorithm to use (MD5, SHA, etc) @param bytes The bytes to digest @return The associated digest @see MessageDigest
[ "Generates", "a", "digest", "based", "on", "the", "given", "algorithm", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/CryptoContext.java#L49-L59
66
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/CryptoContext.java
CryptoContext.md5HexDigest
public String md5HexDigest(String signature) { byte[] bytes = md5Digest(signature.getBytes()); return new String(Hex.encodeHex(bytes)); }
java
public String md5HexDigest(String signature) { byte[] bytes = md5Digest(signature.getBytes()); return new String(Hex.encodeHex(bytes)); }
[ "public", "String", "md5HexDigest", "(", "String", "signature", ")", "{", "byte", "[", "]", "bytes", "=", "md5Digest", "(", "signature", ".", "getBytes", "(", ")", ")", ";", "return", "new", "String", "(", "Hex", ".", "encodeHex", "(", "bytes", ")", ")", ";", "}" ]
Creates a MD5 digest of the given signature and returns the result as a hex-encoded string. @param signature The signature to digest @return The MD5 digest of the signature in hex format
[ "Creates", "a", "MD5", "digest", "of", "the", "given", "signature", "and", "returns", "the", "result", "as", "a", "hex", "-", "encoded", "string", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/CryptoContext.java#L131-L134
67
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/CryptoContext.java
CryptoContext.md5Base64Digest
public String md5Base64Digest(String signature) { byte[] bytes = md5Digest(signature.getBytes()); return new String(Base64.encodeBase64(bytes)); }
java
public String md5Base64Digest(String signature) { byte[] bytes = md5Digest(signature.getBytes()); return new String(Base64.encodeBase64(bytes)); }
[ "public", "String", "md5Base64Digest", "(", "String", "signature", ")", "{", "byte", "[", "]", "bytes", "=", "md5Digest", "(", "signature", ".", "getBytes", "(", ")", ")", ";", "return", "new", "String", "(", "Base64", ".", "encodeBase64", "(", "bytes", ")", ")", ";", "}" ]
Creates a MD5 digest of the given signature and returns the result as a Base64-encoded string. @param signature The signature to digest @return The MD5 digest of the signature in Base64 format
[ "Creates", "a", "MD5", "digest", "of", "the", "given", "signature", "and", "returns", "the", "result", "as", "a", "Base64", "-", "encoded", "string", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/CryptoContext.java#L164-L167
68
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/classfile/ConstantInterfaceMethodInfo.java
ConstantInterfaceMethodInfo.make
static ConstantInterfaceMethodInfo make (ConstantPool cp, ConstantClassInfo parentClass, ConstantNameAndTypeInfo nameAndType) { ConstantInfo ci = new ConstantInterfaceMethodInfo(parentClass, nameAndType); return (ConstantInterfaceMethodInfo)cp.addConstant(ci); }
java
static ConstantInterfaceMethodInfo make (ConstantPool cp, ConstantClassInfo parentClass, ConstantNameAndTypeInfo nameAndType) { ConstantInfo ci = new ConstantInterfaceMethodInfo(parentClass, nameAndType); return (ConstantInterfaceMethodInfo)cp.addConstant(ci); }
[ "static", "ConstantInterfaceMethodInfo", "make", "(", "ConstantPool", "cp", ",", "ConstantClassInfo", "parentClass", ",", "ConstantNameAndTypeInfo", "nameAndType", ")", "{", "ConstantInfo", "ci", "=", "new", "ConstantInterfaceMethodInfo", "(", "parentClass", ",", "nameAndType", ")", ";", "return", "(", "ConstantInterfaceMethodInfo", ")", "cp", ".", "addConstant", "(", "ci", ")", ";", "}" ]
Will return either a new ConstantInterfaceMethodInfo object or one already in the constant pool. If it is a new ConstantInterfaceMethodInfo, it will be inserted into the pool.
[ "Will", "return", "either", "a", "new", "ConstantInterfaceMethodInfo", "object", "or", "one", "already", "in", "the", "constant", "pool", ".", "If", "it", "is", "a", "new", "ConstantInterfaceMethodInfo", "it", "will", "be", "inserted", "into", "the", "pool", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/ConstantInterfaceMethodInfo.java#L37-L45
69
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/classfile/ConstantStringInfo.java
ConstantStringInfo.make
static ConstantStringInfo make(ConstantPool cp, String str) { ConstantInfo ci = new ConstantStringInfo(cp, str); return (ConstantStringInfo)cp.addConstant(ci); }
java
static ConstantStringInfo make(ConstantPool cp, String str) { ConstantInfo ci = new ConstantStringInfo(cp, str); return (ConstantStringInfo)cp.addConstant(ci); }
[ "static", "ConstantStringInfo", "make", "(", "ConstantPool", "cp", ",", "String", "str", ")", "{", "ConstantInfo", "ci", "=", "new", "ConstantStringInfo", "(", "cp", ",", "str", ")", ";", "return", "(", "ConstantStringInfo", ")", "cp", ".", "addConstant", "(", "ci", ")", ";", "}" ]
Will return either a new ConstantStringInfo object or one already in the constant pool. If it is a new ConstantStringInfo, it will be inserted into the pool.
[ "Will", "return", "either", "a", "new", "ConstantStringInfo", "object", "or", "one", "already", "in", "the", "constant", "pool", ".", "If", "it", "is", "a", "new", "ConstantStringInfo", "it", "will", "be", "inserted", "into", "the", "pool", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/ConstantStringInfo.java#L37-L40
70
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java
Modifiers.setPublic
public static int setPublic(int modifier, boolean b) { if (b) { return (modifier | PUBLIC) & (~PROTECTED & ~PRIVATE); } else { return modifier & ~PUBLIC; } }
java
public static int setPublic(int modifier, boolean b) { if (b) { return (modifier | PUBLIC) & (~PROTECTED & ~PRIVATE); } else { return modifier & ~PUBLIC; } }
[ "public", "static", "int", "setPublic", "(", "int", "modifier", ",", "boolean", "b", ")", "{", "if", "(", "b", ")", "{", "return", "(", "modifier", "|", "PUBLIC", ")", "&", "(", "~", "PROTECTED", "&", "~", "PRIVATE", ")", ";", "}", "else", "{", "return", "modifier", "&", "~", "PUBLIC", ";", "}", "}" ]
When set public, the modifier is cleared from being private or protected.
[ "When", "set", "public", "the", "modifier", "is", "cleared", "from", "being", "private", "or", "protected", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java#L34-L41
71
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java
Modifiers.setPrivate
public static int setPrivate(int modifier, boolean b) { if (b) { return (modifier | PRIVATE) & (~PUBLIC & ~PROTECTED); } else { return modifier & ~PRIVATE; } }
java
public static int setPrivate(int modifier, boolean b) { if (b) { return (modifier | PRIVATE) & (~PUBLIC & ~PROTECTED); } else { return modifier & ~PRIVATE; } }
[ "public", "static", "int", "setPrivate", "(", "int", "modifier", ",", "boolean", "b", ")", "{", "if", "(", "b", ")", "{", "return", "(", "modifier", "|", "PRIVATE", ")", "&", "(", "~", "PUBLIC", "&", "~", "PROTECTED", ")", ";", "}", "else", "{", "return", "modifier", "&", "~", "PRIVATE", ";", "}", "}" ]
When set private, the modifier is cleared from being public or protected.
[ "When", "set", "private", "the", "modifier", "is", "cleared", "from", "being", "public", "or", "protected", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java#L47-L54

Dataset Card for "codexglue_code2text_java"

More Information needed

Downloads last month
79

Models trained or fine-tuned on CM/codexglue_code2text_java