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 |
72 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java | Modifiers.setProtected | public static int setProtected(int modifier, boolean b) {
if (b) {
return (modifier | PROTECTED) & (~PUBLIC & ~PRIVATE);
}
else {
return modifier & ~PROTECTED;
}
} | java | public static int setProtected(int modifier, boolean b) {
if (b) {
return (modifier | PROTECTED) & (~PUBLIC & ~PRIVATE);
}
else {
return modifier & ~PROTECTED;
}
} | [
"public",
"static",
"int",
"setProtected",
"(",
"int",
"modifier",
",",
"boolean",
"b",
")",
"{",
"if",
"(",
"b",
")",
"{",
"return",
"(",
"modifier",
"|",
"PROTECTED",
")",
"&",
"(",
"~",
"PUBLIC",
"&",
"~",
"PRIVATE",
")",
";",
"}",
"else",
"{",
"return",
"modifier",
"&",
"~",
"PROTECTED",
";",
"}",
"}"
] | When set protected, the modifier is cleared from being public or
private. | [
"When",
"set",
"protected",
"the",
"modifier",
"is",
"cleared",
"from",
"being",
"public",
"or",
"private",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java#L60-L67 |
73 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java | Modifiers.setFinal | public static int setFinal(int modifier, boolean b) {
if (b) {
return (modifier | FINAL) & (~INTERFACE & ~ABSTRACT);
}
else {
return modifier & ~FINAL;
}
} | java | public static int setFinal(int modifier, boolean b) {
if (b) {
return (modifier | FINAL) & (~INTERFACE & ~ABSTRACT);
}
else {
return modifier & ~FINAL;
}
} | [
"public",
"static",
"int",
"setFinal",
"(",
"int",
"modifier",
",",
"boolean",
"b",
")",
"{",
"if",
"(",
"b",
")",
"{",
"return",
"(",
"modifier",
"|",
"FINAL",
")",
"&",
"(",
"~",
"INTERFACE",
"&",
"~",
"ABSTRACT",
")",
";",
"}",
"else",
"{",
"return",
"modifier",
"&",
"~",
"FINAL",
";",
"}",
"}"
] | When set final, the modifier is cleared from being an interface or
abstract. | [
"When",
"set",
"final",
"the",
"modifier",
"is",
"cleared",
"from",
"being",
"an",
"interface",
"or",
"abstract",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java#L82-L89 |
74 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java | Modifiers.setSynchronized | public static int setSynchronized(int modifier, boolean b) {
if (b) {
return (modifier | SYNCHRONIZED) &
(~VOLATILE & ~TRANSIENT & ~INTERFACE);
}
else {
return modifier & ~SYNCHRONIZED;
}
} | java | public static int setSynchronized(int modifier, boolean b) {
if (b) {
return (modifier | SYNCHRONIZED) &
(~VOLATILE & ~TRANSIENT & ~INTERFACE);
}
else {
return modifier & ~SYNCHRONIZED;
}
} | [
"public",
"static",
"int",
"setSynchronized",
"(",
"int",
"modifier",
",",
"boolean",
"b",
")",
"{",
"if",
"(",
"b",
")",
"{",
"return",
"(",
"modifier",
"|",
"SYNCHRONIZED",
")",
"&",
"(",
"~",
"VOLATILE",
"&",
"~",
"TRANSIENT",
"&",
"~",
"INTERFACE",
")",
";",
"}",
"else",
"{",
"return",
"modifier",
"&",
"~",
"SYNCHRONIZED",
";",
"}",
"}"
] | When set synchronized, non-method settings are cleared. | [
"When",
"set",
"synchronized",
"non",
"-",
"method",
"settings",
"are",
"cleared",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java#L94-L102 |
75 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java | Modifiers.setVolatile | public static int setVolatile(int modifier, boolean b) {
if (b) {
return (modifier | VOLATILE) &
(~SYNCHRONIZED & ~NATIVE & ~INTERFACE & ~ABSTRACT & ~STRICT);
}
else {
return modifier & ~VOLATILE;
}
} | java | public static int setVolatile(int modifier, boolean b) {
if (b) {
return (modifier | VOLATILE) &
(~SYNCHRONIZED & ~NATIVE & ~INTERFACE & ~ABSTRACT & ~STRICT);
}
else {
return modifier & ~VOLATILE;
}
} | [
"public",
"static",
"int",
"setVolatile",
"(",
"int",
"modifier",
",",
"boolean",
"b",
")",
"{",
"if",
"(",
"b",
")",
"{",
"return",
"(",
"modifier",
"|",
"VOLATILE",
")",
"&",
"(",
"~",
"SYNCHRONIZED",
"&",
"~",
"NATIVE",
"&",
"~",
"INTERFACE",
"&",
"~",
"ABSTRACT",
"&",
"~",
"STRICT",
")",
";",
"}",
"else",
"{",
"return",
"modifier",
"&",
"~",
"VOLATILE",
";",
"}",
"}"
] | When set volatile, non-field settings are cleared. | [
"When",
"set",
"volatile",
"non",
"-",
"field",
"settings",
"are",
"cleared",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java#L107-L115 |
76 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java | Modifiers.setTransient | public static int setTransient(int modifier, boolean b) {
if (b) {
return (modifier | TRANSIENT) &
(~SYNCHRONIZED & ~NATIVE & ~INTERFACE & ~ABSTRACT & ~STRICT);
}
else {
return modifier & ~TRANSIENT;
}
} | java | public static int setTransient(int modifier, boolean b) {
if (b) {
return (modifier | TRANSIENT) &
(~SYNCHRONIZED & ~NATIVE & ~INTERFACE & ~ABSTRACT & ~STRICT);
}
else {
return modifier & ~TRANSIENT;
}
} | [
"public",
"static",
"int",
"setTransient",
"(",
"int",
"modifier",
",",
"boolean",
"b",
")",
"{",
"if",
"(",
"b",
")",
"{",
"return",
"(",
"modifier",
"|",
"TRANSIENT",
")",
"&",
"(",
"~",
"SYNCHRONIZED",
"&",
"~",
"NATIVE",
"&",
"~",
"INTERFACE",
"&",
"~",
"ABSTRACT",
"&",
"~",
"STRICT",
")",
";",
"}",
"else",
"{",
"return",
"modifier",
"&",
"~",
"TRANSIENT",
";",
"}",
"}"
] | When set transient, non-field settings are cleared. | [
"When",
"set",
"transient",
"non",
"-",
"field",
"settings",
"are",
"cleared",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java#L120-L128 |
77 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java | Modifiers.setNative | public static int setNative(int modifier, boolean b) {
if (b) {
return (modifier | NATIVE) &
(~VOLATILE & ~TRANSIENT & ~INTERFACE & ~ABSTRACT & ~STRICT);
}
else {
return modifier & ~NATIVE;
}
} | java | public static int setNative(int modifier, boolean b) {
if (b) {
return (modifier | NATIVE) &
(~VOLATILE & ~TRANSIENT & ~INTERFACE & ~ABSTRACT & ~STRICT);
}
else {
return modifier & ~NATIVE;
}
} | [
"public",
"static",
"int",
"setNative",
"(",
"int",
"modifier",
",",
"boolean",
"b",
")",
"{",
"if",
"(",
"b",
")",
"{",
"return",
"(",
"modifier",
"|",
"NATIVE",
")",
"&",
"(",
"~",
"VOLATILE",
"&",
"~",
"TRANSIENT",
"&",
"~",
"INTERFACE",
"&",
"~",
"ABSTRACT",
"&",
"~",
"STRICT",
")",
";",
"}",
"else",
"{",
"return",
"modifier",
"&",
"~",
"NATIVE",
";",
"}",
"}"
] | When set native, non-native-method settings are cleared. | [
"When",
"set",
"native",
"non",
"-",
"native",
"-",
"method",
"settings",
"are",
"cleared",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java#L133-L141 |
78 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java | Modifiers.setInterface | public static int setInterface(int modifier, boolean b) {
if (b) {
return (modifier | (INTERFACE | ABSTRACT)) &
(~FINAL & ~SYNCHRONIZED & ~VOLATILE & ~TRANSIENT & ~NATIVE);
}
else {
return modifier & ~INTERFACE;
}
} | java | public static int setInterface(int modifier, boolean b) {
if (b) {
return (modifier | (INTERFACE | ABSTRACT)) &
(~FINAL & ~SYNCHRONIZED & ~VOLATILE & ~TRANSIENT & ~NATIVE);
}
else {
return modifier & ~INTERFACE;
}
} | [
"public",
"static",
"int",
"setInterface",
"(",
"int",
"modifier",
",",
"boolean",
"b",
")",
"{",
"if",
"(",
"b",
")",
"{",
"return",
"(",
"modifier",
"|",
"(",
"INTERFACE",
"|",
"ABSTRACT",
")",
")",
"&",
"(",
"~",
"FINAL",
"&",
"~",
"SYNCHRONIZED",
"&",
"~",
"VOLATILE",
"&",
"~",
"TRANSIENT",
"&",
"~",
"NATIVE",
")",
";",
"}",
"else",
"{",
"return",
"modifier",
"&",
"~",
"INTERFACE",
";",
"}",
"}"
] | When set as an interface, non-interface settings are cleared and the
modifier is set abstract. | [
"When",
"set",
"as",
"an",
"interface",
"non",
"-",
"interface",
"settings",
"are",
"cleared",
"and",
"the",
"modifier",
"is",
"set",
"abstract",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java#L147-L155 |
79 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java | Modifiers.setAbstract | public static int setAbstract(int modifier, boolean b) {
if (b) {
return (modifier | ABSTRACT) &
(~FINAL & ~VOLATILE & ~TRANSIENT & ~NATIVE &
~SYNCHRONIZED & ~STRICT);
}
else {
return modifier & ~ABSTRACT & ~INTERFACE;
}
} | java | public static int setAbstract(int modifier, boolean b) {
if (b) {
return (modifier | ABSTRACT) &
(~FINAL & ~VOLATILE & ~TRANSIENT & ~NATIVE &
~SYNCHRONIZED & ~STRICT);
}
else {
return modifier & ~ABSTRACT & ~INTERFACE;
}
} | [
"public",
"static",
"int",
"setAbstract",
"(",
"int",
"modifier",
",",
"boolean",
"b",
")",
"{",
"if",
"(",
"b",
")",
"{",
"return",
"(",
"modifier",
"|",
"ABSTRACT",
")",
"&",
"(",
"~",
"FINAL",
"&",
"~",
"VOLATILE",
"&",
"~",
"TRANSIENT",
"&",
"~",
"NATIVE",
"&",
"~",
"SYNCHRONIZED",
"&",
"~",
"STRICT",
")",
";",
"}",
"else",
"{",
"return",
"modifier",
"&",
"~",
"ABSTRACT",
"&",
"~",
"INTERFACE",
";",
"}",
"}"
] | When set abstract, the modifier is cleared from being final, volatile,
transient, native, synchronized, and strictfp. When cleared from being
abstract, the modifier is also cleared from being an interface. | [
"When",
"set",
"abstract",
"the",
"modifier",
"is",
"cleared",
"from",
"being",
"final",
"volatile",
"transient",
"native",
"synchronized",
"and",
"strictfp",
".",
"When",
"cleared",
"from",
"being",
"abstract",
"the",
"modifier",
"is",
"also",
"cleared",
"from",
"being",
"an",
"interface",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/Modifiers.java#L162-L171 |
80 | teatrove/teatrove | teaservlet/src/main/java/org/teatrove/teaservlet/ApplicationDepot.java | ApplicationDepot.destroy | public void destroy() {
for (int j = 0; j < mApplications.length; j++) {
if (mApplications[j] != null) {
mApplications[j].destroy();
}
}
} | java | public void destroy() {
for (int j = 0; j < mApplications.length; j++) {
if (mApplications[j] != null) {
mApplications[j].destroy();
}
}
} | [
"public",
"void",
"destroy",
"(",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"mApplications",
".",
"length",
";",
"j",
"++",
")",
"{",
"if",
"(",
"mApplications",
"[",
"j",
"]",
"!=",
"null",
")",
"{",
"mApplications",
"[",
"j",
"]",
".",
"destroy",
"(",
")",
";",
"}",
"}",
"}"
] | This method destroys the ApplicationDepot. | [
"This",
"method",
"destroys",
"the",
"ApplicationDepot",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/ApplicationDepot.java#L137-L143 |
81 | teatrove/teatrove | teaservlet/src/main/java/org/teatrove/teaservlet/ApplicationDepot.java | ApplicationDepot.createContextSource | private TeaServletContextSource createContextSource(boolean http)
throws Exception {
return new TeaServletContextSource(getClass().getClassLoader(),
this,
mEngine.getServletContext(),
mEngine.getLog(),
http,
mEngine.getProperties().getBoolean("management.httpcontext", false),
mEngine.getProperties().getInt("management.httpcontext.readUrlCacheSize", 500),
mEngine.getProperties().getBoolean("profiling.enabled", true));
} | java | private TeaServletContextSource createContextSource(boolean http)
throws Exception {
return new TeaServletContextSource(getClass().getClassLoader(),
this,
mEngine.getServletContext(),
mEngine.getLog(),
http,
mEngine.getProperties().getBoolean("management.httpcontext", false),
mEngine.getProperties().getInt("management.httpcontext.readUrlCacheSize", 500),
mEngine.getProperties().getBoolean("profiling.enabled", true));
} | [
"private",
"TeaServletContextSource",
"createContextSource",
"(",
"boolean",
"http",
")",
"throws",
"Exception",
"{",
"return",
"new",
"TeaServletContextSource",
"(",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
",",
"this",
",",
"mEngine",
".",
"getServletContext",
"(",
")",
",",
"mEngine",
".",
"getLog",
"(",
")",
",",
"http",
",",
"mEngine",
".",
"getProperties",
"(",
")",
".",
"getBoolean",
"(",
"\"management.httpcontext\"",
",",
"false",
")",
",",
"mEngine",
".",
"getProperties",
"(",
")",
".",
"getInt",
"(",
"\"management.httpcontext.readUrlCacheSize\"",
",",
"500",
")",
",",
"mEngine",
".",
"getProperties",
"(",
")",
".",
"getBoolean",
"(",
"\"profiling.enabled\"",
",",
"true",
")",
")",
";",
"}"
] | creates a single context source from the applications in the depot. | [
"creates",
"a",
"single",
"context",
"source",
"from",
"the",
"applications",
"in",
"the",
"depot",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/ApplicationDepot.java#L148-L159 |
82 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/MethodUtils.java | MethodUtils.getMethodsToImplement | public static
Set<MethodEntry> getMethodsToImplement(Class<?> iface,
Map<String, Class<?>> types,
Class<?> parent) {
// TODO: this does not take in account type params defined at the
// method level yet..ie: <C extends Something> C getC() { ... }
Set<MethodEntry> methods = new HashSet<MethodEntry>();
addMethods(methods, iface, types, parent);
return methods;
} | java | public static
Set<MethodEntry> getMethodsToImplement(Class<?> iface,
Map<String, Class<?>> types,
Class<?> parent) {
// TODO: this does not take in account type params defined at the
// method level yet..ie: <C extends Something> C getC() { ... }
Set<MethodEntry> methods = new HashSet<MethodEntry>();
addMethods(methods, iface, types, parent);
return methods;
} | [
"public",
"static",
"Set",
"<",
"MethodEntry",
">",
"getMethodsToImplement",
"(",
"Class",
"<",
"?",
">",
"iface",
",",
"Map",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"types",
",",
"Class",
"<",
"?",
">",
"parent",
")",
"{",
"// TODO: this does not take in account type params defined at the",
"// method level yet..ie: <C extends Something> C getC() { ... }",
"Set",
"<",
"MethodEntry",
">",
"methods",
"=",
"new",
"HashSet",
"<",
"MethodEntry",
">",
"(",
")",
";",
"addMethods",
"(",
"methods",
",",
"iface",
",",
"types",
",",
"parent",
")",
";",
"return",
"methods",
";",
"}"
] | Get the set of methods that require implementation based on the given
interface. If the types are specified, then they will be passed through
and methods overridden per the generic types. This may result in bridged
methods. If parent is specified, then only non-implemented methods will
be returned.
@param iface The associated interface
@param types The set of named type variables
@param parent The optional parent
@return The set of methods to implement | [
"Get",
"the",
"set",
"of",
"methods",
"that",
"require",
"implementation",
"based",
"on",
"the",
"given",
"interface",
".",
"If",
"the",
"types",
"are",
"specified",
"then",
"they",
"will",
"be",
"passed",
"through",
"and",
"methods",
"overridden",
"per",
"the",
"generic",
"types",
".",
"This",
"may",
"result",
"in",
"bridged",
"methods",
".",
"If",
"parent",
"is",
"specified",
"then",
"only",
"non",
"-",
"implemented",
"methods",
"will",
"be",
"returned",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/MethodUtils.java#L59-L69 |
83 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/MethodUtils.java | MethodUtils.isBridgeRequired | private static boolean isBridgeRequired(Map<String, Class<?>> types,
Method method) {
// check return type
TypeVariable<?> var = getTypeVariable(method.getGenericReturnType());
if (var != null && types.containsKey(var.getName())) {
return true;
}
// check param types
for (Type paramType : method.getGenericParameterTypes()) {
var = getTypeVariable(paramType);
if (var != null && types.containsKey(var.getName())) {
return true;
}
}
// not required
return false;
} | java | private static boolean isBridgeRequired(Map<String, Class<?>> types,
Method method) {
// check return type
TypeVariable<?> var = getTypeVariable(method.getGenericReturnType());
if (var != null && types.containsKey(var.getName())) {
return true;
}
// check param types
for (Type paramType : method.getGenericParameterTypes()) {
var = getTypeVariable(paramType);
if (var != null && types.containsKey(var.getName())) {
return true;
}
}
// not required
return false;
} | [
"private",
"static",
"boolean",
"isBridgeRequired",
"(",
"Map",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"types",
",",
"Method",
"method",
")",
"{",
"// check return type",
"TypeVariable",
"<",
"?",
">",
"var",
"=",
"getTypeVariable",
"(",
"method",
".",
"getGenericReturnType",
"(",
")",
")",
";",
"if",
"(",
"var",
"!=",
"null",
"&&",
"types",
".",
"containsKey",
"(",
"var",
".",
"getName",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"// check param types",
"for",
"(",
"Type",
"paramType",
":",
"method",
".",
"getGenericParameterTypes",
"(",
")",
")",
"{",
"var",
"=",
"getTypeVariable",
"(",
"paramType",
")",
";",
"if",
"(",
"var",
"!=",
"null",
"&&",
"types",
".",
"containsKey",
"(",
"var",
".",
"getName",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"// not required",
"return",
"false",
";",
"}"
] | Check whether a bridge is required for the given method and generic
type information. If the return type or any parameter contains a type
variable that is specified and overridden with a more specific type
via the given types, then a bridge will be required.
@param types The set of named type variables
@param method The method to check
@return The state of whether a bridge is required | [
"Check",
"whether",
"a",
"bridge",
"is",
"required",
"for",
"the",
"given",
"method",
"and",
"generic",
"type",
"information",
".",
"If",
"the",
"return",
"type",
"or",
"any",
"parameter",
"contains",
"a",
"type",
"variable",
"that",
"is",
"specified",
"and",
"overridden",
"with",
"a",
"more",
"specific",
"type",
"via",
"the",
"given",
"types",
"then",
"a",
"bridge",
"will",
"be",
"required",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/MethodUtils.java#L152-L170 |
84 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/MethodUtils.java | MethodUtils.getRootType | private static final Class<?> getRootType(Map<String, Class<?>> types,
Type type) {
// if type explicitly defined, pass thru as is
if (type instanceof Class) {
return (Class<?>) type;
}
// if type defined as parameter, pass thru root type
else if (type instanceof ParameterizedType) {
Type raw = ((ParameterizedType) type).getRawType();
return getRootType(types, raw);
}
// if type defined as wildcard, pass thru bounds
// NOTE: this does not support ? super X format
else if (type instanceof WildcardType) {
Type[] bounds = ((WildcardType) type).getUpperBounds();
if (bounds.length >= 1) {
return getRootType(types, bounds[0]);
}
}
// otherwise, either generic array or plain type variable
// lookup in types and return specified type if provided
else {
TypeVariable<?> raw = getTypeVariable(type);
if (raw != null) {
// verify type is overridden
String name = raw.getName();
if (types.containsKey(name)) {
// get actual type and convert to array if necessary
Class<?> actual = types.get(name);
int dimensions = getDimensions(type);
if (dimensions >= 1) {
actual = Array.newInstance
(
actual, dimensions
).getClass();
}
return actual;
}
}
}
// nothing found
return null;
} | java | private static final Class<?> getRootType(Map<String, Class<?>> types,
Type type) {
// if type explicitly defined, pass thru as is
if (type instanceof Class) {
return (Class<?>) type;
}
// if type defined as parameter, pass thru root type
else if (type instanceof ParameterizedType) {
Type raw = ((ParameterizedType) type).getRawType();
return getRootType(types, raw);
}
// if type defined as wildcard, pass thru bounds
// NOTE: this does not support ? super X format
else if (type instanceof WildcardType) {
Type[] bounds = ((WildcardType) type).getUpperBounds();
if (bounds.length >= 1) {
return getRootType(types, bounds[0]);
}
}
// otherwise, either generic array or plain type variable
// lookup in types and return specified type if provided
else {
TypeVariable<?> raw = getTypeVariable(type);
if (raw != null) {
// verify type is overridden
String name = raw.getName();
if (types.containsKey(name)) {
// get actual type and convert to array if necessary
Class<?> actual = types.get(name);
int dimensions = getDimensions(type);
if (dimensions >= 1) {
actual = Array.newInstance
(
actual, dimensions
).getClass();
}
return actual;
}
}
}
// nothing found
return null;
} | [
"private",
"static",
"final",
"Class",
"<",
"?",
">",
"getRootType",
"(",
"Map",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"types",
",",
"Type",
"type",
")",
"{",
"// if type explicitly defined, pass thru as is",
"if",
"(",
"type",
"instanceof",
"Class",
")",
"{",
"return",
"(",
"Class",
"<",
"?",
">",
")",
"type",
";",
"}",
"// if type defined as parameter, pass thru root type",
"else",
"if",
"(",
"type",
"instanceof",
"ParameterizedType",
")",
"{",
"Type",
"raw",
"=",
"(",
"(",
"ParameterizedType",
")",
"type",
")",
".",
"getRawType",
"(",
")",
";",
"return",
"getRootType",
"(",
"types",
",",
"raw",
")",
";",
"}",
"// if type defined as wildcard, pass thru bounds",
"// NOTE: this does not support ? super X format",
"else",
"if",
"(",
"type",
"instanceof",
"WildcardType",
")",
"{",
"Type",
"[",
"]",
"bounds",
"=",
"(",
"(",
"WildcardType",
")",
"type",
")",
".",
"getUpperBounds",
"(",
")",
";",
"if",
"(",
"bounds",
".",
"length",
">=",
"1",
")",
"{",
"return",
"getRootType",
"(",
"types",
",",
"bounds",
"[",
"0",
"]",
")",
";",
"}",
"}",
"// otherwise, either generic array or plain type variable",
"// lookup in types and return specified type if provided",
"else",
"{",
"TypeVariable",
"<",
"?",
">",
"raw",
"=",
"getTypeVariable",
"(",
"type",
")",
";",
"if",
"(",
"raw",
"!=",
"null",
")",
"{",
"// verify type is overridden",
"String",
"name",
"=",
"raw",
".",
"getName",
"(",
")",
";",
"if",
"(",
"types",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"// get actual type and convert to array if necessary",
"Class",
"<",
"?",
">",
"actual",
"=",
"types",
".",
"get",
"(",
"name",
")",
";",
"int",
"dimensions",
"=",
"getDimensions",
"(",
"type",
")",
";",
"if",
"(",
"dimensions",
">=",
"1",
")",
"{",
"actual",
"=",
"Array",
".",
"newInstance",
"(",
"actual",
",",
"dimensions",
")",
".",
"getClass",
"(",
")",
";",
"}",
"return",
"actual",
";",
"}",
"}",
"}",
"// nothing found",
"return",
"null",
";",
"}"
] | Get the root class type based on the given type and set of named type
variables. If the type is already a Class, it is renamed as is. If the
type is a parameterized type, then the raw type is returned. If the
type is a wildcard, the lower bounds is returned. Otherwise, if the
type is a type variable, its associated value from the types is returned.
@param types The named type variales to pass thru
@param type The associated type
@return The underlying root class for the type | [
"Get",
"the",
"root",
"class",
"type",
"based",
"on",
"the",
"given",
"type",
"and",
"set",
"of",
"named",
"type",
"variables",
".",
"If",
"the",
"type",
"is",
"already",
"a",
"Class",
"it",
"is",
"renamed",
"as",
"is",
".",
"If",
"the",
"type",
"is",
"a",
"parameterized",
"type",
"then",
"the",
"raw",
"type",
"is",
"returned",
".",
"If",
"the",
"type",
"is",
"a",
"wildcard",
"the",
"lower",
"bounds",
"is",
"returned",
".",
"Otherwise",
"if",
"the",
"type",
"is",
"a",
"type",
"variable",
"its",
"associated",
"value",
"from",
"the",
"types",
"is",
"returned",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/MethodUtils.java#L206-L254 |
85 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/MethodUtils.java | MethodUtils.getMethodType | private static Class<?> getMethodType(Map<String, Class<?>> types,
Type type, Class<?> clazz) {
// check if type is an actual type variable
TypeVariable<?> variable = getTypeVariable(type);
if (variable != null) {
// verify type is overridden
String name = variable.getName();
if (types.containsKey(name)) {
// convert to array if necessary
Class<?> actual = types.get(name);
int dimensions = getDimensions(type);
if (dimensions > 0) {
actual = Array.newInstance(actual, dimensions).getClass();
}
// return overridden type
return actual;
}
}
// nothing overriden, so just return base class
return clazz;
} | java | private static Class<?> getMethodType(Map<String, Class<?>> types,
Type type, Class<?> clazz) {
// check if type is an actual type variable
TypeVariable<?> variable = getTypeVariable(type);
if (variable != null) {
// verify type is overridden
String name = variable.getName();
if (types.containsKey(name)) {
// convert to array if necessary
Class<?> actual = types.get(name);
int dimensions = getDimensions(type);
if (dimensions > 0) {
actual = Array.newInstance(actual, dimensions).getClass();
}
// return overridden type
return actual;
}
}
// nothing overriden, so just return base class
return clazz;
} | [
"private",
"static",
"Class",
"<",
"?",
">",
"getMethodType",
"(",
"Map",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"types",
",",
"Type",
"type",
",",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"// check if type is an actual type variable",
"TypeVariable",
"<",
"?",
">",
"variable",
"=",
"getTypeVariable",
"(",
"type",
")",
";",
"if",
"(",
"variable",
"!=",
"null",
")",
"{",
"// verify type is overridden",
"String",
"name",
"=",
"variable",
".",
"getName",
"(",
")",
";",
"if",
"(",
"types",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"// convert to array if necessary",
"Class",
"<",
"?",
">",
"actual",
"=",
"types",
".",
"get",
"(",
"name",
")",
";",
"int",
"dimensions",
"=",
"getDimensions",
"(",
"type",
")",
";",
"if",
"(",
"dimensions",
">",
"0",
")",
"{",
"actual",
"=",
"Array",
".",
"newInstance",
"(",
"actual",
",",
"dimensions",
")",
".",
"getClass",
"(",
")",
";",
"}",
"// return overridden type",
"return",
"actual",
";",
"}",
"}",
"// nothing overriden, so just return base class",
"return",
"clazz",
";",
"}"
] | Get the actual type for the given type. If the type is a type variable
that is specified in the given types, then the associated class is
returned. Otherwise, the specified class is returned.
@param types The set of named type variables
@param type The generic type of the method
@param clazz The underlying type of the method
@return The actual type to use in the method | [
"Get",
"the",
"actual",
"type",
"for",
"the",
"given",
"type",
".",
"If",
"the",
"type",
"is",
"a",
"type",
"variable",
"that",
"is",
"specified",
"in",
"the",
"given",
"types",
"then",
"the",
"associated",
"class",
"is",
"returned",
".",
"Otherwise",
"the",
"specified",
"class",
"is",
"returned",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/MethodUtils.java#L267-L292 |
86 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/MethodUtils.java | MethodUtils.addMethod | private static void addMethod(Set<MethodEntry> methods,
MethodEntry method) {
if (!method.isBridged()) {
methods.remove(method);
methods.add(method);
}
else if (!methods.contains(method)) {
methods.add(method);
}
} | java | private static void addMethod(Set<MethodEntry> methods,
MethodEntry method) {
if (!method.isBridged()) {
methods.remove(method);
methods.add(method);
}
else if (!methods.contains(method)) {
methods.add(method);
}
} | [
"private",
"static",
"void",
"addMethod",
"(",
"Set",
"<",
"MethodEntry",
">",
"methods",
",",
"MethodEntry",
"method",
")",
"{",
"if",
"(",
"!",
"method",
".",
"isBridged",
"(",
")",
")",
"{",
"methods",
".",
"remove",
"(",
"method",
")",
";",
"methods",
".",
"add",
"(",
"method",
")",
";",
"}",
"else",
"if",
"(",
"!",
"methods",
".",
"contains",
"(",
"method",
")",
")",
"{",
"methods",
".",
"add",
"(",
"method",
")",
";",
"}",
"}"
] | Add a method to the set of existing methods. If the method is not
bridged, it will overwrite any existing signature. Otherwise, it will
only update the set if not previously defined. Note that the signature
of the method entry includes the method name, parameter types, and the
return type.
@param methods The set of methods
@param method The method to add | [
"Add",
"a",
"method",
"to",
"the",
"set",
"of",
"existing",
"methods",
".",
"If",
"the",
"method",
"is",
"not",
"bridged",
"it",
"will",
"overwrite",
"any",
"existing",
"signature",
".",
"Otherwise",
"it",
"will",
"only",
"update",
"the",
"set",
"if",
"not",
"previously",
"defined",
".",
"Note",
"that",
"the",
"signature",
"of",
"the",
"method",
"entry",
"includes",
"the",
"method",
"name",
"parameter",
"types",
"and",
"the",
"return",
"type",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/MethodUtils.java#L304-L313 |
87 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/MethodUtils.java | MethodUtils.addMethods | private static void addMethods(Set<MethodEntry> methods,
Class<?> clazz, Map<String, Class<?>> types,
Class<?> parent) {
// validate interface
if (!clazz.isInterface()) {
throw new IllegalStateException("class must be interface: " + clazz);
}
// loop through each method (only those declared)
for (Method method : clazz.getDeclaredMethods()) {
addMethods(methods, clazz, types, parent, method);
}
// recursively add each super interface providing type info if valid
addParentMethods(methods, clazz, types, parent, null);
} | java | private static void addMethods(Set<MethodEntry> methods,
Class<?> clazz, Map<String, Class<?>> types,
Class<?> parent) {
// validate interface
if (!clazz.isInterface()) {
throw new IllegalStateException("class must be interface: " + clazz);
}
// loop through each method (only those declared)
for (Method method : clazz.getDeclaredMethods()) {
addMethods(methods, clazz, types, parent, method);
}
// recursively add each super interface providing type info if valid
addParentMethods(methods, clazz, types, parent, null);
} | [
"private",
"static",
"void",
"addMethods",
"(",
"Set",
"<",
"MethodEntry",
">",
"methods",
",",
"Class",
"<",
"?",
">",
"clazz",
",",
"Map",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"types",
",",
"Class",
"<",
"?",
">",
"parent",
")",
"{",
"// validate interface",
"if",
"(",
"!",
"clazz",
".",
"isInterface",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"class must be interface: \"",
"+",
"clazz",
")",
";",
"}",
"// loop through each method (only those declared)",
"for",
"(",
"Method",
"method",
":",
"clazz",
".",
"getDeclaredMethods",
"(",
")",
")",
"{",
"addMethods",
"(",
"methods",
",",
"clazz",
",",
"types",
",",
"parent",
",",
"method",
")",
";",
"}",
"// recursively add each super interface providing type info if valid",
"addParentMethods",
"(",
"methods",
",",
"clazz",
",",
"types",
",",
"parent",
",",
"null",
")",
";",
"}"
] | Recursive method that adds all applicable methods for the given class,
which is expected to be an interface. The tree is walked for the class
and all super interfaces in recursive fashion to get each available
method. Any method that is already defined by the given parent will be
ignored. Otherwise, the method, including any required bridged methods
will be added. The specified list of types define the optional type
parameters of the given interface class. These types will propogate up
the tree as necessary for any super-interfaces that match.
@param methods The set of existing methods
@param clazz The current interface class
@param types The set of named type variable
@param parent The optional parent class | [
"Recursive",
"method",
"that",
"adds",
"all",
"applicable",
"methods",
"for",
"the",
"given",
"class",
"which",
"is",
"expected",
"to",
"be",
"an",
"interface",
".",
"The",
"tree",
"is",
"walked",
"for",
"the",
"class",
"and",
"all",
"super",
"interfaces",
"in",
"recursive",
"fashion",
"to",
"get",
"each",
"available",
"method",
".",
"Any",
"method",
"that",
"is",
"already",
"defined",
"by",
"the",
"given",
"parent",
"will",
"be",
"ignored",
".",
"Otherwise",
"the",
"method",
"including",
"any",
"required",
"bridged",
"methods",
"will",
"be",
"added",
".",
"The",
"specified",
"list",
"of",
"types",
"define",
"the",
"optional",
"type",
"parameters",
"of",
"the",
"given",
"interface",
"class",
".",
"These",
"types",
"will",
"propogate",
"up",
"the",
"tree",
"as",
"necessary",
"for",
"any",
"super",
"-",
"interfaces",
"that",
"match",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/MethodUtils.java#L330-L346 |
88 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/MethodUtils.java | MethodUtils.addMethods | private static void addMethods(Set<MethodEntry> methods,
Class<?> clazz, Map<String, Class<?>> types,
Class<?> parent, Method method) {
// validate interface
//if (!clazz.isInterface()) {
// throw new IllegalStateException("class must be interface: " + clazz);
//}
// check if the method requires a bridge and add generic method
// with overridden type params
MethodEntry impl = null;
boolean bridged = isBridgeRequired(types, method);
// do not add method if already implemented
// ignore if method already defined on the parent
if (!bridged && parent != null && findMethod(parent, method) != null) {
return;
}
// bridge if necessary
if (bridged) {
// get the underying generic type if provided
Class<?> returnType = getMethodType
(
types, method.getGenericReturnType(), method.getReturnType()
);
// get the underlying generic params if provided
Type[] paramTypes = method.getGenericParameterTypes();
Class<?>[] paramClasses = method.getParameterTypes();
for (int i = 0; i < paramClasses.length; i++) {
paramClasses[i] = getMethodType
(
types, paramTypes[i], paramClasses[i]
);
}
// check if only return type is overridden and only add impl
// if not yet defined...this is possible since return type is
// not part of a method signature for equality purposes so we
// only need to implement in a concrete implementation once and
// bridge all other methods. Parameters, on the other hand
// must always be explicitly implemented to satisfy their
// interface definition.
MethodEntry bridgeMethod = null;
if (Arrays.equals(paramClasses, method.getParameterTypes())) {
for (MethodEntry mentry : methods) {
if (mentry.getName().equals(method.getName()) &&
Arrays.equals(mentry.getParamTypes(),
method.getParameterTypes())) {
bridgeMethod = mentry;
}
}
}
// add implementation
impl = new MethodEntry(
method.getName(), returnType, paramClasses, bridgeMethod
);
addMethod(methods, impl);
}
// add actual method definition, bridging if implemented above
addMethod(methods, new MethodEntry(method.getName(),
method.getReturnType(),
method.getParameterTypes(),
impl));
// recursively add each super interface providing type info if valid
addParentMethods(methods, clazz, types, parent, method);
} | java | private static void addMethods(Set<MethodEntry> methods,
Class<?> clazz, Map<String, Class<?>> types,
Class<?> parent, Method method) {
// validate interface
//if (!clazz.isInterface()) {
// throw new IllegalStateException("class must be interface: " + clazz);
//}
// check if the method requires a bridge and add generic method
// with overridden type params
MethodEntry impl = null;
boolean bridged = isBridgeRequired(types, method);
// do not add method if already implemented
// ignore if method already defined on the parent
if (!bridged && parent != null && findMethod(parent, method) != null) {
return;
}
// bridge if necessary
if (bridged) {
// get the underying generic type if provided
Class<?> returnType = getMethodType
(
types, method.getGenericReturnType(), method.getReturnType()
);
// get the underlying generic params if provided
Type[] paramTypes = method.getGenericParameterTypes();
Class<?>[] paramClasses = method.getParameterTypes();
for (int i = 0; i < paramClasses.length; i++) {
paramClasses[i] = getMethodType
(
types, paramTypes[i], paramClasses[i]
);
}
// check if only return type is overridden and only add impl
// if not yet defined...this is possible since return type is
// not part of a method signature for equality purposes so we
// only need to implement in a concrete implementation once and
// bridge all other methods. Parameters, on the other hand
// must always be explicitly implemented to satisfy their
// interface definition.
MethodEntry bridgeMethod = null;
if (Arrays.equals(paramClasses, method.getParameterTypes())) {
for (MethodEntry mentry : methods) {
if (mentry.getName().equals(method.getName()) &&
Arrays.equals(mentry.getParamTypes(),
method.getParameterTypes())) {
bridgeMethod = mentry;
}
}
}
// add implementation
impl = new MethodEntry(
method.getName(), returnType, paramClasses, bridgeMethod
);
addMethod(methods, impl);
}
// add actual method definition, bridging if implemented above
addMethod(methods, new MethodEntry(method.getName(),
method.getReturnType(),
method.getParameterTypes(),
impl));
// recursively add each super interface providing type info if valid
addParentMethods(methods, clazz, types, parent, method);
} | [
"private",
"static",
"void",
"addMethods",
"(",
"Set",
"<",
"MethodEntry",
">",
"methods",
",",
"Class",
"<",
"?",
">",
"clazz",
",",
"Map",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"types",
",",
"Class",
"<",
"?",
">",
"parent",
",",
"Method",
"method",
")",
"{",
"// validate interface",
"//if (!clazz.isInterface()) { ",
"// throw new IllegalStateException(\"class must be interface: \" + clazz);",
"//}",
"// check if the method requires a bridge and add generic method",
"// with overridden type params",
"MethodEntry",
"impl",
"=",
"null",
";",
"boolean",
"bridged",
"=",
"isBridgeRequired",
"(",
"types",
",",
"method",
")",
";",
"// do not add method if already implemented",
"// ignore if method already defined on the parent",
"if",
"(",
"!",
"bridged",
"&&",
"parent",
"!=",
"null",
"&&",
"findMethod",
"(",
"parent",
",",
"method",
")",
"!=",
"null",
")",
"{",
"return",
";",
"}",
"// bridge if necessary",
"if",
"(",
"bridged",
")",
"{",
"// get the underying generic type if provided",
"Class",
"<",
"?",
">",
"returnType",
"=",
"getMethodType",
"(",
"types",
",",
"method",
".",
"getGenericReturnType",
"(",
")",
",",
"method",
".",
"getReturnType",
"(",
")",
")",
";",
"// get the underlying generic params if provided",
"Type",
"[",
"]",
"paramTypes",
"=",
"method",
".",
"getGenericParameterTypes",
"(",
")",
";",
"Class",
"<",
"?",
">",
"[",
"]",
"paramClasses",
"=",
"method",
".",
"getParameterTypes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"paramClasses",
".",
"length",
";",
"i",
"++",
")",
"{",
"paramClasses",
"[",
"i",
"]",
"=",
"getMethodType",
"(",
"types",
",",
"paramTypes",
"[",
"i",
"]",
",",
"paramClasses",
"[",
"i",
"]",
")",
";",
"}",
"// check if only return type is overridden and only add impl",
"// if not yet defined...this is possible since return type is",
"// not part of a method signature for equality purposes so we",
"// only need to implement in a concrete implementation once and",
"// bridge all other methods. Parameters, on the other hand",
"// must always be explicitly implemented to satisfy their",
"// interface definition.",
"MethodEntry",
"bridgeMethod",
"=",
"null",
";",
"if",
"(",
"Arrays",
".",
"equals",
"(",
"paramClasses",
",",
"method",
".",
"getParameterTypes",
"(",
")",
")",
")",
"{",
"for",
"(",
"MethodEntry",
"mentry",
":",
"methods",
")",
"{",
"if",
"(",
"mentry",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"method",
".",
"getName",
"(",
")",
")",
"&&",
"Arrays",
".",
"equals",
"(",
"mentry",
".",
"getParamTypes",
"(",
")",
",",
"method",
".",
"getParameterTypes",
"(",
")",
")",
")",
"{",
"bridgeMethod",
"=",
"mentry",
";",
"}",
"}",
"}",
"// add implementation",
"impl",
"=",
"new",
"MethodEntry",
"(",
"method",
".",
"getName",
"(",
")",
",",
"returnType",
",",
"paramClasses",
",",
"bridgeMethod",
")",
";",
"addMethod",
"(",
"methods",
",",
"impl",
")",
";",
"}",
"// add actual method definition, bridging if implemented above",
"addMethod",
"(",
"methods",
",",
"new",
"MethodEntry",
"(",
"method",
".",
"getName",
"(",
")",
",",
"method",
".",
"getReturnType",
"(",
")",
",",
"method",
".",
"getParameterTypes",
"(",
")",
",",
"impl",
")",
")",
";",
"// recursively add each super interface providing type info if valid",
"addParentMethods",
"(",
"methods",
",",
"clazz",
",",
"types",
",",
"parent",
",",
"method",
")",
";",
"}"
] | Recursive method that adds all applicable methods related to the given
class, which is expected to be an interface. The tree is walked for the
class and all super interfaces in recursive fashion to get each available
method that matches the provided method. Any method that is already
defined by the given parent will be ignored. Otherwise, the method,
including any required bridged methods will be added. The specified list
of types define the optional type parameters of the given interface
class. These types will propogate up the tree as necessary for any
super-interfaces that match.
@param methods The set of existing methods
@param clazz The current interface class
@param types The set of named type variable
@param parent The optional parent class
@param method The method to implement | [
"Recursive",
"method",
"that",
"adds",
"all",
"applicable",
"methods",
"related",
"to",
"the",
"given",
"class",
"which",
"is",
"expected",
"to",
"be",
"an",
"interface",
".",
"The",
"tree",
"is",
"walked",
"for",
"the",
"class",
"and",
"all",
"super",
"interfaces",
"in",
"recursive",
"fashion",
"to",
"get",
"each",
"available",
"method",
"that",
"matches",
"the",
"provided",
"method",
".",
"Any",
"method",
"that",
"is",
"already",
"defined",
"by",
"the",
"given",
"parent",
"will",
"be",
"ignored",
".",
"Otherwise",
"the",
"method",
"including",
"any",
"required",
"bridged",
"methods",
"will",
"be",
"added",
".",
"The",
"specified",
"list",
"of",
"types",
"define",
"the",
"optional",
"type",
"parameters",
"of",
"the",
"given",
"interface",
"class",
".",
"These",
"types",
"will",
"propogate",
"up",
"the",
"tree",
"as",
"necessary",
"for",
"any",
"super",
"-",
"interfaces",
"that",
"match",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/MethodUtils.java#L365-L436 |
89 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/MethodUtils.java | MethodUtils.addParentMethods | private static void addParentMethods(Set<MethodEntry> methods,
Class<?> clazz,
Map<String, Class<?>> types,
Class<?> parent, Method method) {
// recursively add each super interface providing type info if valid
Class<?>[] ifaces = clazz.getInterfaces();
Type[] generics = clazz.getGenericInterfaces();
for (int i = 0; i < ifaces.length; i++) {
Class<?> iface = ifaces[i];
Type generic = iface;
if (generics != null && i < generics.length) {
generic = generics[i];
}
// check if interface is parameterized and lookup type information
// cascading current type information if types match
if (generic instanceof ParameterizedType) {
TypeVariable<?>[] vars = iface.getTypeParameters();
ParameterizedType ptype = (ParameterizedType) generic;
Type[] arguments = ptype.getActualTypeArguments();
// check each parameter for specific type
Map<String, Class<?>> args = new HashMap<String, Class<?>>();
for (int j = 0; j < vars.length; j++) {
Type arg = arguments[j];
TypeVariable<?> var = vars[j];
// check if root type defined and pass type thru
Class<?> root = getRootType(types, arg);
if (root != null) {
args.put(var.getName(), root);
}
}
// recursively invoke
if (method == null) {
addMethods(methods, (Class<?>) ptype.getRawType(), args,
parent);
}
else {
addMethods(methods, (Class<?>) ptype.getRawType(), args,
parent, method);
}
}
// normal class, so recursively invoke as is
else if (iface instanceof Class<?>) {
if (method == null) {
addMethods(methods, iface, new HashMap<String, Class<?>>(),
parent);
}
else {
addMethods(methods, iface, new HashMap<String, Class<?>>(),
parent, method);
}
}
}
} | java | private static void addParentMethods(Set<MethodEntry> methods,
Class<?> clazz,
Map<String, Class<?>> types,
Class<?> parent, Method method) {
// recursively add each super interface providing type info if valid
Class<?>[] ifaces = clazz.getInterfaces();
Type[] generics = clazz.getGenericInterfaces();
for (int i = 0; i < ifaces.length; i++) {
Class<?> iface = ifaces[i];
Type generic = iface;
if (generics != null && i < generics.length) {
generic = generics[i];
}
// check if interface is parameterized and lookup type information
// cascading current type information if types match
if (generic instanceof ParameterizedType) {
TypeVariable<?>[] vars = iface.getTypeParameters();
ParameterizedType ptype = (ParameterizedType) generic;
Type[] arguments = ptype.getActualTypeArguments();
// check each parameter for specific type
Map<String, Class<?>> args = new HashMap<String, Class<?>>();
for (int j = 0; j < vars.length; j++) {
Type arg = arguments[j];
TypeVariable<?> var = vars[j];
// check if root type defined and pass type thru
Class<?> root = getRootType(types, arg);
if (root != null) {
args.put(var.getName(), root);
}
}
// recursively invoke
if (method == null) {
addMethods(methods, (Class<?>) ptype.getRawType(), args,
parent);
}
else {
addMethods(methods, (Class<?>) ptype.getRawType(), args,
parent, method);
}
}
// normal class, so recursively invoke as is
else if (iface instanceof Class<?>) {
if (method == null) {
addMethods(methods, iface, new HashMap<String, Class<?>>(),
parent);
}
else {
addMethods(methods, iface, new HashMap<String, Class<?>>(),
parent, method);
}
}
}
} | [
"private",
"static",
"void",
"addParentMethods",
"(",
"Set",
"<",
"MethodEntry",
">",
"methods",
",",
"Class",
"<",
"?",
">",
"clazz",
",",
"Map",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"types",
",",
"Class",
"<",
"?",
">",
"parent",
",",
"Method",
"method",
")",
"{",
"// recursively add each super interface providing type info if valid",
"Class",
"<",
"?",
">",
"[",
"]",
"ifaces",
"=",
"clazz",
".",
"getInterfaces",
"(",
")",
";",
"Type",
"[",
"]",
"generics",
"=",
"clazz",
".",
"getGenericInterfaces",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ifaces",
".",
"length",
";",
"i",
"++",
")",
"{",
"Class",
"<",
"?",
">",
"iface",
"=",
"ifaces",
"[",
"i",
"]",
";",
"Type",
"generic",
"=",
"iface",
";",
"if",
"(",
"generics",
"!=",
"null",
"&&",
"i",
"<",
"generics",
".",
"length",
")",
"{",
"generic",
"=",
"generics",
"[",
"i",
"]",
";",
"}",
"// check if interface is parameterized and lookup type information",
"// cascading current type information if types match",
"if",
"(",
"generic",
"instanceof",
"ParameterizedType",
")",
"{",
"TypeVariable",
"<",
"?",
">",
"[",
"]",
"vars",
"=",
"iface",
".",
"getTypeParameters",
"(",
")",
";",
"ParameterizedType",
"ptype",
"=",
"(",
"ParameterizedType",
")",
"generic",
";",
"Type",
"[",
"]",
"arguments",
"=",
"ptype",
".",
"getActualTypeArguments",
"(",
")",
";",
"// check each parameter for specific type ",
"Map",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"args",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"(",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"vars",
".",
"length",
";",
"j",
"++",
")",
"{",
"Type",
"arg",
"=",
"arguments",
"[",
"j",
"]",
";",
"TypeVariable",
"<",
"?",
">",
"var",
"=",
"vars",
"[",
"j",
"]",
";",
"// check if root type defined and pass type thru",
"Class",
"<",
"?",
">",
"root",
"=",
"getRootType",
"(",
"types",
",",
"arg",
")",
";",
"if",
"(",
"root",
"!=",
"null",
")",
"{",
"args",
".",
"put",
"(",
"var",
".",
"getName",
"(",
")",
",",
"root",
")",
";",
"}",
"}",
"// recursively invoke",
"if",
"(",
"method",
"==",
"null",
")",
"{",
"addMethods",
"(",
"methods",
",",
"(",
"Class",
"<",
"?",
">",
")",
"ptype",
".",
"getRawType",
"(",
")",
",",
"args",
",",
"parent",
")",
";",
"}",
"else",
"{",
"addMethods",
"(",
"methods",
",",
"(",
"Class",
"<",
"?",
">",
")",
"ptype",
".",
"getRawType",
"(",
")",
",",
"args",
",",
"parent",
",",
"method",
")",
";",
"}",
"}",
"// normal class, so recursively invoke as is",
"else",
"if",
"(",
"iface",
"instanceof",
"Class",
"<",
"?",
">",
")",
"{",
"if",
"(",
"method",
"==",
"null",
")",
"{",
"addMethods",
"(",
"methods",
",",
"iface",
",",
"new",
"HashMap",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"(",
")",
",",
"parent",
")",
";",
"}",
"else",
"{",
"addMethods",
"(",
"methods",
",",
"iface",
",",
"new",
"HashMap",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"(",
")",
",",
"parent",
",",
"method",
")",
";",
"}",
"}",
"}",
"}"
] | Recursively add all methods walking the interface hiearchy for the given
class.
@param methods The set of existing methods
@param clazz The current interface class
@param types The set of named type variable
@param parent The optional parent class
@param method The method to implement | [
"Recursively",
"add",
"all",
"methods",
"walking",
"the",
"interface",
"hiearchy",
"for",
"the",
"given",
"class",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/MethodUtils.java#L448-L505 |
90 | teatrove/teatrove | tea/src/main/java/org/teatrove/tea/engine/TemplateSourceImpl.java | TemplateSourceImpl.createTemplateClassesDir | public static File createTemplateClassesDir(File tmpDir, String dirPath,
Log log) {
File destDir = null;
if (dirPath != null && !dirPath.isEmpty()) {
// handle file-based paths
if (dirPath.startsWith("file:")) {
destDir = new File(dirPath.substring(5));
}
// otherwise, assume relative path to tmp dir
else {
destDir = new File(tmpDir, dirPath);
try {
if (!destDir.getCanonicalPath().startsWith(
tmpDir.getCanonicalPath().concat(File.separator))) {
throw new IllegalStateException(
"invalid template classes directory: " + dirPath
);
}
}
catch (IOException ioe) {
throw new IllegalStateException(
"invalid template classes directory: " + dirPath,
ioe
);
}
}
if (!destDir.isDirectory()) {
// try creating it but not the parents.
if (!destDir.mkdir()) {
log.warn("Could not create template classes directory: " +
destDir.getAbsolutePath());
destDir = null;
}
}
if (destDir != null && !destDir.canWrite()) {
log.warn("Unable to write to template classes directory: " +
destDir.getAbsolutePath());
destDir = null;
}
}
return destDir;
} | java | public static File createTemplateClassesDir(File tmpDir, String dirPath,
Log log) {
File destDir = null;
if (dirPath != null && !dirPath.isEmpty()) {
// handle file-based paths
if (dirPath.startsWith("file:")) {
destDir = new File(dirPath.substring(5));
}
// otherwise, assume relative path to tmp dir
else {
destDir = new File(tmpDir, dirPath);
try {
if (!destDir.getCanonicalPath().startsWith(
tmpDir.getCanonicalPath().concat(File.separator))) {
throw new IllegalStateException(
"invalid template classes directory: " + dirPath
);
}
}
catch (IOException ioe) {
throw new IllegalStateException(
"invalid template classes directory: " + dirPath,
ioe
);
}
}
if (!destDir.isDirectory()) {
// try creating it but not the parents.
if (!destDir.mkdir()) {
log.warn("Could not create template classes directory: " +
destDir.getAbsolutePath());
destDir = null;
}
}
if (destDir != null && !destDir.canWrite()) {
log.warn("Unable to write to template classes directory: " +
destDir.getAbsolutePath());
destDir = null;
}
}
return destDir;
} | [
"public",
"static",
"File",
"createTemplateClassesDir",
"(",
"File",
"tmpDir",
",",
"String",
"dirPath",
",",
"Log",
"log",
")",
"{",
"File",
"destDir",
"=",
"null",
";",
"if",
"(",
"dirPath",
"!=",
"null",
"&&",
"!",
"dirPath",
".",
"isEmpty",
"(",
")",
")",
"{",
"// handle file-based paths",
"if",
"(",
"dirPath",
".",
"startsWith",
"(",
"\"file:\"",
")",
")",
"{",
"destDir",
"=",
"new",
"File",
"(",
"dirPath",
".",
"substring",
"(",
"5",
")",
")",
";",
"}",
"// otherwise, assume relative path to tmp dir",
"else",
"{",
"destDir",
"=",
"new",
"File",
"(",
"tmpDir",
",",
"dirPath",
")",
";",
"try",
"{",
"if",
"(",
"!",
"destDir",
".",
"getCanonicalPath",
"(",
")",
".",
"startsWith",
"(",
"tmpDir",
".",
"getCanonicalPath",
"(",
")",
".",
"concat",
"(",
"File",
".",
"separator",
")",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"invalid template classes directory: \"",
"+",
"dirPath",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"invalid template classes directory: \"",
"+",
"dirPath",
",",
"ioe",
")",
";",
"}",
"}",
"if",
"(",
"!",
"destDir",
".",
"isDirectory",
"(",
")",
")",
"{",
"// try creating it but not the parents.",
"if",
"(",
"!",
"destDir",
".",
"mkdir",
"(",
")",
")",
"{",
"log",
".",
"warn",
"(",
"\"Could not create template classes directory: \"",
"+",
"destDir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"destDir",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"destDir",
"!=",
"null",
"&&",
"!",
"destDir",
".",
"canWrite",
"(",
")",
")",
"{",
"log",
".",
"warn",
"(",
"\"Unable to write to template classes directory: \"",
"+",
"destDir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"destDir",
"=",
"null",
";",
"}",
"}",
"return",
"destDir",
";",
"}"
] | converts a path to a File for storing compiled template classes.
@return the directory or null if the directory is not there or
if it cannot be written to. | [
"converts",
"a",
"path",
"to",
"a",
"File",
"for",
"storing",
"compiled",
"template",
"classes",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/engine/TemplateSourceImpl.java#L68-L114 |
91 | teatrove/teatrove | tea/src/main/java/org/teatrove/tea/engine/TemplateSourceImpl.java | TemplateSourceImpl.createClassInjector | protected ClassInjector createClassInjector() throws Exception {
return new ResolvingInjector
(mConfig.getContextSource().getContextType().getClassLoader(),
new File[] {mCompiledDir},
mConfig.getPackagePrefix(),
false);
} | java | protected ClassInjector createClassInjector() throws Exception {
return new ResolvingInjector
(mConfig.getContextSource().getContextType().getClassLoader(),
new File[] {mCompiledDir},
mConfig.getPackagePrefix(),
false);
} | [
"protected",
"ClassInjector",
"createClassInjector",
"(",
")",
"throws",
"Exception",
"{",
"return",
"new",
"ResolvingInjector",
"(",
"mConfig",
".",
"getContextSource",
"(",
")",
".",
"getContextType",
"(",
")",
".",
"getClassLoader",
"(",
")",
",",
"new",
"File",
"[",
"]",
"{",
"mCompiledDir",
"}",
",",
"mConfig",
".",
"getPackagePrefix",
"(",
")",
",",
"false",
")",
";",
"}"
] | provides a default class injector using the contextType's ClassLoader
as a parent. | [
"provides",
"a",
"default",
"class",
"injector",
"using",
"the",
"contextType",
"s",
"ClassLoader",
"as",
"a",
"parent",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/engine/TemplateSourceImpl.java#L719-L725 |
92 | teatrove/teatrove | tea/src/main/java/org/teatrove/tea/engine/TemplateSourceImpl.java | TemplateSourceImpl.sourceSignatureChanged | protected boolean sourceSignatureChanged(String tName, Compiler compiler)
throws IOException {
TemplateRepository tRepo = TemplateRepository.getInstance();
TemplateInfo templateInfo = tRepo.getTemplateInfo(tName);
if(null == templateInfo) {
return false;
}
CompilationUnit unit = compiler.getCompilationUnit(tName, null);
if (unit == null) {
return false;
}
return ! unit.signatureEquals(tName, templateInfo.getParameterTypes(), templateInfo.getReturnType());
} | java | protected boolean sourceSignatureChanged(String tName, Compiler compiler)
throws IOException {
TemplateRepository tRepo = TemplateRepository.getInstance();
TemplateInfo templateInfo = tRepo.getTemplateInfo(tName);
if(null == templateInfo) {
return false;
}
CompilationUnit unit = compiler.getCompilationUnit(tName, null);
if (unit == null) {
return false;
}
return ! unit.signatureEquals(tName, templateInfo.getParameterTypes(), templateInfo.getReturnType());
} | [
"protected",
"boolean",
"sourceSignatureChanged",
"(",
"String",
"tName",
",",
"Compiler",
"compiler",
")",
"throws",
"IOException",
"{",
"TemplateRepository",
"tRepo",
"=",
"TemplateRepository",
".",
"getInstance",
"(",
")",
";",
"TemplateInfo",
"templateInfo",
"=",
"tRepo",
".",
"getTemplateInfo",
"(",
"tName",
")",
";",
"if",
"(",
"null",
"==",
"templateInfo",
")",
"{",
"return",
"false",
";",
"}",
"CompilationUnit",
"unit",
"=",
"compiler",
".",
"getCompilationUnit",
"(",
"tName",
",",
"null",
")",
";",
"if",
"(",
"unit",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"!",
"unit",
".",
"signatureEquals",
"(",
"tName",
",",
"templateInfo",
".",
"getParameterTypes",
"(",
")",
",",
"templateInfo",
".",
"getReturnType",
"(",
")",
")",
";",
"}"
] | parses the tea source file and compares the signature to the signature of the current class file
in the TemplateRepository
@return true if tea source signature is different than the class file signature or class file does not exist | [
"parses",
"the",
"tea",
"source",
"file",
"and",
"compares",
"the",
"signature",
"to",
"the",
"signature",
"of",
"the",
"current",
"class",
"file",
"in",
"the",
"TemplateRepository"
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/engine/TemplateSourceImpl.java#L853-L868 |
93 | teatrove/teatrove | tea/src/main/java/org/teatrove/tea/util/FileCompilationProvider.java | FileCompilationProvider.createCompilationSource | @Override
public CompilationSource createCompilationSource(String name) {
File sourceFile = getSourceFile(name);
if (sourceFile == null || !sourceFile.exists()) {
return null;
}
return new FileSource(name, sourceFile);
} | java | @Override
public CompilationSource createCompilationSource(String name) {
File sourceFile = getSourceFile(name);
if (sourceFile == null || !sourceFile.exists()) {
return null;
}
return new FileSource(name, sourceFile);
} | [
"@",
"Override",
"public",
"CompilationSource",
"createCompilationSource",
"(",
"String",
"name",
")",
"{",
"File",
"sourceFile",
"=",
"getSourceFile",
"(",
"name",
")",
";",
"if",
"(",
"sourceFile",
"==",
"null",
"||",
"!",
"sourceFile",
".",
"exists",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"FileSource",
"(",
"name",
",",
"sourceFile",
")",
";",
"}"
] | Always returns an instance of FileCompiler.Unit. Any errors reported
by the compiler that have a reference to a CompilationUnit will have
been created by this factory method. Casting this to FileCompiler.Unit
allows error reporters to access the source file via the getSourceFile
method.
@see FileCompilationProvider.Unit#getSourceFile | [
"Always",
"returns",
"an",
"instance",
"of",
"FileCompiler",
".",
"Unit",
".",
"Any",
"errors",
"reported",
"by",
"the",
"compiler",
"that",
"have",
"a",
"reference",
"to",
"a",
"CompilationUnit",
"will",
"have",
"been",
"created",
"by",
"this",
"factory",
"method",
".",
"Casting",
"this",
"to",
"FileCompiler",
".",
"Unit",
"allows",
"error",
"reporters",
"to",
"access",
"the",
"source",
"file",
"via",
"the",
"getSourceFile",
"method",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/util/FileCompilationProvider.java#L228-L236 |
94 | teatrove/teatrove | tea/src/main/java/org/teatrove/tea/util/FileCompilationProvider.java | FileCompilationProvider.getSourceFile | protected File getSourceFile(String name) {
String fileName = name.replace('.', File.separatorChar) + ".tea";
File file = new File(mRootSourceDir, fileName);
return file;
} | java | protected File getSourceFile(String name) {
String fileName = name.replace('.', File.separatorChar) + ".tea";
File file = new File(mRootSourceDir, fileName);
return file;
} | [
"protected",
"File",
"getSourceFile",
"(",
"String",
"name",
")",
"{",
"String",
"fileName",
"=",
"name",
".",
"replace",
"(",
"'",
"'",
",",
"File",
".",
"separatorChar",
")",
"+",
"\".tea\"",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"mRootSourceDir",
",",
"fileName",
")",
";",
"return",
"file",
";",
"}"
] | Get the source file relative to the root source directory for the given
template.
@param name The fully-qualified name of the template
@return The file reference to the source file | [
"Get",
"the",
"source",
"file",
"relative",
"to",
"the",
"root",
"source",
"directory",
"for",
"the",
"given",
"template",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/util/FileCompilationProvider.java#L246-L251 |
95 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/util/SecureReadWriteLock.java | SecureReadWriteLock.releaseLock | public boolean releaseLock() {
LockInfo info = (LockInfo)mLockInfoRef.get();
int type = info.mType;
int count = info.mCount;
if (count > 0) {
count--;
}
else {
info.mType = type = NONE;
count = 0;
}
if ((info.mCount = count) == 0) {
switch (type) {
case NONE: default:
return false;
case READ:
synchronized (this) {
mReadLocks--;
notifyAll();
}
break;
case UPGRADABLE:
synchronized (this) {
mUpgradableLockHeld = null;
notifyAll();
}
break;
case WRITE:
synchronized (this) {
mWriteLockHeld = null;
notifyAll();
}
break;
}
info.mType = NONE;
}
else if (type == WRITE && info.mUpgradeCount == count) {
// Convert write lock back into an upgradable lock.
info.mType = UPGRADABLE;
info.mUpgradeCount = 0;
synchronized (this) {
mWriteLockHeld = null;
notifyAll();
}
}
return true;
} | java | public boolean releaseLock() {
LockInfo info = (LockInfo)mLockInfoRef.get();
int type = info.mType;
int count = info.mCount;
if (count > 0) {
count--;
}
else {
info.mType = type = NONE;
count = 0;
}
if ((info.mCount = count) == 0) {
switch (type) {
case NONE: default:
return false;
case READ:
synchronized (this) {
mReadLocks--;
notifyAll();
}
break;
case UPGRADABLE:
synchronized (this) {
mUpgradableLockHeld = null;
notifyAll();
}
break;
case WRITE:
synchronized (this) {
mWriteLockHeld = null;
notifyAll();
}
break;
}
info.mType = NONE;
}
else if (type == WRITE && info.mUpgradeCount == count) {
// Convert write lock back into an upgradable lock.
info.mType = UPGRADABLE;
info.mUpgradeCount = 0;
synchronized (this) {
mWriteLockHeld = null;
notifyAll();
}
}
return true;
} | [
"public",
"boolean",
"releaseLock",
"(",
")",
"{",
"LockInfo",
"info",
"=",
"(",
"LockInfo",
")",
"mLockInfoRef",
".",
"get",
"(",
")",
";",
"int",
"type",
"=",
"info",
".",
"mType",
";",
"int",
"count",
"=",
"info",
".",
"mCount",
";",
"if",
"(",
"count",
">",
"0",
")",
"{",
"count",
"--",
";",
"}",
"else",
"{",
"info",
".",
"mType",
"=",
"type",
"=",
"NONE",
";",
"count",
"=",
"0",
";",
"}",
"if",
"(",
"(",
"info",
".",
"mCount",
"=",
"count",
")",
"==",
"0",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"NONE",
":",
"default",
":",
"return",
"false",
";",
"case",
"READ",
":",
"synchronized",
"(",
"this",
")",
"{",
"mReadLocks",
"--",
";",
"notifyAll",
"(",
")",
";",
"}",
"break",
";",
"case",
"UPGRADABLE",
":",
"synchronized",
"(",
"this",
")",
"{",
"mUpgradableLockHeld",
"=",
"null",
";",
"notifyAll",
"(",
")",
";",
"}",
"break",
";",
"case",
"WRITE",
":",
"synchronized",
"(",
"this",
")",
"{",
"mWriteLockHeld",
"=",
"null",
";",
"notifyAll",
"(",
")",
";",
"}",
"break",
";",
"}",
"info",
".",
"mType",
"=",
"NONE",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"WRITE",
"&&",
"info",
".",
"mUpgradeCount",
"==",
"count",
")",
"{",
"// Convert write lock back into an upgradable lock.",
"info",
".",
"mType",
"=",
"UPGRADABLE",
";",
"info",
".",
"mUpgradeCount",
"=",
"0",
";",
"synchronized",
"(",
"this",
")",
"{",
"mWriteLockHeld",
"=",
"null",
";",
"notifyAll",
"(",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Release the lock held by the current thread.
@return false if this thread doesn't hold a lock. | [
"Release",
"the",
"lock",
"held",
"by",
"the",
"current",
"thread",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/SecureReadWriteLock.java#L322-L374 |
96 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/util/SecureReadWriteLock.java | SecureReadWriteLock.writeLockAvailable | private boolean writeLockAvailable(int type) {
if (mReadLocks == 0 && mWriteLockHeld == null) {
return (type == UPGRADABLE) ? true : mUpgradableLockHeld == null;
}
return false;
} | java | private boolean writeLockAvailable(int type) {
if (mReadLocks == 0 && mWriteLockHeld == null) {
return (type == UPGRADABLE) ? true : mUpgradableLockHeld == null;
}
return false;
} | [
"private",
"boolean",
"writeLockAvailable",
"(",
"int",
"type",
")",
"{",
"if",
"(",
"mReadLocks",
"==",
"0",
"&&",
"mWriteLockHeld",
"==",
"null",
")",
"{",
"return",
"(",
"type",
"==",
"UPGRADABLE",
")",
"?",
"true",
":",
"mUpgradableLockHeld",
"==",
"null",
";",
"}",
"return",
"false",
";",
"}"
] | Caller must be synchronized. | [
"Caller",
"must",
"be",
"synchronized",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/SecureReadWriteLock.java#L440-L445 |
97 | teatrove/teatrove | build-tools/package-info-maven-plugin/src/main/java/org/teatrove/maven/plugins/packageinfo/PackageInfoMojo.java | PackageInfoMojo.writePackageInfos | private void writePackageInfos( File rootDir, File outputDir )
throws MojoExecutionException
{
getLog().debug( "in writePackageInfos(" + rootDir + ", " + outputDir + ")" );
try
{
if ( shouldWritePackageInfo( rootDir ) )
{
if( !outputDir.exists() && !outputDir.mkdirs() ) {
throw new MojoExecutionException( "outputDirectory was unable to be created: " + outputDir );
}
writePackageInfo( outputDir );
}
else
{
getLog().debug( "no files in:" + rootDir );
}
}
catch ( Throwable e )
{
throw new MojoExecutionException( "could not write PackageInfo.java in: " + outputDir, e );
}
// get any sub-directories
File[] subdirs = rootDir.listFiles( new FileFilter()
{
public boolean accept( File pathname )
{
return pathname.isDirectory();
}
} );
// recurse
if ( subdirs != null ) {
for (File subdir : subdirs) {
writePackageInfos(subdir, new File(outputDir, subdir.getName()));
}
}
} | java | private void writePackageInfos( File rootDir, File outputDir )
throws MojoExecutionException
{
getLog().debug( "in writePackageInfos(" + rootDir + ", " + outputDir + ")" );
try
{
if ( shouldWritePackageInfo( rootDir ) )
{
if( !outputDir.exists() && !outputDir.mkdirs() ) {
throw new MojoExecutionException( "outputDirectory was unable to be created: " + outputDir );
}
writePackageInfo( outputDir );
}
else
{
getLog().debug( "no files in:" + rootDir );
}
}
catch ( Throwable e )
{
throw new MojoExecutionException( "could not write PackageInfo.java in: " + outputDir, e );
}
// get any sub-directories
File[] subdirs = rootDir.listFiles( new FileFilter()
{
public boolean accept( File pathname )
{
return pathname.isDirectory();
}
} );
// recurse
if ( subdirs != null ) {
for (File subdir : subdirs) {
writePackageInfos(subdir, new File(outputDir, subdir.getName()));
}
}
} | [
"private",
"void",
"writePackageInfos",
"(",
"File",
"rootDir",
",",
"File",
"outputDir",
")",
"throws",
"MojoExecutionException",
"{",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"in writePackageInfos(\"",
"+",
"rootDir",
"+",
"\", \"",
"+",
"outputDir",
"+",
"\")\"",
")",
";",
"try",
"{",
"if",
"(",
"shouldWritePackageInfo",
"(",
"rootDir",
")",
")",
"{",
"if",
"(",
"!",
"outputDir",
".",
"exists",
"(",
")",
"&&",
"!",
"outputDir",
".",
"mkdirs",
"(",
")",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"outputDirectory was unable to be created: \"",
"+",
"outputDir",
")",
";",
"}",
"writePackageInfo",
"(",
"outputDir",
")",
";",
"}",
"else",
"{",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"no files in:\"",
"+",
"rootDir",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"could not write PackageInfo.java in: \"",
"+",
"outputDir",
",",
"e",
")",
";",
"}",
"// get any sub-directories",
"File",
"[",
"]",
"subdirs",
"=",
"rootDir",
".",
"listFiles",
"(",
"new",
"FileFilter",
"(",
")",
"{",
"public",
"boolean",
"accept",
"(",
"File",
"pathname",
")",
"{",
"return",
"pathname",
".",
"isDirectory",
"(",
")",
";",
"}",
"}",
")",
";",
"// recurse",
"if",
"(",
"subdirs",
"!=",
"null",
")",
"{",
"for",
"(",
"File",
"subdir",
":",
"subdirs",
")",
"{",
"writePackageInfos",
"(",
"subdir",
",",
"new",
"File",
"(",
"outputDir",
",",
"subdir",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"}",
"}"
] | recurse into rootDir writing PackageInfos on the way in.
@param rootDir The root directory for the source
@param outputDir The root directory to output to
@throws org.apache.maven.plugin.MojoExecutionException | [
"recurse",
"into",
"rootDir",
"writing",
"PackageInfos",
"on",
"the",
"way",
"in",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/package-info-maven-plugin/src/main/java/org/teatrove/maven/plugins/packageinfo/PackageInfoMojo.java#L197-L238 |
98 | teatrove/teatrove | build-tools/package-info-maven-plugin/src/main/java/org/teatrove/maven/plugins/packageinfo/PackageInfoMojo.java | PackageInfoMojo.shouldWritePackageInfo | private boolean shouldWritePackageInfo( File directory )
{
if ( !directory.isDirectory() )
return false;
if (!directory.exists())
return false;
// legacy behavior: if mPackageRootDir is a sub-dir of mSrcRootPath, an explicit package was specified
if(isChild(new File(mSrcRootPath), mPackageRootDir)) {
// return true if 'directory' passed in equals() or is a child of mPackageRootDir
return mPackageRootDir.equals(directory) || isChild(mPackageRootDir, directory);
} else { // only return true if 'directory' passed in contains at least one file
File[] files = directory.listFiles( new FileFilter()
{
public boolean accept( File pathname )
{
return pathname.isFile();
}
} );
return files != null && files.length > 0;
}
} | java | private boolean shouldWritePackageInfo( File directory )
{
if ( !directory.isDirectory() )
return false;
if (!directory.exists())
return false;
// legacy behavior: if mPackageRootDir is a sub-dir of mSrcRootPath, an explicit package was specified
if(isChild(new File(mSrcRootPath), mPackageRootDir)) {
// return true if 'directory' passed in equals() or is a child of mPackageRootDir
return mPackageRootDir.equals(directory) || isChild(mPackageRootDir, directory);
} else { // only return true if 'directory' passed in contains at least one file
File[] files = directory.listFiles( new FileFilter()
{
public boolean accept( File pathname )
{
return pathname.isFile();
}
} );
return files != null && files.length > 0;
}
} | [
"private",
"boolean",
"shouldWritePackageInfo",
"(",
"File",
"directory",
")",
"{",
"if",
"(",
"!",
"directory",
".",
"isDirectory",
"(",
")",
")",
"return",
"false",
";",
"if",
"(",
"!",
"directory",
".",
"exists",
"(",
")",
")",
"return",
"false",
";",
"// legacy behavior: if mPackageRootDir is a sub-dir of mSrcRootPath, an explicit package was specified",
"if",
"(",
"isChild",
"(",
"new",
"File",
"(",
"mSrcRootPath",
")",
",",
"mPackageRootDir",
")",
")",
"{",
"// return true if 'directory' passed in equals() or is a child of mPackageRootDir",
"return",
"mPackageRootDir",
".",
"equals",
"(",
"directory",
")",
"||",
"isChild",
"(",
"mPackageRootDir",
",",
"directory",
")",
";",
"}",
"else",
"{",
"// only return true if 'directory' passed in contains at least one file",
"File",
"[",
"]",
"files",
"=",
"directory",
".",
"listFiles",
"(",
"new",
"FileFilter",
"(",
")",
"{",
"public",
"boolean",
"accept",
"(",
"File",
"pathname",
")",
"{",
"return",
"pathname",
".",
"isFile",
"(",
")",
";",
"}",
"}",
")",
";",
"return",
"files",
"!=",
"null",
"&&",
"files",
".",
"length",
">",
"0",
";",
"}",
"}"
] | Tests if a PackageInfo.java file should be written in the directory passed in.
If the File passed in is not a directory or is not writable, false is returned.
If an explicit starting package is specified to the mojo (the legacy behavior), true is returned if
the directory passed in is a sub-package of that root package.
If an explicit starting package is NOT specified, true will only be returned if the directory passed in
contains at least one file.
@param directory The directory to write package info to.
@return returns true if a PackageInfo.java should be written. | [
"Tests",
"if",
"a",
"PackageInfo",
".",
"java",
"file",
"should",
"be",
"written",
"in",
"the",
"directory",
"passed",
"in",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/package-info-maven-plugin/src/main/java/org/teatrove/maven/plugins/packageinfo/PackageInfoMojo.java#L289-L315 |
99 | teatrove/teatrove | trove/src/main/java/org/teatrove/trove/io/LinePositionReader.java | LinePositionReader.readLine | public String readLine() throws IOException {
StringBuffer buf = new StringBuffer(80);
int line = mLineNumber;
int c;
while (line == mLineNumber && (c = read()) >= 0) {
buf.append((char)c);
}
return buf.toString();
} | java | public String readLine() throws IOException {
StringBuffer buf = new StringBuffer(80);
int line = mLineNumber;
int c;
while (line == mLineNumber && (c = read()) >= 0) {
buf.append((char)c);
}
return buf.toString();
} | [
"public",
"String",
"readLine",
"(",
")",
"throws",
"IOException",
"{",
"StringBuffer",
"buf",
"=",
"new",
"StringBuffer",
"(",
"80",
")",
";",
"int",
"line",
"=",
"mLineNumber",
";",
"int",
"c",
";",
"while",
"(",
"line",
"==",
"mLineNumber",
"&&",
"(",
"c",
"=",
"read",
"(",
")",
")",
">=",
"0",
")",
"{",
"buf",
".",
"append",
"(",
"(",
"char",
")",
"c",
")",
";",
"}",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] | After calling readLine, calling getLineNumber returns the next line
number. | [
"After",
"calling",
"readLine",
"calling",
"getLineNumber",
"returns",
"the",
"next",
"line",
"number",
"."
] | 7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/io/LinePositionReader.java#L63-L71 |